2010年8月8日日曜日

Arduino Daisy Chain 2


Program for Arduino Daisy Chain

This program is specifically designed to communicate with Isadora.

You can use this program as a switch in Isadora.



Program for a host Arduino

/*

this program is just send on and off signal to client Arduino every 2 second

*/

int signalPin=3;
void setup(){
pinMode(signalPin, OUTPUT);

digitalWrite(signalPin, LOW);
}
void loop(){
 
digitalWrite(signalPin, HIGH);
delay(2000);
digitalWrite(signalPin, LOW);
delay(2000);
}


Program for a Client

int ReadingPin = 0;
int val;
void setup(){
Serial.begin(9600);

}
void loop(){
val = analogRead(ReadingPin);

/*

with this "if" commend, Arduino does not send any data to Isadora when an analog pin receive nothing.

*/
  if (val>100){
  val=1;//you can change value to anything you want 
Serial.print(1,DEC);
Serial.print (val, DEC);
Serial.println();
delay(50);
}
}






0 件のコメント:

コメントを投稿