1、选择开发板
2、选择端口
3、代码:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN (13) as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
4、点击上传代码,上传后led开始闪烁。
点亮外接LED灯
int LED = 7;
void setup() {
// 定义7为输出引脚
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH); // 点亮LED
delay(1000); // 持续1秒
digitalWrite(LED, LOW); // 熄灭LED
delay(1000); // 持续1秒
}