Pages: [1]   Go Down
Author Topic: Arduino Uno with a Pot to control voltage  (Read 2852 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
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
 
}
 
Logged

Spain
Offline Offline
Newbie
*
Karma: 2
Posts: 7
Enjoying life with Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Tutorial/AnalogReadSerial
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12944
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where are you getting the "8V"?

In your post you put...
Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12944
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes Exactly !
Logged

Spain
Offline Offline
Newbie
*
Karma: 2
Posts: 7
Enjoying life with Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need analogWrite.

http://arduino.cc/en/Tutorial/Fade
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12944
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You need analogWrite

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

Quote
yes Exactly !

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Spain
Offline Offline
Newbie
*
Karma: 2
Posts: 7
Enjoying life with Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: