【Follow me第二季第4期】任务一Blink、串口打印
[复制链接]
本帖最后由 eew_uscYT9 于 2024-12-6 23:40 编辑
点灯启动
RGB连接方式
有原理图可以看出,低电平点亮
代码如下
#include "WiFiNINA.h"
#define led1 LEDB
#define led2 LEDG
#define led3 LEDR
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop() {
Serial.println("Hello DigiKey & EEWorld!");
// Red
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
delay(500);
// Green
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
delay(500);
// Blue
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
delay(500);
}
顺带打印了"Hello DigiKey & EEWorld!"
|