Browse Source

Merge branch 'feature/load_unload_liquid' into develop

develop
Carmine De Rosa 6 years ago
parent
commit
a66795d978
  1. 50
      arduino/arduino.ino
  2. 16
      ephimera/ephimera.pde
  3. 1
      ephimera/serial.pde

50
arduino/arduino.ino

@ -11,6 +11,7 @@ Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
const char HEADER = 'H'; const char HEADER = 'H';
const char A_TAG = 'M'; const char A_TAG = 'M';
const char B_TAG = 'X'; const char B_TAG = 'X';
const char C_TAG = 'U';
const int TOTAL_BYTES = 10 ; // the total bytes in a message const int TOTAL_BYTES = 10 ; // the total bytes in a message
int atomPins[] = {2,3,4,5,6,7,8,9}; int atomPins[] = {2,3,4,5,6,7,8,9};
@ -60,36 +61,43 @@ void loop() {
if(Serial.available() >= TOTAL_BYTES) { if(Serial.available() >= TOTAL_BYTES) {
if( Serial.read() == HEADER) { if( Serial.read() == HEADER) {
char tag = Serial.read(); char tag = Serial.read();
if(tag == A_TAG) {
if(tag == A_TAG || tag == B_TAG) {
for(int i=0; i<8; i++) { for(int i=0; i<8; i++) {
values[i] = Serial.read(); 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++) { 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);
} }
} }
} }

16
ephimera/ephimera.pde

@ -57,6 +57,7 @@ void draw() {
} }
void keyPressed() { void keyPressed() {
if (key == 'S' || key == 's') { if (key == 'S' || key == 's') {
video.pause(); video.pause();
makePicture(); makePicture();
@ -67,4 +68,19 @@ void keyPressed() {
if (key == 'G' || key == 'g') { if (key == 'G' || key == 'g') {
video.start(); 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<colorsN; i++) {
colorByteValues[i] = (int(key)-49) == i ? byte(100) : 0;
print(colorByteValues[i] + "\t");
}
println("");
sendMessage(B_TAG, colorByteValues);
}
} }

1
ephimera/serial.pde

@ -1,6 +1,7 @@
public static final char HEADER = 'H'; public static final char HEADER = 'H';
public static final char A_TAG = 'M'; public static final char A_TAG = 'M';
public static final char B_TAG = 'X'; public static final char B_TAG = 'X';
public static final char C_TAG = 'U';
void ephSerial() { void ephSerial() {

Loading…
Cancel
Save