I want to use a potentiometer to control the speed of some blinking LEDs for a project with Arduino Uno, but I've found that if I turn the potentiometer completely one way, the LEDs and the LED on the Arduino board go out. I've got the potentiometer set up with one leg to ground, one to 5V and the middle to Analog 0. Any idea how to get around this? I'm slightly worried I'm going to damage something.
It's connected to pin A0 at the minute. I haven't actually written any code using the potentiometer yet, I just found this issue while setting up the components.
That's basically how I've got the potentiometer set up, but I'm not sure what the green arrow between IOREF and 5V in that diagram means. Sorry, I'm pretty new to this stuff, this project's the first thing I've used Arduino for.
I should probably also mention that everything runs fine when the potentiometer isn't fully turned.
Unfortunately this project is for coursework, so I'm a tad wary of uploading my whole code online before the hand in deadline in case I run into plagiarism themed issues. I was hoping to get the work done today, but I guess I'll probably be better waiting until I can ask my lecturer about this problem.
Thanks for all your help anyway. I'll post back if I find out what was wrong.
I just spotted my mistake. I accidentally had one of the legs of the potentiometer in the same rail as my push button. I feel like an idiot now haha. Sorry for wasting your time guys, but thanks again for all the help
Sorry for wasting your time guys, but thanks again for all the help
you learned something so it was no waste of time.
Here is something that might be of interest:
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}