Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pinled = 11;
- int potpin = 0; // analog pin used to connect the potentiometer
- int val; // variable to read the value from the analog pin
- void setup()
- {
- pinMode(pinled, OUTPUT);
- }
- void loop()
- {
- val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
- val = map(val, 0, 1023, 0, 255); // scale it to use it with the servo (value between 0 and 255)
- analogWrite (pinled, val); //
- }
Advertisement
Add Comment
Please, Sign In to add comment