loading
Potentiometers have a lot of uses in electronics. They are essentially a variable resistor. Combine this with the fact that an Arduino is capable of reading analog voltages, this can turn a potentiometer into something like a continuous speed control or position control. This basic control is essential understand in making more complex systems. On top of that, I made this at TechShop. Maybe you can try this after taking the electronics course.

http://techshop.ws

Step 1: Materials

Arduino Uno

Usb cable

LED

10k ohm Potentiometer

500ohm resistor

breadboard

wire

Step 2: Circuit

This is a fairly simple circuit. The Arduino can provide power for the potentiometer and a logical high from the digital pins is high enough to run a simple led.

Connect the LED to pin 3 with a current limiting resistor of 500 ohms. Connect the long end of the led to the resistor and the short side to ground. Connect the potentiometer to power and ground and the third leg to analog pin 5. This creates a variable voltage divider. Once the Arduino is connected to a computer, the board will have power.

Step 3: Code

The following is the code for the blinking device.

-----------------------------------------------------------------

#define POT_PIN 5
#define LED_PIN 3

void setup(){
 
  //set this to output
  pinMode(LED_PIN, OUTPUT);
 
}

void loop(){
 
  int val;
 
  val=analogRead(POT_PIN);

  digitalWrite(LED_PIN, HIGH);
 
  delay(val);
 
  digitalWrite(LED_PIN, LOW);
 
  delay(val);
 
}


-----------------------------------------------------------------

So what's going on here? First the arduino needs to set the led pin to an output. Then the program loops through and does a few things. First it sets aside a little memory for the value that will be read from the potentiometer. Then it reads the voltage value from analog pin 5. This is a value from 0 to 1023 which translates to 0-5v. Once that value is determined, it sets that value as the delay for the duration of the on and off cycles of the led.

And that's it, a potentiometer used to control a blinking light.
<p>Is it all right with you if I add this instructable to my beginning Arduino collection?</p><p><a href="https://www.instructables.com/id/Beginning-Arduino/" rel="nofollow">https://www.instructables.com/id/Beginning-Arduino/</a></p>
another cool thing you could do is use the pot to control the brightness of the LED, replace your current loop with this: <br /> <br />void loop(){ <br />int val; <br />val= analogRead(POT_PIN); <br />analogWrite(LED_PIN,(val/4); <br />delay(100); <br />}
sorry put an extra ) at the end of the analogWrite: <br /> <br />void loop(){ <br />int val; <br />val= analogRead(POT_PIN); <br />analogWrite(LED_PIN,(val/4)); <br />delay(100); <br />}
Sure, turn that blinking light into a dimmer switch! But this is just a really really slow version of analogWrite. Turns out analogWrite doesn't change the voltage, but instead just blinks really fast. Also known as PWM'ing. Turn down the delay, the blinks start getting so fast that it just looks dim. It's a good intro to PWM though! <br> <br>But if I were to make a dimmer, I would do this <br> <br>void loop(){ <br>int val; <br>val=analogRead(POT_PIN); <br>val=map(val, 0, 1023, 0, 255); <br>analogWrite(LED_PIN, val); <br>} <br> <br>That way the changes are accurately mapped to the possible values analogWrite accepts and changes are instant (no delay needed). <br> <br>-Joe <br>

About This Instructable

18,834views

13favorites

License:

More by madebyjoe:Arduino powered GLCD (Graphic LCD) - I made it at TechShop Arduino Bluetooth Serial Connections! - I made it at TechShop Android Tablet PS3 / Xbox360 Controller Mount - I made it at TechShop 
Add instructable to: