Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(12, 11, 8, 7, 6, 5);
- int ldr = 5;
- int valor;
- int led=9;
- void setup() {
- pinMode(ldr, INPUT);
- lcd.begin(16,2);
- Serial.begin(9600);
- }
- void loop() {
- lcd.setCursor(0, 0);
- valor=analogRead(ldr);
- if (valor>200){
- lcd.write("Hay luz, led off");
- analogWrite(led, 0);
- }
- if (valor<=200 && valor>=60){
- lcd.write("Sombra, led 50%");
- analogWrite(led, 123);
- }
- if (valor<60) {
- lcd.write("No luz, led 100%");
- analogWrite(led, 255);
- }
- delay(20);
- lcd.clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment