In Arduino:
File/Examples/Firmata/Standard Firmata
(This needs to have been downoaded from Arduino Reference and stored in the Arduino library)
(Library location can be found via Arduino/Preferences in the arduino software)
Upload to arduino device and close program
In Processing:
Open the example arduino file
(This needs to be downloaded from the Processing Reference page and saved into the Processing library)
(Library location can be found via Processing/Preferences in the arduino software)
import processing.serial.* ;
import cc.arduino.*;
Arduino arduino;
color off = color(4, 79, 111);
color on = color(84, 145, 158); (<-- this says what colour will show when the light sensor is fully on and fully; and fade between the two. Colours are done in RGB)
void setup() {
size(470, 280); (<-- display screen size)
arduino = new Arduino(this, Arduino.list()[0], 57600);
}
void draw() {
println(arduino.analogRead(0)); (<-- Make sure this says "analogRead", and not just "read")
}
In order to show something more visual, I need to add some more functions into "void draw":
void draw(){
println (arduino.analogRead(0));
background (255,103,255);
int input = arduino.analogRead(0);
ellipse (500,500,input,input); (<-- circle (position x, position y, size x, size y)fill (input/4, input/8, input/12); (<-- input affects colour in RGB)


No comments:
Post a Comment