Last active
December 22, 2015 03:09
-
-
Save adell/6408499 to your computer and use it in GitHub Desktop.
Fazendo um led piscar de forma suave
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
// Projeto FilipeFlop - Brilho LED PWM | |
int ledPin = 11; | |
float sinVal; | |
int ledVal; | |
void setup() { | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() { | |
for (int x=0; x<180; x++) { | |
// converte graus para radianos e então obtém o valor do seno | |
sinVal = (sin(x*(3.1412/180))); | |
ledVal = int(sinVal*255); | |
analogWrite(ledPin, ledVal); | |
delay(25); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment