Go Down

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

mhkaram

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 :
http://www.youtube.com/watch?v=FKj9jJgj8Pc
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
 
}

Spanman

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

mhkaram

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

mhkaram

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?


Spanman

You need analogWrite.

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

Coding Badly

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.

mhkaram

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

Spanman

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.

johnwasser

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