Go Down

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

mhkaram

Feb 27, 2011, 09:11 am
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 = map(val1,0,1023,0,8);
digitalWrite(valve, val1);  // turn the ledPin on
delay(0);                  // stop the program for some time

}

#1

mhkaram

#2
Feb 27, 2011, 09:46 am
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

#3
Feb 27, 2011, 09:51 am
Where are you getting the "8V"?

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

#4
Feb 27, 2011, 09:53 am
i have connected the Arduino ( from Vin and ground pins ) into a DC power supply.

#5
Feb 27, 2011, 09:56 am
Are you wanting to vary the Arduino OUTPUT voltage from 0 volts to 8 volts?

#6
yes Exactly !

Spanman

#7
Feb 27, 2011, 10:04 am
You need analogWrite.

#8
Feb 27, 2011, 10:08 am
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

#9
Feb 27, 2011, 10:10 am
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

#10
Feb 27, 2011, 10:33 am
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

#11
Feb 27, 2011, 08:43 pm
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.