💽影片名稱:Arduino 08 - LED脈波PMW🎬集數: 08集
🌐(前往YouTube觀看)-[ https://youtu.be/wVznn9goj7Q?feature=shared ]
🌐(YouTube播放清單)-[ https://www.youtube.com/playlist?list=PLOrdAySpFIQrg6lLPL5h_AQl4oRo_0ix4 ]
🌐程式創造++ 頻道:[ https://www.youtube.com/@CCplus2561 ]
電路接法
![[Arduino教學] 08 - LED脈波PMW [Arduino教學] 08 - LED脈波PMW](https://pimg.1px.tw/ccplus2561/1752456325-344457590-g.png)
實作一: LED亮度100% (MAX255%)
|
void setup() {
// put your setup code here, to run once:
pinMode(11,OUTPUT); //數位D11讓他輸出模式
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(11,100); //亮度100% (MAX 255)
}
|
實作二: LED亮度30%
|
void setup() {
// put your setup code here, to run once:
pinMode(11,OUTPUT); //數位D11讓他輸出模式
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(11,30); //亮度30% (MAX 255)
}
|
練習題: LED亮度0~255%
|
void setup() {
// put your setup code here, to run once:
pinMode(11,OUTPUT); //數位D11讓他輸出模式
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(11,0); //亮度0% (MAX 255)
delay(300);
analogWrite(11,50); //亮度50% (MAX 255)
delay(300);
analogWrite(11,100); //亮度100% (MAX 255)
delay(300);
analogWrite(11,150); //亮度150% (MAX 255)
delay(300);
analogWrite(11,200); //亮度200% (MAX 255)
delay(300);
analogWrite(11,250); //亮度250% (MAX 255)
delay(300);
analogWrite(11,255); //亮度255% (MAX 255)
delay(300);
}
|
請先 登入 以發表留言。