Help with code for setting off an image when arduino input is high
in
Integration and Hardware
•
1 year ago
Hello!
I've been trying to set off an image when a hand is waved over a sensor plugged into the arduino. Using processing, through firmata, connected with the arduino, I want the image to show up when the input is high. But so far, the image doesn't even pop up. Can anyone help or point me in the right direction?
Here's my code:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color off = color(5, 79, 200);
color on = color(84, 145, 158);
void setup() {
size(1440, 900);
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
}
void draw() {
background(off);
stroke(on);
PImage img;
for (int i = 0; i <= 13; i++) {
if (arduino.digitalRead(i) == Arduino.HIGH)
img = loadImage("Screen shot 2012-03-13 at 1.49.50 PM.png");
else
fill(off);
}
for (int i = 0; i <= 5; i++) {
ellipse(280 + i * 30, 240, arduino.analogRead(i) / 16, arduino.analogRead(i) / 16);
}
}
I've been trying to set off an image when a hand is waved over a sensor plugged into the arduino. Using processing, through firmata, connected with the arduino, I want the image to show up when the input is high. But so far, the image doesn't even pop up. Can anyone help or point me in the right direction?
Here's my code:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color off = color(5, 79, 200);
color on = color(84, 145, 158);
void setup() {
size(1440, 900);
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
}
void draw() {
background(off);
stroke(on);
PImage img;
for (int i = 0; i <= 13; i++) {
if (arduino.digitalRead(i) == Arduino.HIGH)
img = loadImage("Screen shot 2012-03-13 at 1.49.50 PM.png");
else
fill(off);
}
for (int i = 0; i <= 5; i++) {
ellipse(280 + i * 30, 240, arduino.analogRead(i) / 16, arduino.analogRead(i) / 16);
}
}
1