void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(2,OUTPUT); pinMode(7,OUTPUT); analogWrite(9,255); } void loop() { // put your main code here, to run repeatedly: //Serial.println(digitalRead(4)); if(digitalRead(4)==0){ digitalWrite(2,1); digitalWrite(9,255); digitalWrite(7,HIGH); delay(1); digitalWrite(7,LOW); delay(1); }else{ digitalWrite(2,0); digitalWrite(9,0); digitalWrite(7,0); } }
######################
标签:code,run,Arduino,digitalWrite,学习,蜂鸣器,your From: https://www.cnblogs.com/herd/p/17473426.html