krshr

ArduinoLEDauto

Dec 13th, 2018
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. int value = analogRead(LDR);
  2. Serial.println(value);
  3. c1= value;
  4. c2= 500-c1; // resta c2 de 1000 ans guarda el resultado en c1
  5. if (value < 500)
  6. {
  7. digitalWrite(pwmPin, HIGH);
  8. delayMicroseconds(c2);
  9. digitalWrite(pwmPin, LOW);
  10. delayMicroseconds(c1);
  11. }
  12. if (value > 500)
  13. {
  14. digitalWrite(2,LOW);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment