first commit
This commit is contained in:
27
PWM_TEST/PWM_TEST.ino
Normal file
27
PWM_TEST/PWM_TEST.ino
Normal file
@@ -0,0 +1,27 @@
|
||||
/*********
|
||||
Rui Santos
|
||||
Complete project details at https://randomnerdtutorials.com
|
||||
*********/
|
||||
|
||||
const int ledPin = D2;
|
||||
|
||||
void setup() {
|
||||
pinMode(ledPin,OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// increase the LED brightness
|
||||
for(int dutyCycle = 0; dutyCycle < 255; dutyCycle++){
|
||||
// changing the LED brightness with PWM
|
||||
analogWrite(ledPin, dutyCycle);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
// decrease the LED brightness
|
||||
for(int dutyCycle = 255; dutyCycle > 0; dutyCycle--){
|
||||
// changing the LED brightness with PWM
|
||||
analogWrite(ledPin, dutyCycle);
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user