//boolean_and.pde
#define A 2
#define B 3
#define Y0 4
void setup() {
Serial.begin(9600);
Serial.println("Chang Yung Fu <<<2012/9/20>>>");
Serial.println("Combining Logic using Arduino");
Serial.println("Boolean algebra AND Gate example");
Serial.println("Y0=B*A");
Serial.println("B,A=>Y0");
Serial.println("------------");
Serial.println("0,0 =>0");
Serial.println("0,1 =>0");
Serial.println("1,0 =>0");
Serial.println("1,1 =>1");
pinMode(A,INPUT);
pinMode(B,INPUT);
pinMode(Y0,OUTPUT);
}
void loop() {
boolean OutY0;
OutY0=digitalRead(B) && digitalRead(A) ;
digitalWrite(Y0,OutY0);
}
沒有留言:
張貼留言