Arduino | Theremino | Theremino | |
---|---|---|---|
invia al Pin | DigitalWrite(1,HIGH) AnalogWrite(1,125) | WriteSlot(1,1000); WriteSlot(1,500); | WriteSlot(1,1000) WriteSlot(1,500) |
legge dal Pin | DigitalRead(1) AnalogRead(1) | ReadSlot(1); | ReadSlot(1) |
setup | void setup(){
pinMode(1,INPUT); } | il setup viene eseguito manualmente in HAL | |
ciclo principale | void loop(){ ... } |
static void Main_Thread() { ... } |
Sub PausableExecution() ... End Sub |
pausa | delay(200); | PausaMS(200); | PausaMS(200) |
espressione condizionale | if(x>125) { ... } | if x>125 ... End if | |
ripetizione | for(int i=1;i<=3;i++){ ... } | for i1 as int32=1 to 10 ... Next | |
variabili | int x=100; | dim x as Integer=100 | |
float x=100.23; | dim x as single=100.23 |
void setup(){ pinMode(13,OUTPUT); } void loop(){ digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(500); }
static void EseguiConPause(){ WriteSlot(1,1000); PausaMS(500); WriteSlot(1,0); PausaMS(500); }
Sub PausableExecution() For i1 As Int32 = 1 to 10 WriteSlot(1,1000) PausaMS(500) WriteSlot(1,0) PausaMS(500) Next End Sub
void setup(){ pinMode(a1,INPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); } void loop(){ X=analogRead(a1); if(X>=0 && X<=62){ digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); } if(X>62 && X<=125){ digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,LOW); digitalWrite(5,LOW); } if(X>125 && X<=187){ digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,LOW); } if(X>187 && X<=255){ digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); } }
static void EseguiConPause(){ float X=ReadSlot(1); if(X>=0 & X< 250){ WriteSlot(2,1000); WriteSlot(3,0); WriteSlot(4,0); WriteSlot(5,0); } if(X>=250 & X< 500){ WriteSlot(2,1000); WriteSlot(3,1000); WriteSlot(4,0); WriteSlot(5,0); } if(X>=500 & X< 750){ WriteSlot(2,1000); WriteSlot(3,1000); WriteSlot(4,1000); WriteSlot(5,0); } if(X>=750 & X<=1000){ WriteSlot(2,1000); WriteSlot(3,1000); WriteSlot(4,1000); WriteSlot(5,1000); } }
Sub PausableExecution() Dim X as single=readSlot(1) If X>=0 and X<=250 then WriteSlot(2,1000) WriteSlot(3,0) WriteSlot(4,0) WriteSlot(5,0) End if If X>250 and X<=500 then WriteSlot(2,1000) WriteSlot(3,1000) WriteSlot(4,0) WriteSlot(5,0) End if If X>0 and X<=750 then WriteSlot(2,1000) WriteSlot(3,1000) WriteSlot(4,1000) WriteSlot(5,0) End if If X>750 and X<=1000 then WriteSlot(2,1000) WriteSlot(3,1000) WriteSlot(4,1000) WriteSlot(5,1000) End if End Sub