Last active
August 29, 2015 13:56
-
-
Save rbarros/9061992 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
// Exemplo 04: Acenda e apague um LED gradualmente, produzindo um | |
// efeito como aquele que vemos em um computador Apple em suspensão | |
const int LED = 9; // pino para o LED | |
int i = 0; // Utilizamos essa variável para contagem | |
void setup() { | |
pinMode(LED, OUTPUT); // Diz ao Arduino que LED é uma saída | |
} | |
void loop() { | |
for (i =0; i < 255; i++) { // faz um loop de 0 a 254 (acende gradualmente) | |
analogWrite(LED, i); // define o brilho do LED | |
delay(10); // Espera 10ms, pois analogWrite é instantâneo e não veriamos nenhuma alteração | |
} | |
for (i = 255; i > 0; i--) { // faz um loop de 255 a 1 (apaga gradualmente) | |
analogWrite(LED, i); // define o brilho do LED | |
delay(10); // aguarda 10ms | |
} | |
} |
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
wget -q -U Mozilla -O "oi.mp3" "http://translate.google.com/translate_tts?tl=pt&q=Oi" |
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
// Arduino Basico | |
// Autor: Michael McRoberts | |
// Listgem 3.3 - Codigo para o projeto 7 Lampada pulsante | |
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 entao obtem o valor do seno | |
sinVal = (sin(x*(3.1416/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