Colour Fills and Arduino Pins
in
Integration and Hardware
•
6 months ago
Hi
Im trying to fill colours in my sketch but am having problems. The fills are dependent on digital pin states on an Arduino board. The Arduino board is running the Standard Firmata Sketch from Arduino IDE examples. The Processing sketch is drawing ellipses and filling the ellipses white, so looking at my code below, it seems the code see's the pin states to be low. When i give the pin 5volts i want the colour fills to be different but i cant get this to work. I have all the libraries in place so everything is fine with them.
Any Ideas, help would be appreciated.
Thanks
Sam
PImage bg; //Image variables
int y;
//Imports Arduino Libraries
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color white = color(255, 255, 255);
color black = color(0, 0, 0);
void setup() {
//DRAW SCREEN X AND Y
size(1444, 850);
smooth();
// create a font with the third font available to the system:
PFont myFont = createFont(PFont.list()[2], 60);
textFont(myFont);
//arduino is an instance of the class Arduino, first part of below
//calls the instance via the class. Not sure about between parenthesis!
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++) arduino.pinMode(i, Arduino.INPUT);
//Load Image
bg = loadImage("rockband.jpg");
bg.resize(width, height);
}
void draw() {
background(bg);
stroke(250, 138, 18);
if(arduino.digitalRead(3) == Arduino.LOW){
fill(white);
ellipse(700, 600, 200, 200); //Kick
ellipse(850, 500, 110, 35); //Snare
ellipse(490, 460, 100, 20); //HiHat
ellipse(640, 440, 95, 75); //Tom1
ellipse(755, 440, 95, 75); //Tom2
ellipse(575, 510, 120, 50); //FloorTom
ellipse(830, 380, 130, 20); //OHLeft Ride
ellipse(590, 380, 115, 20); //OHLeft Crash
}
else{
fill(black);
ellipse(700, 600, 200, 200); //Kick
ellipse(850, 500, 110, 35); //Snare
ellipse(490, 460, 100, 20); //HiHat
ellipse(640, 440, 95, 75); //Tom1
ellipse(755, 440, 95, 75); //Tom2
ellipse(575, 510, 120, 50); //FloorTom
ellipse(830, 380, 130, 20); //OHLeft Ride
ellipse(590, 380, 115, 20); //OHLeft Crash
}
}
1