diff --git a/arduino/arduino.ino b/arduino/arduino.ino index 4965250..0b4b715 100644 --- a/arduino/arduino.ino +++ b/arduino/arduino.ino @@ -11,6 +11,7 @@ Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); const char HEADER = 'H'; const char A_TAG = 'M'; const char B_TAG = 'X'; +const char C_TAG = 'U'; const int TOTAL_BYTES = 10 ; // the total bytes in a message int atomPins[] = {2,3,4,5,6,7,8,9}; @@ -60,36 +61,43 @@ void loop() { if(Serial.available() >= TOTAL_BYTES) { if( Serial.read() == HEADER) { char tag = Serial.read(); - if(tag == A_TAG) { + if(tag == A_TAG || tag == B_TAG) { for(int i=0; i<8; i++) { values[i] = Serial.read(); } } - - for(int i=0; i<8; i++) { - pwm.setPWM(i, 0, SERVOMIN); - delay(values[i]*SERVODIVIDER); - pwm.setPWM(i, 0, ((SERVOMAX-SERVOMIN)/2)+SERVOMIN); - } - - while(cycle < 8) { + + if(tag == C_TAG) { + for(int i=0; i<8; i++) { + pwm.setPWM(i, 0, SERVOMAX+50); + delay(100*SERVODIVIDER); + pwm.setPWM(i, 0, ((SERVOMAX-SERVOMIN)/2)+SERVOMIN); + } + } else { for(int i=0; i<8; i++) { - Serial.print(values[i]); - Serial.print(" "); - if(values[i]>0) { - values[i]--; - digitalWrite(atomPins[i], HIGH); - if(values[i]==0) { - cycle++; - digitalWrite(atomPins[i], LOW); + pwm.setPWM(i, 0, SERVOMIN); + delay(values[i]*SERVODIVIDER); + pwm.setPWM(i, 0, ((SERVOMAX-SERVOMIN)/2)+SERVOMIN); + } + + if(tag == A_TAG) { + while(cycle < 8) { + for(int i=0; i<8; i++) { + Serial.print(values[i]); + Serial.print(" "); + if(values[i]>0) { + values[i]--; + digitalWrite(atomPins[i], HIGH); + if(values[i]==0) { + cycle++; + digitalWrite(atomPins[i], LOW); + } + } } - } + Serial.println(""); + delay(TIMER); + } } - - Serial.println(""); - delay(TIMER); - - //digitalWrite(13, LOW); } } } diff --git a/ephimera/ephimera.pde b/ephimera/ephimera.pde index 4b2d253..2f9224b 100644 --- a/ephimera/ephimera.pde +++ b/ephimera/ephimera.pde @@ -57,6 +57,7 @@ void draw() { } void keyPressed() { + if (key == 'S' || key == 's') { video.pause(); makePicture(); @@ -67,4 +68,19 @@ void keyPressed() { if (key == 'G' || key == 'g') { video.start(); } + + if (key == 'U' || key == 'u') { + sendMessage(C_TAG, colorByteValues); + } + + if (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8') { + for(int i = 0; i