big93
YaBB Newbies
Offline
Posts: 3
key press example
Jan 3rd , 2008, 3:04am
hi, im a noob at processing, and i just found out how wounderfull the language is to use with arduino, becuase it opens up many more possibilities, and i'm having problems doing my first project. i'm trying to make it so when i press a button on my keyboard, an led will turn on. But i'm getting several problems, most saying that "void" does not belong in the place i put it. now this code IS NOT ANYWHERE NEAR THE CODE I WANT, this is simply an output test for the arduino, but i really don't know how to layout the language so it does not interfear with the arduinos translation to using processing. if anybody could please fix up the code, and compile it to see if it works, because i cant get what im trying, so if anybody could just make it really quick, i would greatly apreciate it, heres the sample output code: import processing.serial.*; import cc.arduino.*; Arduino arduino; color off = color(4, 79, 111); color on = color(84, 145, 158); int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW }; void setup() { size(470, 200); println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[0], 57600); for (int i = 0; i <= 13; i++) arduino.pinMode(i, Arduino.OUTPUT); } void draw() { background(off); stroke(on); for (int i = 0; i <= 13; i++) { if (values[i] == Arduino.HIGH) fill(on); else fill(off); rect(420 - i * 30, 30, 20, 20); } } void mousePressed() { int pin = (450 - mouseX) / 30; if (values[pin] == Arduino.LOW) { arduino.digitalWrite(pin, Arduino.HIGH); values[pin] = Arduino.HIGH; } else { arduino.digitalWrite(pin, Arduino.LOW); values[pin] = Arduino.LOW; } } please just change it so i get the desired effect, thanks and happy new years! -big93