Go Down

### Topic: Can the voltage on a mega or uno be adjusted at 5v or 3.3v pin? (Read 332 times)previous topic - next topic

#### keyboardcowboy

#15
##### Aug 21, 2019, 02:49 pmLast Edit: Aug 21, 2019, 02:51 pm by keyboardcowboy
Ok going to use a 5k pot, attach one end to ground and the other to 5v with the middle going to aref on a uno board I dont have being used currently. Should I connect the end of the pot to A0-A5 instead or keep it at the 5v pin so when analogreference external is enabled the pins at 0-5 drop to the adjusted voltage correct? while the 5v pin would stay constant?

#### septillion

#16
##### Aug 21, 2019, 03:12 pm
What? What do you think to gain by feeding Vref some voltage and messing with analogRead()?

Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake

#### keyboardcowboy

#17
##### Aug 21, 2019, 04:12 pmLast Edit: Aug 21, 2019, 04:22 pm by keyboardcowboy
Ok 5v and ground go from uno to breadboard then from breadboard to each side of the pot. I had the AREF connected to the middle but no luck, tried A2 now on A3. If I measure with my meter at the right and center of the pot I cant adjust voltage from 0-5v but I dont know how to read the voltage read at the middle of the pot at A3.

Code: [Select]
`int a = A1;int c = A2;float b = 0;void setup(){  Serial.begin(9600);}void loop(){  analogReference(EXTERNAL);  pinMode(c,INPUT);  digitalWrite(c,HIGH);  pinMode(a, INPUT);  a = analogRead(c);  Serial.println(a);  b = map (c,0,1024,0,5);  Serial.print("V= ");  Serial.println(b);  delay(1000);}`

I have ground on the side and 5V on side with the AREF in the middle of the pot and can go from 0-4.5V which is plenty, but what would be the best code to read this in the serial monitor?

#### septillion

#18
##### Aug 21, 2019, 04:14 pm
But how is any of that helping is controlling a heater?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake

#### keyboardcowboy

#19
##### Aug 21, 2019, 04:33 pmLast Edit: Aug 21, 2019, 04:41 pm by keyboardcowboy
Code: [Select]
`[quote author=septillion link=msg=4282512 date=1566396868]But how is any of that helping is controlling a heater? ???[/quote]It always power to a atomizer fine but I need to figure out how to read the voltage from A0 right now which is tied to the same input as AREF through a breadboard[code]void setup(){  Serial.begin(9600);  analogReference(EXTERNAL);}void loop(){  int sensorValue = analogRead(A0);  float voltage= sensorValue * (5.0 / 1023.0);  float b;  Serial.println(voltage);  b = map (b,0,1024,0,5);  Serial.print("V= ");  Serial.println(b);  delay(1000);}`

Says A0 is putting out 5V which is untrue when its reading 3V after adjusting the pot by reading my meter

#### septillion

#20
##### Aug 21, 2019, 04:35 pm
It powers the heater how?

Why did you tie the A0 to Vref? Just leave Vref, if you want to read voltage just use a Ax pin.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake

#### keyboardcowboy

#21
##### Aug 21, 2019, 04:50 pmLast Edit: Aug 21, 2019, 04:51 pm by keyboardcowboy
Code: [Select]
`void setup(){  Serial.begin(9600);  analogReference(EXTERNAL);}void loop(){  int sensorValue = analogRead(A0);  float voltage= sensorValue * (5.0 / 1023.0);  Serial.println(voltage);}`

Voltage is 3.3V with Voltmeter at pot measuring from side pin n center that goes to A0.
Going to try A1-5 since A0 only reads 5v on serial monitor

#### Leveller

#22
##### Aug 21, 2019, 04:57 pm
So wiring the heater between the wiper on the pot and A0? surely you can only read it from A0 then? Can you post a picture or drawing of what you've done?
Two possibilities exist: either we are alone in the Universe or we are not. Both are equally terrifying.

#### johnwasser

#23
##### Aug 21, 2019, 04:59 pm
I need to figure out how to read the voltage from A0 right now which is tied to the same input as AREF through a breadboard
When A0 is tied to Aref it will ALWAYS read 1023.  When you change Aref, the 1023 no longer means "over 1023/1024ths of the Vcc (5V) voltage".  It means "over 1023/1024ths of the Aref voltage".

Are you trying to read a voltage?!?  Start by using the default Aref (5V).
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

#### keyboardcowboy

#24
##### Aug 21, 2019, 05:16 pm
Heres the wiring,  blue to ground black goes to green wire at 5v n orange to breadboard to A0 now

#### keyboardcowboy

#25
##### Aug 21, 2019, 05:25 pmLast Edit: Aug 21, 2019, 05:31 pm by keyboardcowboy
Yes thats all im trying to do since I can control voltage with the pot by having ground and 5v at each end of the pot but am lost on reading voltage out of the middle pin on the pot that I have going to a breadboard then to A0 right now. those are my only connections
Code: [Select]
`void setup(){  Serial.begin(9600);}void loop(){  float a = A0;  analogReference(EXTERNAL);  pinMode(a,INPUT);  digitalWrite(a,HIGH);  int sensorValue = analogRead(0);  float voltage= sensorValue * (5.0 / 1023.0);  Serial.println(voltage);  delay(500);}`

A0 measures at 5V but the middle pin of the pot is adjustable, still trying to figure out if possible to read pin, hooked center pot pin back to aref with no diff

#### keyboardcowboy

#26
##### Aug 21, 2019, 05:36 pm
Code: [Select]
`void setup(){  Serial.begin(9600);}void loop(){  float a = A0;  analogReference(EXTERNAL);  int sensorValue = analogRead(0);  float voltage= sensorValue * (5.0 / 1023.0);  Serial.println(voltage);  delay(500);}`

Ok digitalwrite and pinmode were removed after which now it reads from 0-5 at A0, only the center pin on the pot stays constant

#### keyboardcowboy

#27
##### Aug 21, 2019, 06:37 pm
the amps arnt high enough for what id need, would need a external power supply n was hoping might power a vape atomizer.

#### septillion

#28
##### Aug 21, 2019, 06:39 pmLast Edit: Aug 21, 2019, 06:39 pm by septillion
No shit sherlock Wasn't that what we where saying?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake