suthiporn / iot

0 stars 0 forks source link

#Lab3 #10

Open suthiporn opened 7 years ago

suthiporn commented 7 years ago

#Lab3.txt 3

suthiporn commented 7 years ago

อธิบายหลักการทำงาน ต่อ LED 1 หลอด จ่ายไฟที่ port9 เป็นการหรี่ไฟ ไฟจะค่อยๆสว่างขึ้น โดยมีการกำหนดโวลล์เป็น 0 , 10 , 50 , 100 , 150 , 200 , 255

Source code int ledPin = 9; // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(ledPin, OUTPUT); } // the loop function runs over and over again forever void loop() { analogWrite(ledPin, 0); delay(1000); // wait for a second analogWrite(ledPin, 10); delay(1000); analogWrite(ledPin, 50); delay(1000); analogWrite(ledPin, 100); delay(1000); analogWrite(ledPin, 150); delay(1000); analogWrite(ledPin, 200); delay(1000); analogWrite(ledPin, 255); delay(1000); }