Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sensorPin = A0; // select the input pin for the potentiometer
- int ledPin = 7; // select the pin for the LED
- int sensorValue = 0; // variable to store the value coming from the sensor
- void setup() {
- // declare the ledPin as an OUTPUT:
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- // read the value from the sensor:
- sensorValue = analogRead(sensorPin);
- // turn the ledPin on
- if ( sensorValue == 1023)
- {
- digitalWrite(ledPin, HIGH);
- }
- else if (sensorValue == 0){
- // turn the ledPin off:
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement