Last active
December 19, 2015 18:39
-
-
Save alepez/6000398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imposta il numero del pin associato al led | |
int ledPin = 9; | |
// tiene in memoria il valore | |
int valore = 0; | |
void setup() { | |
// imposta il pin in modalita' OUTPUT | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() { | |
// imposta il pin al valore definito | |
analogWrite(ledPin, valore); | |
// aumenta di 1 il valore | |
valore++; | |
// aspetta 50 millisecondi | |
delay(50); | |
// se valore ha raggiunto il massimo lo rimette a 0 | |
if (valore == 256) { | |
valore = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esempio semplice semplice, per "dimmerare" un led usando il PWM.