Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
h>
#include <compat/deprecated.h>
#include <FlexiTimer2.h>
#define SAMPFREQ 256
Servo myServo1;
Servo myServo2;
Servo myServo3;
Servo myServo4;
Servo myServo5;
Servo myServo6;
int pos = 0;
int modo = 0;
int oscMsg[12];
int inByte = 0;
void setup()
{
myServo1.attach(13); // pulso
myServo2.attach(8); //dedo mindinho
myServo3.attach(9); //dedo2
myServo4.attach(10); //dedo3
myServo5.attach(11, 576, 2384); //indicador
myServo6.attach(12); //poegar
}
void loop(){
//contador de ups
if (Serial.available()) {
if (getOscMsg()==1){
// and vaule
case'a':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
case'b':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
}
case'c':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
}
case'd':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
}
case'e':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
}
case'f':
Serial.print("MODO ");
Serial.println(modo);
value = 0;
break;
}
}
}
}
}
delay(1);
ADC_Value = analogRead(CurrentCh);
value99 = value99+1;
if(ADC_Value > 400){
value98 = value98 + 1; //caso tenha o valor alto, adiciona um no contador
}
if(ADC_Value < 250){
Serial.println(ADC_Value);
myServo1.write(90);
myServo2.write(10);
myServo3.write(10);
myServo4.write(10);
myServo5.write(10);
myServo6.write(10);
delay(1);
}
else if (value98 >= 45){ //on
Serial.print("on");
Serial.println(ADC_Value);
Serial.println(value98);
myServo6.write(150);
delay(1);
}
if(modo ==3){
Serial.print("MODO ");
Serial.println(modo);
myServo1.write(90);
myServo2.write(150); // aponta
myServo3.write(150);
myServo4.write(150);
myServo5.write(15);
myServo6.write(20);
delay(1);
}
if(modo ==4){
Serial.print("MODO ");
Serial.println(modo);
myServo1.write(90);
myServo2.write(15); // Spider
myServo3.write(150);
myServo4.write(150);
myServo5.write(15);
myServo6.write(20);
delay(1);
}
if(modo ==5){
Serial.print("MODO ");
Serial.println(modo);
myServo1.write(90);
myServo2.write(150); // Joia
myServo3.write(150);
myServo4.write(150);
myServo5.write(150);
myServo6.write(20);
delay(1);
}
if(modo ==6){
Serial.print("MODO ");
Serial.println(modo);
myServo1.write(90);
myServo2.write(15); // hang
myServo3.write(150);
myServo4.write(150);
myServo5.write(150);
myServo6.write(20);
delay(1);
}
// function to process simple OSC message sent by TouchOSC for iphone / ipad
float getOscMsg(){
inByte=Serial.read();
if (inByte == 47){
inbyteIndex=0;
}
if ((inbyteIndex <= 11) && (inbyteIndex >= 0)){ // is it time to finish or can we start?
oscMsg[inbyteIndex]=inByte;
inbyteIndex++;
}
if (inbyteIndex == 11){
inbyteIndex=-1;
union u_tag {
byte bytes[4];
float buffer;
}
u;
u.bytes[0]=oscMsg[11];
u.bytes[1]=oscMsg[10];
u.bytes[2]=oscMsg[9];
u.bytes[3]=oscMsg[8];
msgVal = u.buffer;
return 1;
}
return 0;
}