Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. int sensorPin = A0; // select the input pin for the potentiometer
  2. int ledPin = 7; // select the pin for the LED
  3. int sensorValue = 0; // variable to store the value coming from the sensor
  4.  
  5. void setup() {
  6. // declare the ledPin as an OUTPUT:
  7. pinMode(ledPin, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11. // read the value from the sensor:
  12. sensorValue = analogRead(sensorPin);
  13. // turn the ledPin on
  14.  
  15. if ( sensorValue == 1023)
  16. {
  17. digitalWrite(ledPin, HIGH);
  18. }
  19. else if (sensorValue == 0){
  20.  
  21. // turn the ledPin off:
  22. digitalWrite(ledPin, LOW);
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement