Arduino Basics- Using potentiometers - I made it at TechShop
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 Basics- Using potentiometers - I made it at TechShop
Arduino Uno

Usb cable

LED

10k ohm Potentiometer

500ohm resistor

breadboard

wire

Step 2: Circuit

Arduino Basics- Using potentiometers - I made it at TechShop
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.
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel