Advertisement
RealHero

Arduino 1.4

Jun 5th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #define LED_PIN 11
  2. #define LDR_PIN A0
  3. #define POT_PIN A1
  4. void setup() {
  5. Serial.begin(9600);
  6. pinMode(LED_PIN, OUTPUT);
  7. pinMode(10, OUTPUT);
  8. }
  9. void loop() {
  10. int lightness = analogRead(LDR_PIN); //считываем уровень освещенности
  11. if(lightness<951)
  12. {
  13. analogWrite(LED_PIN,255);
  14. }
  15. else
  16. {
  17. analogWrite(11,0);
  18. }
  19.  
  20. if(lightness<475)
  21. {
  22. analogWrite(10, 255);
  23. }
  24. else
  25. {
  26. analogWrite(10,0);
  27. }
  28. Serial.println(lightness);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement