# Support on an analog reading project

Ok, i’m a huge noob.
I wrote a script that reads that analog data coming from a potentiometer and depending on how high or low the numbers are, it either turns on or off an LED.
I can get the code to control two LED’s one is connected to the potentiometer and the other is separated and blinks if the analog reading gets too high.
I want to turn the voltage to the potentiometer LOW in order to keep the LED connected it from blowing out. For some reason, it turns off but then it blinks on and off. Can someone help me?

``````int led1 = 13;
int potent = 2;
///////////////////
void setup() {

pinMode (potent, OUTPUT);
pinMode (led1, OUTPUT);
Serial.begin(9600);
}
//////////////////
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);

if(sensorValue < 495)
{
digitalWrite(potent, HIGH);
}
if (sensorValue > 495)
{
digitalWrite(potent, LOW);
}
if (sensorValue > 410)
{
digitalWrite(led1, LOW);
delay(200);
digitalWrite(led1, HIGH);
delay(200);
}
if (sensorValue < 410)
{
digitalWrite(led1, LOW);
}
}
``````

I don't understand what you mean by either having an LED connected to a potentiometer, or by turning the voltage to the potentiometer to low.

The outside wires of the pot should be to 5v and Gnd, the middle one- the wiper- to the analog pin. Is that what you have?

Might be an idea to post a schematic.

An LED won't blow out as long as you have a resistor of the right value in series, so that it loses the difference between the supplied voltage (5V here) and the LED forward voltage (say 2V or so) at the max current (say 20mA). So you need a resistor to lose say 3Vat 0.02A which is 3/0.02 by Ohms Law, or 150. So say 220.... then your LED's safe at 5V.

Here is a photo I made of it using Fritzing.

I have no idea what you're trying to do there.... it's very unusual to have one side of the pot to digital pin. When you take that pin low, both sides of the pot are low since the other side is grounded already. Then regardless of where the wiper is, the analog value will be 0.

If you're trying to dim one of the LEDs, based on the pot's value, then that's exactly what this example does.