Advertisement
ccarman602

Lesson-3-Rotary

Nov 25th, 2021 (edited)
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Rotary controls LED
  2. int rotaryPin = A0;    // select the input pin for the rotary
  3. int ledPin = 4;      // select the pin for the LED
  4. int rotaryValue = 0;  // variable to store the value coming from the rotary
  5.  
  6. void setup() {
  7.   // declare the ledPin as an OUTPUT:
  8.   pinMode(ledPin, OUTPUT);
  9.   pinMode(rotaryPin, INPUT);
  10. }
  11.  
  12. void loop() {
  13.   // read the value from the sensor:
  14.   rotaryValue = analogRead(rotaryPin);
  15.   // turn the ledPin on
  16.   digitalWrite(ledPin, HIGH);
  17.   // stop the program for <sensorValue> milliseconds:
  18.   delay(rotaryValue);
  19.   // turn the ledPin off:
  20.   digitalWrite(ledPin, LOW);
  21.   // stop the program for for <sensorValue> milliseconds:
  22.   delay(rotaryValue);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement