友情提示:380元/半年,儿童学编程,就上码丁实验室。
arduino
你将学到什么
你将学到如何利用中断来切换LED状态
电路图
电路图
arduino代码
#define LED 12
void setup() {
// put your setup code here, to run once:
pinMode(LED,OUTPUT);
attachInterrupt(1,myFun,RISING);
}
void loop() {
// put your main code here, to run repeatedly:
}
void myFun()
{
digitalWrite(LED,!digitalRead(LED));
}
欢迎转发评论!