1.单词
word |
meaning |
AC |
交流电(alternative current) |
DC |
直流电(direct current) |
int infrared = A0;
int Yellow = 4;
int Red = 6;
int buzzer = 5;
void setup(){
pinMode(infrared,INPUT);
pinMode(Yellow,OUTPUT);
pinMode(Red,OUTPUT);
pinMode(buzzer,OUTPUT);
Serial.begin(9600);
}
void loop(){
int val = analogRead(infrared);
Serial.println(val);
if (val>=30 && val<=400){
digitalWrite(Yellow,HIGH);
digitalWrite(Red,LOW);
}else if(val>=400){
digitalWrite(Red,HIGH);
digitalWrite(Yellow,LOW);
}else{
digitalWrite(Yellow,LOW);
};
}