Go Down

Topic: Arduino Uno with a Pot to control voltage (Read 3570 times) previous topic - next topic


I am new to the Arduino so bear with me. I am trying to vary voltage to a a device. I need the voltage to go from 0-8 volts.
so my Question is: how can I hook up the POT,code the Arduino, and hook up the device
I have got a good idea from watching this Vid :
However, unlike the Servo my device does not come with Arduino code to make my life easier.

what I have so far is this:
I have connected the POT to the 5V, Ground, and control pin # 2 ( analog ).
My output device is simply connected to Ground and pin #13 ( digital ).

my code is not doing what it needs to ( i.e vary the voltage ) all its doing is going from 0 V straight to 8 V.

can anyone suggest a way to make the voltage vary from 0-8V using the POT .. Thank you

int potPin1 = 2;   
int valve = 13;   
int val1 = 0;       

void setup() {
  pinMode(valve, OUTPUT); 

void loop() {
  val1 = analogRead(potPin1);   
  val1 = map(val1,0,1023,0,8);
  digitalWrite(valve, val1);  // turn the ledPin on
  delay(0);                  // stop the program for some time




thats pretty much how i  have my POT connected .. but it does not show I can vary the voltage from 0-8V using the POT

Coding Badly

Where are you getting the "8V"?

In your post you put...
I have connected the POT to the 5V, Ground, and control pin # 2 ( analog ).

...which will vary the voltage from 0 volts to 5 volts.


i have connected the Arduino ( from Vin and ground pins ) into a DC power supply.

Coding Badly

Are you wanting to vary the Arduino OUTPUT voltage from 0 volts to 8 volts?


You need analogWrite.


Coding Badly

You need analogWrite

Nope.  The output is either 0 volts or 5 volts.  There is nothing in between.

yes Exactly !

In which case, you are going to have to provide a description of the hardware.


10 K pot, connected in the manner described above, a Valve that operates from 2.5-8 V connected in the manner described above


As the Arduino pins supply 5 volts and your valve requires 8 volts I would suggest using the Arduino to control a transistor supplying the 8 volts to the valve.


The Arduino doesn't have a built-in D/A (Digital to Analog) converter.  it simulates an Analog output with Pulse Width Modulation: turning on a 5V signal only part of the time.

D/A is fairly easily done with an R-2R resistor ladder:  http://en.wikipedia.org/wiki/Resistor_ladder

Because you are working with voltages higher than the 5V output of the Arduino and possibly currents higher than Arduino can provide you will need some transistors to switch the 8V to the resistor ladder.  There are tutorials around for using transistors to drive higher voltage and current loads like DC motors.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131