SHARE
TWEET

Untitled

a guest Dec 6th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Initializing Variables
  2. int ledPin = 3;
  3. int potentiometerPin = A0;
  4.  
  5. int potentiometerValue = 0;
  6. int delayTime = 0;
  7. bool ledState = true;
  8.  
  9. void setup()
  10. {
  11. //Sets Pins to Input/Output
  12. pinMode(ledPin, OUTPUT);
  13. pinMode(potentiometerPin, INPUT);
  14. }
  15.  
  16. void loop()
  17. {
  18. //
  19. digitalWrite(ledPin, ledState);
  20.  
  21. //Toggles ledState Between On and Off
  22. ledState = !ledState;
  23.  
  24. //Checks A0 for Potentiometer Value (0 - 1023)
  25. potentiometerValue = analogRead(potentiometerPin);
  26.  
  27. //Scales delayTime Based On Potentiometer Value (0ms to 1250ms)
  28. delayTime = map(potentiometerValue, 0, 1023, 0, 1250);
  29.  
  30. //Delay Before Repeating Loop
  31. delay(delayTime);
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top