Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. int odczytanaWartosc = 0; //Variable to store ADC read
  2.  
  3. int prog = 0; //Light switching threshold - set by the potentiometer
  4.  
  5.  
  6. void setup() {
  7. pinMode(8, OUTPUT); //Configuration of outputs for the LED
  8. }
  9.  
  10. void loop() {
  11. odczytanaWartosc = analogRead(A5);//Reading values ​​from the ADC
  12.  
  13. prog = analogRead(A4);//Reading values ​​from the ADC
  14.  
  15. if (odczytanaWartosc < prog) { //Is it darker than the set threshold?
  16. digitalWrite(8, HIGH);//Turn on the diode
  17.  
  18. } else {
  19. digitalWrite(8, LOW);/Turn off the diode
  20.  
  21. }
  22.  
  23. delay(50);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement