Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumOther questionsOther Wiring questions › analog in does not work right

Page Index Toggle Pages: 1
analog in does not work right (Read 3800 times)
04/21/10 at 14:29:47

Armyn   Offline
YaBB Newbies
Philippines

Posts: 2
*
 
I've tested my board and the examples for digital ports worked just fine, however, when i tested the analog input and output ports, it doesn't seem to work right, the values being displayed on the serial monitor doesn't seem to match with the voltage inputted. Does anyone know what the problem may be? Thanks!!!
 
IP Logged
 
Reply #1 - 04/21/10 at 20:07:55

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Please check this, http://wiring.org.co/reference/analogRead_.html analogRead read values between 0 and 1024 where 0 is about 0volts and 1023 about 5volts.
analogWrite is PWM (pulse width modulation) This is turning a digital output ON and OFF very
quickly to simulate values between 0 and 5 volts. If the output is 0 volts for 90% of the
time and 5 volts for 10%, this is called a 10% duty cycle. It emulates an analog voltage of
0.5 volts. An 80% duty cycle emulates a 4-volt signal:
Does this help?
 
IP Logged
 
Reply #2 - 04/22/10 at 03:03:02

Armyn   Offline
YaBB Newbies
Philippines

Posts: 2
*
 
Yes, I understand how it works, however, as I've tried the potentiometer and photoresistor examples... I think the values being displayed does not match the real voltage inputted into the analog input port, because even though I am not turning the knob on the potentiometer, the values fluctuates from 1023, 900+... down to 500+, whereas it should only display a particular value. Thanks!
 
IP Logged
 
Reply #3 - 04/22/10 at 06:33:12

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Value fluctuation is normal by +-2 or 2 but not that big, there must be something wrong with your potentiometer, or your connections, a loose cable etc, also with disconnected pins and then reading them. Please provide information on your system, board (where did you get it), wiring version etc.
What type of potentiometer etc.
 
IP Logged
 
Page Index Toggle Pages: 1