Papermind

Untitled

Jan 16th, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. int pinled = 11;
  2. int potpin = 0;  // analog pin used to connect the potentiometer
  3. int val;    // variable to read the value from the analog pin
  4.  
  5. void setup()
  6. {
  7. pinMode(pinled, OUTPUT);
  8. }
  9.  
  10. void loop()
  11. {
  12.   val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  13.   val = map(val, 0, 1023, 0, 255);     // scale it to use it with the servo (value between 0 and 255)
  14.   analogWrite (pinled, val); //
  15. }
Advertisement
Add Comment
Please, Sign In to add comment