From 49170f86e2417807a415d089b782ec1fb00aec75 Mon Sep 17 00:00:00 2001 From: Leandro Estrella rPi Date: Sat, 5 Oct 2019 16:03:26 +0200 Subject: [PATCH 1/4] add keys in processing --- ephimera/ephimera.pde | 16 ++++++++++++++++ ephimera/serial.pde | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) mode change 100755 => 100644 ephimera/serial.pde diff --git a/ephimera/ephimera.pde b/ephimera/ephimera.pde index 4b2d253..352c0ad 100644 --- a/ephimera/ephimera.pde +++ b/ephimera/ephimera.pde @@ -57,6 +57,7 @@ void draw() { } void keyPressed() { + println(int(key)); 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 Date: Sat, 5 Oct 2019 16:19:30 +0200 Subject: [PATCH 2/4] fix numeric keys --- ephimera/ephimera.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ephimera/ephimera.pde b/ephimera/ephimera.pde index 352c0ad..f4d9eb7 100644 --- a/ephimera/ephimera.pde +++ b/ephimera/ephimera.pde @@ -73,7 +73,7 @@ void keyPressed() { sendMessage(C_TAG, colorByteValues); } - if (key == '1' || key == '2' || key == 3 || key == 4 || key == 5 || key == 6 || key == 7 || key == 8) { + if (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8') { for(int i = 0; i Date: Sat, 5 Oct 2019 16:21:22 +0200 Subject: [PATCH 3/4] rm debug --- ephimera/ephimera.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ephimera/ephimera.pde b/ephimera/ephimera.pde index f4d9eb7..2f9224b 100644 --- a/ephimera/ephimera.pde +++ b/ephimera/ephimera.pde @@ -57,7 +57,7 @@ void draw() { } void keyPressed() { - println(int(key)); + if (key == 'S' || key == 's') { video.pause(); makePicture(); From 44edd3b1918e0919b6e2d5e72136624200c1d0a7 Mon Sep 17 00:00:00 2001 From: Carmine De Rosa Date: Sat, 5 Oct 2019 16:22:07 +0200 Subject: [PATCH 4/4] update arduino sketch --- arduino/arduino.ino | 54 ++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 23 deletions(-) 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); } } }