Last active
November 11, 2017 03:37
-
-
Save LuizFelipeLemon/7d2cea31975eca54c19b276804aeb8a6 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
#define ldr A0 //Nomeia a porta A0 como pot | |
#define led 3 //Nomeia a porta 3 como led | |
void setup(){ | |
Serial.begin(9600); //Inicia a Serial | |
pinMode(ldr,INPUT); //Define o pino A5 como entrada | |
pinMode(3,OUTPUT); //Define o pino 3 como saída | |
} | |
void loop(){ | |
int ldrValor = analogRead(ldr); // Armazenda valor analógico | |
int pwm = map(ldrValor,0,1023,0,255); // Transforma os valores de 0 a 1023 para 0 a 255 | |
Serial.println(pwm); | |
analogWrite(3,pwm); //Escreve na porta do led | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment