And here we are again!
Updates on the project:
Decided to use Arduino Mega in order to have more RAM and pins. Also, we shrunk the videos to ~1M size with 12 fps. Also, perhaps using a lower Serial port will help with speed.
Arduino code so far:
//Declaration of variables
int bend1 = A0;
int bend2 = A1;
int bend3 = A2;
int bend4 = A3;
void setup()
{
Serial.begin(9600);
}
void loop()
//Print the analogical input to send to Processing
{
Serial.print(analogRead(bend1));
Serial.print(",");
Serial.print(analogRead(bend2));
Serial.print(",");
Serial.print(analogRead(bend3));
Serial.print(",");
//print and space
Serial.println(analogRead(bend4));
}
Processing code so far:
import processing.serial.*;
import processing.video.*;
//sensors
float s1 = 0;
float s2 = 0;
float s3 = 0;
float s4 = 0;
float stotal;
Movie trololo;
Serial myPort;
void setup() {
trololo = new Movie(this, "trololo.mp4");
size(480,360,P2D);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
}
void serialEvent(Serial myPort) {
String inString = myPort.readStringUntil('\n');
float[] sensors = float(split(inString, ","));
//read the sensor values
s1 = map(sensors[0], 0, 1023, 0, 1000);
s2 = map(sensors[1], 0, 1023, 0, 1000);
s3 = map(sensors[2], 0, 1023, 0, 1000);
s4 = map(sensors[3], 0, 1023, 0, 1000);
//average of sensor inputs
stotal = sensors[0] + sensors[1] + sensors[2] + sensors[3];
if (stotal >= 2046) {
trololo.play();
}
}
void movieEvent(Movie trololo) {
trololo.read();
}
void draw() {
image(trololo,0,0);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment