MWC红色Arduino板(之后的简称Arduino板)上有四个LED灯,分别为LED1~LED4。经过测试,发现其对应的引脚地址为:13,30,31,32.
需要注意:LED1为高电平灯亮,LED2~LED4为低电平灯亮。
pinMode 设置引脚的输入,输出模式;
digitalWrite向指定的数字引脚写入值;
delay延迟,参数的单位为毫秒。
int LED1 = 13; // HIGH level signal trigger int LED2 = 30; // LOW level signal trigger int LED3 = 31; // LOW level signal trigger int LED4 = 32; // LOW level signal trigger void setup() { // put your setup code here, to run once: pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED1, HIGH); digitalWrite(LED2, LOW); digitalWrite(LED3, LOW); digitalWrite(LED4, LOW); delay(500); digitalWrite(LED1, LOW); digitalWrite(LED2, HIGH); digitalWrite(LED3, HIGH); digitalWrite(LED4, HIGH); delay(500); }