we encountered problems Processing couldn't read information properly from Arduino, so our lecturer offered a helping hand to solve the problems. Hence it looked like this:
Arduino
Main/idle page:
// Page 1
#define p1WaterTap 3
#define p1ShowerHot 6
#define p1ShowerCold 5
#define p1WallLightSwitch 7
// Page 2
#define p2SeatBelt 8
#define p2Radio 9
#define p2Engine 10
// Page 3
#define p3RemoteTV 11
#define p3FridgeDoor 12
#define p3WallLightSwitch A0
// Page indicators
#define triggerP1 A3
#define triggerP2 A2
#define triggerP3 A1
boolean engagedPage1;
boolean engagedPage2;
boolean engagedPage3;
boolean bookEngaged;
#define serialSendDelay 1
// SETUP
void setup() {
// Page 1
pinMode(p1WaterTap, INPUT);
pinMode(p1ShowerHot, INPUT);
pinMode(p1ShowerCold, INPUT);
pinMode(p1WallLightSwitch, INPUT);
digitalWrite(p1WaterTap, HIGH);
digitalWrite(p1ShowerHot, HIGH);
digitalWrite(p1ShowerCold, HIGH);
digitalWrite(p1WallLightSwitch, HIGH);
// Page 2
pinMode(p2SeatBelt, INPUT);
pinMode(p2Radio, INPUT);
pinMode(p2Engine, INPUT);
digitalWrite(p2SeatBelt, HIGH);
digitalWrite(p2Radio, HIGH);
digitalWrite(p2Engine, HIGH);
// Page 3
pinMode(p3RemoteTV, INPUT);
pinMode(p3FridgeDoor, INPUT);
pinMode(p3WallLightSwitch, INPUT);
digitalWrite(p3RemoteTV, HIGH);
digitalWrite(p3FridgeDoor, LOW);
digitalWrite(p3WallLightSwitch, HIGH);
// Page indicators
pinMode (triggerP1, INPUT);
pinMode (triggerP2, INPUT);
pinMode (triggerP3, INPUT);
digitalWrite(triggerP1, HIGH);
digitalWrite(triggerP2, HIGH);
digitalWrite(triggerP3, HIGH);
engagedPage1 = false;
engagedPage2 = false;
engagedPage3 = false;
bookEngaged = false;
// Serial communication
Serial.begin(9600);
Serial.println ("...");
} // END SETUP
// LOOP
void loop() {
// Page 1
if (engagedPage1 == false) {
if (digitalRead(triggerP1) == HIGH) {
bookEngaged = true;
engagedPage1 = true;
Serial.print("x");
}
}
// Page 2
if (engagedPage2 == false) {
if (digitalRead(triggerP2) == HIGH) {
bookEngaged = true;
engagedPage2 = true;
Serial.print("y");
}
}
// Page 3
if (engagedPage3 == false) {
if (digitalRead(triggerP3) == HIGH) {
bookEngaged = true;
engagedPage3 = true;
Serial.print("z");
}
}
// If the book is engaged
if (bookEngaged == true) {
// Page 1
if ( engagedPage1 == true ) {
InteractionsPage1();
}
if ( digitalRead(triggerP1) == LOW ) {
engagedPage1 = false;
}
// Page 2
if ( engagedPage2 == true ) {
InteractionsPage2();
}
if ( digitalRead(triggerP2) == LOW ) {
engagedPage2 = false;
}
// Page 3
if ( engagedPage3 == true ) {
InteractionsPage3();
}
if ( digitalRead(triggerP3) == LOW ) {
engagedPage3 = false;
}
// Reset book pages are not engaged
if ( digitalRead(triggerP1) == LOW && digitalRead(triggerP2) == LOW ) {
if ( digitalRead(triggerP3) == LOW ) {
bookEngaged = false;
engagedPage1 = false;
engagedPage2 = false;
engagedPage3 = false;
Serial.print("<");
}
}
}
// Flush serial just in case
Serial.flush();
} // END LOOP
1st page:
void InteractionsPage1() {
if ( Serial.read() == 62 ) {
// Water tap
if ( digitalRead(p1WaterTap) == LOW ) {
Serial.print('a');
delay(serialSendDelay);
}
else if ( digitalRead(p1WaterTap) == HIGH ) {
Serial.print('b');
delay(serialSendDelay);
}
// Shower
if ( digitalRead(p1ShowerHot) == LOW ) {
Serial.print('c');
delay(serialSendDelay);
}
else if ( digitalRead(p1ShowerCold) == LOW ) {
Serial.print('d');
delay(serialSendDelay);
}
// Wall light switch
if ( digitalRead(p1WallLightSwitch) == LOW ) {
Serial.print('e');
delay(serialSendDelay);
}
}
} // END InteractionsPage1
2nd page:
void InteractionsPage2() {
if ( Serial.read() == 62 ) {
// Seat belt
if (digitalRead(p2SeatBelt) == LOW) {
Serial.print('f');
delay(serialSendDelay);
}
// Radio
if (digitalRead(p2Radio) == LOW) {
Serial.print('g');
delay(serialSendDelay);
}
// Engine
if (digitalRead(p2Engine) == LOW) {
Serial.print('h');
delay(serialSendDelay);
}
}
}
3rd page:
void InteractionsPage3() {
if ( Serial.read() == 62 ) {
// TV remote
if (digitalRead(p3RemoteTV) == LOW) {
Serial.print('i');
delay(serialSendDelay);
}
// Fridge door
if (digitalRead(p3FridgeDoor) == LOW) {
Serial.print('j');
delay(serialSendDelay);
}
else if (digitalRead(p3FridgeDoor) == HIGH) {
Serial.println('l');
delay(serialSendDelay);
}
// Wall light switch
if (digitalRead(p3WallLightSwitch) == LOW) {
Serial.print('k');
delay(serialSendDelay);
}
}
}
Processing
main/idle page:
import processing.serial.*;
import processing.video.*;
Serial myCommChannel;
Movie theidlescene;
//------------------Spread 1 Movie Bin------------------------------------------------------------
Movie wakeup01;
Movie walktobathroom02;
Movie waittoturnontap03;
Movie turnontap04;
Movie brushingteeth05;
Movie turnofftap06;
Movie outcome1A07;
Movie outcome1B08;
Movie continuewater09;
Movie finishbrushteeth10;
Movie walktoshower11;
Movie waittohotandcold12;
Movie outcomehot13;
Movie outcomecold14;
Movie shower15;
Movie finishshower16;
Movie waittopressswitch17;
Movie pressswitch18;
Movie outcome3A19;
Movie outcome3B20;
Movie goout21;
//-------------------Spread 2 Movie Bin-----------------------------------------------------------
Movie firstScene;
Movie secondScene;
Movie secondTwoScene;
Movie thirdScene;
Movie thirdTwoScene;
Movie fourthScene;
Movie fourthTwoScene;
Movie fourthThreeScene;
Movie fifthScene;
Movie sixthScene;
Movie sixthTwoScene;
Movie sixthThreeScene;
Movie seventhScene;
Movie infoOne;
Movie infoTwo;
//--------------------Spread 3 Movie Bin----------------------------------------------------------
Movie reachhome_301;
Movie sitdown_302;
Movie waittopressremote_303;
Movie pressremote_304;
Movie watchtv_305;
Movie walktofridge_306;
Movie waittoopenfridge_307;
Movie openfridge_308;
Movie getfood_309;
Movie outcomefridge_310;
Movie waittoclosefridge_311;
Movie closefridge_312;
Movie walkbacktocouch_313;
Movie yawn_314;
Movie outcome1A_315;
Movie outcome1B_316;
Movie walktobedroom_317;
Movie waittopressswitch_318;
Movie outcome2A_319;
Movie outcome2B_320;
Movie gosleep_321;
//------------------------------------------------------------------------------
boolean serialCreated = false;
boolean idlescene = true;
//--------------------Spread 1 Boolean----------------------------------------------------------
boolean wakeup101;
boolean walk102;
boolean waittap103;
boolean turntapon104;
boolean brushteeth105;
boolean turntapoff106;
boolean turntapoff106bad;
boolean outcomebadwater107;
boolean outcomegoodwater108;
boolean continuewater109;
boolean finishbrush110;
boolean walktoshower111;
boolean waitheater112;
boolean outcomehot113;
boolean outcomecold114;
boolean finishshower116;
boolean waitswitch1117;
boolean pressswitch1118;
boolean pressswitch1118bad;
boolean outcomebadlight119;
boolean outcomegoodlight120;
boolean goout121;
//-------------------Spread 2 Boolean----------------------------------------------------------
boolean firstPlaying;
boolean secondPlaying;
boolean secondTwoPlaying;
boolean thirdPlaying;
boolean thirdTwoPlaying;
boolean fourthPlaying;
boolean fourthTwoPlaying;
boolean fourthThreePlaying;
boolean fifthPlaying;
boolean sixthPlaying;
boolean infoOnePlaying;
boolean infoTwoPlaying;
boolean sixthTwoPlaying;
boolean sixthThreePlaying;
boolean seventhPlaying;
//-------------------Spread 3 Boolean-----------------------------------------------------------
boolean gohome_3301;
boolean sitdown_3302;
boolean waitremote_3303;
boolean pressremote_3304;
boolean watchtv_3305;
boolean walktofridge_3306;
boolean waitfridge_3307;
boolean openfridge_3308;
boolean getfood_3309;
boolean outcomefridge_3310;
boolean waitfridgeclose_3311;
boolean closefridge_3312;
boolean walkback_3313;
boolean yawn_3314;
boolean waitremoteoff_3315;
boolean pressremoteoff_3316;
boolean pressremoteoff_3316bad;
boolean outcomebadremote_3317;
boolean outcomegoodremote_3318;
boolean walktobed_3319;
boolean waitswitch3_3320;
boolean pressswitch3_3321;
boolean pressswitch3_3321bad;
boolean outcomebadswitch_3322;
boolean outcomegoodswitch_3323;
boolean gosleep_3324;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int myTime0000;
int myTime0101;
int myTime0102;
int myTime0103;
int myTime0201;
int myTime0202;
int myTime0203;
int myTime0301;
int myTime0302;
int myTime0303;
int myTime0304;
int myTime0305;
int waitTime = 7200;
int waitReset = 10000;
/*
*SETUP
*/
void setup() {
//printArray(Serial.list());
frameRate(25);
//size (720,1080);
fullScreen(2);
initializeVariables();
if (serialCreated == false) { // Prevents serial from being re-created when sketch is reset
myCommChannel = new Serial(this, Serial.list()[1], 9600);
serialCreated = true;
}
theidlescene = new Movie (this, "00idle.mp4");
println("START");
InstantiateMoviesSpread1();
InstantiateMoviesSpread2();
InstantiateMoviesSpread3();
startCounting00();
} // END SETUP
/*
*DRAW
*/
void draw()
{
if (idlescene) {
playidle();
} else {
Spread1();
Spread2();
Spread3();
}
} // END DRAW
void startCounting00() {
myTime0000 = millis();
}
void movieEvent(Movie m) {
m.read();
}
void endit() {
frameCount = -1;
}
char getSerialInput() {
myCommChannel.write(">");
delay(1);
char inputChar = myCommChannel.readChar();
return inputChar;
}
void mouseClicked() {
//setup();
initializeVariables();
frameCount = -1;
}
movie bin:
void InstantiateMoviesSpread1() {
//----------------Define Spread 1 Movie--------------------------------------------------------------
wakeup01 = new Movie(this, "0101wakeup.mp4");
walktobathroom02 = new Movie(this, "0102walktoabathroom.mp4");
waittoturnontap03 = new Movie(this, "0103waittoturnonwatertap.mp4");
turnontap04 = new Movie(this, "0104turnonwatertap.mp4");
brushingteeth05 = new Movie (this, "0105brushteethloop.mp4");
turnofftap06 = new Movie(this, "0106turnofftap.mp4");
outcome1A07 = new Movie(this, "0108outcomeB.mp4");
outcome1B08 = new Movie(this, "0108outcomeB.mp4");
continuewater09 = new Movie(this, "0109contbrushingteethnowater.mp4");
finishbrushteeth10 = new Movie(this, "0110finishbrushteeth.mp4");
walktoshower11 = new Movie(this, "0111walktoshower.mp4");
waittohotandcold12 = new Movie(this, "0112waittohotandcold.mp4");
outcomehot13 = new Movie(this, "0113outcomeHot.mp4");
outcomecold14 = new Movie(this, "0114outcomeCold.mp4");
//shower15 = new Movie(this, "0115shower.mp4");
finishshower16 = new Movie(this, "0116comeoutshowertodoor.mp4");
waittopressswitch17 = new Movie(this, "0117waittopressswitch.mp4");
pressswitch18 = new Movie(this, "0118opressswitch.mp4");
outcome3A19 = new Movie(this, "0119outcomeA.mp4");
outcome3B20 = new Movie(this, "0120outcomeB.mp4");
goout21 = new Movie(this, "0121goout.mp4");
}
void InstantiateMoviesSpread2() {
//-----------------Define Spread 2 Movie-------------------------------------------------------------
firstScene = new Movie(this, "02_02_01.mp4");
secondScene = new Movie(this, "02_02_02.mp4");
secondTwoScene = new Movie(this, "02_02_03.mp4");
thirdScene = new Movie(this, "02_03_01.mp4");
thirdTwoScene = new Movie (this, "02_03_02.mp4");
fourthScene = new Movie(this, "02_04_01.mp4");
fourthTwoScene = new Movie(this, "02_04_02.mp4");
fourthThreeScene = new Movie(this, "02_04_03.mp4");
fifthScene = new Movie(this, "02_05.mp4");
sixthScene = new Movie(this, "02_06_01.mp4");
sixthTwoScene = new Movie(this, "02_06_02.mp4");
sixthThreeScene = new Movie(this, "02_06_03.mp4");
seventhScene = new Movie(this, "02_07.mp4");
infoOne = new Movie(this, "infoTwo.mp4");
infoTwo = new Movie(this, "infoTwo.mp4");
}
void InstantiateMoviesSpread3() {
//---------------Define Spread 3 Movie---------------------------------------------------------------
reachhome_301 = new Movie(this, "0301arrive.mp4");
sitdown_302 = new Movie(this, "0302putandsit.mp4");
waittopressremote_303 = new Movie(this, "0303waittopressremote.mp4");
pressremote_304 = new Movie(this, "0304pressremote.mp4");
watchtv_305 = new Movie (this, "0305watchingtv.mp4");
walktofridge_306 = new Movie(this, "0306walktofridge.mp4");
waittoopenfridge_307 = new Movie(this, "0307waittoopenfridge.mp4");
openfridge_308 = new Movie(this, "0308openfridge.mp4");
getfood_309 = new Movie(this, "0309getfood.mp4");
outcomefridge_310 = new Movie(this, "0310outcomefridge.mp4");
waittoclosefridge_311 = new Movie(this, "0311waittoclosefridge.mp4");
closefridge_312 = new Movie(this, "0312closefridge.mp4");
walkbacktocouch_313 = new Movie(this, "0313walkbacktocouch.mp4");
yawn_314 = new Movie(this, "0314yawn.mp4");
outcome1A_315 = new Movie(this, "0316outcomeB.mp4");
outcome1B_316 = new Movie(this, "0316outcomeB.mp4");
walktobedroom_317 = new Movie(this, "0317walkingtobedroom.mp4");
waittopressswitch_318 = new Movie(this, "0117waittopressswitch.mp4");
outcome2A_319 = new Movie(this, "0320outcomeB.mp4");
outcome2B_320 = new Movie(this, "0320outcomeB.mp4");
gosleep_321 = new Movie(this, "0321gosleep.mp4");
}
1st page:
void Spread1() {
if (wakeup101) {
play101();
}
if (walk102) {
play102();
}
if (waittap103) {
play103();
}
if (turntapon104) {
play104();
}
if (brushteeth105) {
play105();
}
if (turntapoff106) {
play106();
}
if (turntapoff106bad) {
play106bad();
}
if (outcomebadwater107) {
play107();
}
if (outcomegoodwater108) {
play108();
}
if (continuewater109) {
play109();
}
if (finishbrush110) {
play110();
}
if (walktoshower111) {
play111();
}
if (waitheater112) {
play112();
}
if (outcomehot113) {
play113();
}
if (outcomecold114) {
play114();
}
if (finishshower116) {
play116();
}
if (waitswitch1117) {
play117();
}
if (pressswitch1118) {
play118();
}
if (pressswitch1118bad) {
play118bad();
}
if (outcomebadlight119) {
play119();
}
if (outcomegoodlight120) {
play120();
}
if (goout121) {
play121();
}
}
//-------------------SPREAD 1---------------------------------------------------
//------------------------------------------------------------------------------
void play101() {
wakeup01.play();
image(wakeup01, 0, 0, wakeup01.width, wakeup01.height);
if (wakeup01.time() >= wakeup01.duration()-0.3 ) {
wakeup01.stop();
wakeup101 = false;
walk102 = true;
}
}
void play102() {
walktobathroom02.play();
image(walktobathroom02, 0, 0, walktobathroom02.width, walktobathroom02.height);
if (walktobathroom02.time() >= walktobathroom02.duration()-0.3 ) {
walktobathroom02.stop();
walk102 = false;
waittap103 = true;
}
}
void play103() {
waittoturnontap03.loop();
image(waittoturnontap03, 0, 0, waittoturnontap03.width, waittoturnontap03.height);
char inputChar = getSerialInput();
switch (inputChar) {
case 'a':
waittoturnontap03.noLoop();
waittoturnontap03.stop();
waittap103=false;
turntapon104 = true;
myCommChannel.clear();
break;
}
}
void play104() {
turnontap04.play();
image(turnontap04, 0, 0, turnontap04.width, turnontap04.height);
if (turnontap04.time() >= turnontap04.duration()-0.3 ) {
turnontap04.stop();
turntapon104 = false;
startCounting1One();
brushteeth105 = true;
}
}
void startCounting1One() {
myTime0101 = millis();
}
void play105() {
brushingteeth05.loop();
//if ( brushingteeth05.available() == true) {
image(brushingteeth05, 0, 0, brushingteeth05.width, brushingteeth05.height);
//}
//if (millis() - myTime0101 >= waitTime) {
// brushingteeth05.noLoop();
// brushingteeth05.stop();
// brushteeth105=false;
// outcomebadwater107 = true;
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'b':
brushingteeth05.noLoop();
brushingteeth05.stop();
brushteeth105=false;
turntapoff106 = true;
myCommChannel.clear();
break;
}
}
void play106() {
turnofftap06.play();
image(turnofftap06, 0, 0, turnofftap06.width, turnofftap06.height);
if (turnofftap06.time() >= turnofftap06.duration()-0.3 ) {
turnofftap06.stop();
turntapoff106 = false;
outcomegoodwater108 = true;
}
}
void play107() {
outcome1A07.loop();
//if (outcome1A07.available() == true) {
image(outcome1A07, 0, 0, outcome1A07.width, outcome1A07.height);
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'b':
outcome1A07.noLoop();
outcome1A07.stop();
outcomebadwater107=false;
turntapoff106bad = true;
myCommChannel.clear();
break;
}
}
void play106bad() {
turnofftap06.play();
image(turnofftap06, 0, 0, turnofftap06.width, turnofftap06.height);
if (turnofftap06.time() >= turnofftap06.duration()-0.3 ) {
turnofftap06.stop();
turntapoff106 = false;
continuewater109 = true;
}
}
void play108() {
outcome1B08.play();
image(outcome1B08, 0, 0, outcome1B08.width, outcome1B08.height);
if (outcome1B08.time() >= outcome1B08.duration()-0.3 ) {
outcome1B08.stop();
outcomegoodwater108 = false;
continuewater109 = true;
}
}
void play109() {
continuewater09.play();
image(continuewater09, 0, 0, continuewater09.width, continuewater09.height);
if (continuewater09.time() >= continuewater09.duration()-0.3 ) {
continuewater09.stop();
continuewater109 = false;
finishbrush110 = true;
}
}
void play110() {
finishbrushteeth10.play();
image(finishbrushteeth10, 0, 0, finishbrushteeth10.width, finishbrushteeth10.height);
if (finishbrushteeth10.time() >= finishbrushteeth10.duration()-0.3 ) {
finishbrushteeth10.stop();
finishbrush110 = false;
walktoshower111 = true;
}
}
void play111() {
walktoshower11.play();
image(walktoshower11, 0, 0, walktoshower11.width, walktoshower11.height);
if (walktoshower11.time() >= walktoshower11.duration()-0.3 ) {
walktoshower11.stop();
walktoshower111 = false;
waitheater112 = true;
}
}
void play112() {
waittohotandcold12.loop();
//if (waittohotandcold12.available() == true) {
image(waittohotandcold12, 0, 0, waittohotandcold12.width, waittohotandcold12.height);
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'c':
waittohotandcold12.noLoop();
waittohotandcold12.stop();
waitheater112=false;
startCounting1Two();
outcomehot113 = true;
println("this is hot");
myCommChannel.clear();
delay(500);
break;
case 'd':
waittohotandcold12.noLoop();
waittohotandcold12.stop();
waitheater112=false;
startCounting1Two();
outcomecold114 = true;
println("this is cold");
myCommChannel.clear();
delay(500);
break;
}
}
void startCounting1Two() {
myTime0102 = millis();
}
void play113() {
outcomehot13.loop();
//if (outcomehot13.available() == true) {
image(outcomehot13, 0, 0, outcomehot13.width, outcomehot13.height);
//}
if (millis() - myTime0102 >= waitTime) {
outcomehot13.noLoop();
outcomehot13.stop();
outcomehot113=false;
//shower115 = true;
finishshower116 = true;
println("playing hot");
}
}
void play114() {
outcomecold14.loop();
//if (outcomecold14.available() == true) {
image(outcomecold14, 0, 0, outcomecold14.width, outcomecold14.height);
//}
if (millis() - myTime0102 >= waitTime) {
outcomecold14.noLoop();
outcomecold14.stop();
outcomecold114=false;
//shower115 = true;
finishshower116 = true;
println("tplaying cold");
}
}
void play116() {
finishshower16.play();
image(finishshower16, 0, 0, finishshower16.width, finishshower16.height);
if (finishshower16.time() >= finishshower16.duration()-0.3 ) {
finishshower16.stop();
finishshower116 = false;
startCounting1Three();
waitswitch1117 = true;
}
}
void startCounting1Three() {
myTime0103 = millis();
}
void play117() {
waittopressswitch17.loop();
//if (waittopressswitch17.available() == true) {
image(waittopressswitch17, 0, 0, waittopressswitch17.width, waittopressswitch17.height);
//}
if (millis() - myTime0103 >= waitTime) {
waittopressswitch17.noLoop();
waittopressswitch17.stop();
waitswitch1117=false;
outcomebadlight119 = true;
}
char inputChar = getSerialInput();
switch (inputChar) {
case 'e':
waittopressswitch17.noLoop();
waittopressswitch17.stop();
waitswitch1117=false;
pressswitch1118 = true;
myCommChannel.clear();
break;
}
}
void play118() {
pressswitch18.play();
image(pressswitch18, 0, 0, pressswitch18.width, pressswitch18.height);
if (pressswitch18.time() >= pressswitch18.duration()-0.3 ) {
pressswitch18.stop();
pressswitch1118 = false;
outcomegoodlight120 = true;
}
}
void play119() {
outcome3A19.loop();
//if (outcome3A19.available() == true) {
image(outcome3A19, 0, 0, outcome3A19.width, outcome3A19.height);
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'e':
outcome3A19.noLoop();
outcome3A19.stop();
outcomebadlight119=false;
pressswitch1118bad = true;
myCommChannel.clear();
break;
}
}
void play118bad() {
pressswitch18.play();
image(pressswitch18, 0, 0, pressswitch18.width, pressswitch18.height);
if (pressswitch18.time() >= pressswitch18.duration()-0.3 ) {
pressswitch18.stop();
pressswitch1118bad = false;
goout121 = true;
}
}
void play120() {
outcome3B20.play();
image(outcome3B20, 0, 0, outcome3B20.width, outcome3B20.height);
if (outcome3B20.time() >= outcome3B20.duration()-0.3 ) {
outcome3B20.stop();
outcomegoodlight120 = false;
goout121 = true;
}
}
void play121() {
goout21.play();
image(goout21, 0, 0, goout21.width, goout21.height);
if (goout21.time() >= goout21.duration()-0.3 ) {
goout21.stop();
goout121 = false;
//initializeVariables();
//idlescene = true;
endit();
}
}
2nd page:
void Spread2() {
if (firstPlaying) {
playFirstScene();
}
if (secondPlaying) {
playSecondScene();
}
if (secondTwoPlaying) {
playSecondTwoScene();
}
if (thirdPlaying) {
playThirdScene();
}
if (thirdTwoPlaying) {
playThirdTwoScene();
}
if (fourthPlaying) {
playFourthScene();
}
if (fourthTwoPlaying) {
playFourthTwoScene();
}
if (fourthThreePlaying) {
playFourthThreeScene();
}
if (fifthPlaying) {
playFifthScene();
}
if (sixthPlaying) {
playSixthScene();
}
if (infoOnePlaying) {
playInfoOne();
}
if (sixthTwoPlaying) {
playSixthTwoScene();
}
if (infoTwoPlaying) {
playInfoTwo();
}
if (sixthThreePlaying) {
playSixthThreeScene();
}
if (seventhPlaying) {
playSeventhScene();
}
}
//-------------------SPREAD 2---------------------------------------------------
//------------------------------------------------------------------------------
void playFirstScene() {
firstScene.play();
//image(firstScene, 0, 0, firstScene.width, firstScene.height);
image(firstScene, 0, 0, width, height);
if (firstScene.time() >= firstScene.duration()-0.3 ) {
firstScene.stop();
firstPlaying = false;
secondPlaying = true;
}
}
void playSecondScene() {
secondScene.play();
//image(secondScene, 0, 0, secondScene.width, secondScene.height);
image(secondScene, 0, 0, width, height);
if (secondScene.time() >= secondScene.duration()-0.3) {
secondScene.stop();
secondPlaying = false;
secondTwoPlaying = true;
}
}
void playSecondTwoScene() {
secondTwoScene.play();
//image(secondTwoScene, 0, 0, secondTwoScene.width, secondTwoScene.height);
image(secondTwoScene, 0, 0, width, height);
if (secondTwoScene.time() >= secondTwoScene.duration()-0.3) {
secondTwoScene.stop();
secondTwoPlaying = false;
thirdPlaying = true;
}
}
void playThirdScene() {
thirdScene.loop();
//if (thirdScene.available() == true) {
//image(thirdScene, 0, 0, thirdScene.width, thirdScene.height);
image(thirdScene, 0, 0, width, height);
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'f':
thirdScene.noLoop();
thirdScene.stop();
thirdPlaying=false;
thirdTwoPlaying = true;
myCommChannel.clear();
break;
}
}
void playThirdTwoScene() {
thirdTwoScene.play();
//image(thirdTwoScene, 0, 0, thirdTwoScene.width, thirdTwoScene.height);
image(thirdTwoScene, 0, 0, width, height);
if (thirdTwoScene.time() >= thirdTwoScene.duration()-0.3) {
thirdTwoScene.stop();
thirdTwoPlaying=false;
fourthPlaying = true;
}
}
void playFourthScene() {
fourthScene.loop();
//if (fourthScene.available() == true) {
//image(fourthScene, 0, 0, fourthScene.width, fourthScene.height);
image(fourthScene, 0, 0, width, height);
//}
char inputChar = getSerialInput();
switch (inputChar) {
case 'g':
fourthScene.noLoop();
fourthScene.stop();
fourthPlaying=false;
fourthTwoPlaying = true;
myCommChannel.clear();
break;
}
}
void playFourthTwoScene() {
fourthTwoScene.play();
//image(fourthTwoScene, 0, 0, fourthTwoScene.width, fourthTwoScene.height);
image(fourthTwoScene, 0, 0, width, height);
if (fourthTwoScene.time() >= fourthTwoScene.duration()-0.3) {
fourthTwoScene.stop();
fourthTwoPlaying=false;
fourthThreePlaying = true;
}
}
void playFourthThreeScene() {
fourthThreeScene.play();
//image(fourthThreeScene, 0, 0, fourthThreeScene.width, fourthThreeScene.height);
image(fourthThreeScene, 0, 0, width, height);
if (fourthThreeScene.time() >= fourthThreeScene.duration()-0.3) {
fourthThreeScene.stop();
fourthThreePlaying=false;
fifthPlaying = true;
}
}
void playFifthScene() {
fifthScene.play();
//image(fifthScene, 0, 0, fifthScene.width, fifthScene.height);
image(fifthScene, 0, 0, width, height);
if (fifthScene.time() >= fifthScene.duration()-0.3) {
fifthScene.stop();
fifthPlaying=false;
startCounting2();
//println(myTime);
sixthPlaying = true;
}
}
void startCounting2() {
myTime0201 = millis();
}
void playSixthScene() {
sixthScene.loop();
//if (sixthScene.available() == true) {
//image(sixthScene, 0, 0, sixthScene.width, sixthScene.height);
image(sixthScene, 0, 0, width, height);
//}
if (millis() - myTime0201 >= waitTime) {
sixthScene.noLoop();
sixthScene.stop();
sixthPlaying=false;
startCounting2Two();
infoOnePlaying = true;
println("this is detected");
}
char inputChar = getSerialInput();
switch (inputChar) {
case 'h':
sixthScene.noLoop();
sixthScene.stop();
sixthPlaying=false;
sixthTwoPlaying = true;
println("good");
myCommChannel.clear();
break;
}
}
void startCounting2Two() {
myTime0202 = millis();
}
void playInfoOne() {
println("playing info one");
infoOne.loop();
//if (infoOne.available() == true) {
//image(infoOne, 0, 0, infoOne.width, infoOne.height);
image(infoOne, 0, 0, width, height);
//}
if (millis() - myTime0202 >= waitTime) {
infoOne.noLoop();
infoOne.stop();
infoOnePlaying=false;
sixthThreePlaying = true;
}
}
void playSixthTwoScene() {
sixthTwoScene.play();
//image(sixthTwoScene, 0, 0, sixthTwoScene.width, sixthTwoScene.height);
image(sixthTwoScene, 0, 0, width, height);
if (sixthTwoScene.time() >= sixthTwoScene.duration()-0.3) {
sixthTwoScene.stop();
sixthTwoPlaying = false;
startCounting2Three();
infoTwoPlaying = true;
}
}
void startCounting2Three() {
myTime0203 = millis();
}
void playInfoTwo() {
infoTwo.loop();
//if (infoTwo.available() == true) {
//image(infoTwo, 0, 0, infoTwo.width, infoTwo.height);
image(infoTwo, 0, 0, width, height);
//}
if (millis() - myTime0203 >= waitTime) {
infoTwo.noLoop();
infoTwo.stop();
infoTwoPlaying=false;
sixthThreePlaying = true;
}
}
void playSixthThreeScene() {
sixthThreeScene.play();
//image(sixthThreeScene, 0, 0, sixthThreeScene.width, sixthThreeScene.height);
image(sixthThreeScene, 0, 0, width, height);
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.