Skip to content

Instantly share code, notes, and snippets.

@michaels123
Last active January 7, 2018 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaels123/55a60aeb777af32f41fc4224e27cdb73 to your computer and use it in GitHub Desktop.
Save michaels123/55a60aeb777af32f41fc4224e27cdb73 to your computer and use it in GitHub Desktop.
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);
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.OUTPUT); //Arduino Pins als Outputs definieren
}
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); //Zeichnen der Rechtecke
} //Rechtecke sind gefüllt wenn Output HIGH
//sonst Output LOW
}
void mousePressed()
{
int pin = (450 - mouseX) / 30;
//Wenn Rechteck angeklickt Output Status
if (values[pin] == Arduino.LOW) { //ändern und neuen Wert abspeichern
arduino.digitalWrite(pin, Arduino.HIGH);
values[pin] = Arduino.HIGH;
} else {
arduino.digitalWrite(pin, Arduino.LOW);
values[pin] = Arduino.LOW;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment