|
Post by 邱老师 on Jan 1, 2021 7:08:36 GMT
arduino输出PWM信号,收到信号的LED产生了亮度渐变的效果 开发板的接线:把D9口连接到LED接口。
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
|
|
|
Post by 邱老师 on Jan 1, 2021 10:10:29 GMT
|
|
徐晨涛
New Member
Posts: 29
|
Post by 徐晨涛 on Jan 10, 2021 6:35:20 GMT
完成
|
|
叶子郑茂
New Member
Posts: 13
|
Post by 叶子郑茂 on Jan 10, 2021 6:42:20 GMT
|
|
叶子郑茂
New Member
Posts: 13
|
Post by 叶子郑茂 on Jan 10, 2021 6:48:00 GMT
完成
|
|
王鑫
New Member
Posts: 20
|
Post by 王鑫 on Jan 11, 2021 10:00:02 GMT
完成
|
|
胡志松
New Member
Posts: 26
|
Post by 胡志松 on Jan 11, 2021 10:02:24 GMT
完成
|
|
毛显棋
Junior Member
王骞是傻逼SBSBSBSBSBBSBSB
Posts: 80
|
Post by 毛显棋 on Jan 17, 2021 6:22:08 GMT
OK
|
|
滕祠
Junior Member
Posts: 76
|
Post by 滕祠 on Jan 17, 2021 6:26:18 GMT
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
|
|
徐瑶锦
New Member
Posts: 20
|
Post by 徐瑶锦 on Jan 17, 2021 6:54:06 GMT
完成
|
|
林明轩
Junior Member
Posts: 87
|
Post by 林明轩 on Jan 17, 2021 6:54:33 GMT
完成
|
|