Society of Robots - Robot Forum

Software => Software => Topic started by: spectrem12 on February 24, 2011, 08:24:31 PM

Title: Arduino Uno Serial read
Post by: spectrem12 on February 24, 2011, 08:24:31 PM
Alright guys. So I keep trying to find this, but I am about to give up. Using the Arduino Uno currently. I have setup the simple photoresistor.

I have set up the serial read so I can see what type of data is coming through. That way I know values to use for line following, IR sensors, etc.

As I play with the photo resistor bringing my hand closer and closer. The numbers go from 0(using flashlight) to about 800 - 900(complete darkness)

What is this value it is giving me?? Just some standard used by Arduino? Is it a round about voltage seen by the A0 port?
Does anyone have an idea?

Same thing when reading the IR range finder. When you read the values, what do the represent?

Thanks for the help
Title: Re: Arduino Uno Serial read
Post by: joe61 on February 24, 2011, 09:12:13 PM
Alright guys. So I keep trying to find this, but I am about to give up. Using the Arduino Uno currently. I have setup the simple photoresistor.

I have set up the serial read so I can see what type of data is coming through. That way I know values to use for line following, IR sensors, etc.

As I play with the photo resistor bringing my hand closer and closer. The numbers go from 0(using flashlight) to about 800 - 900(complete darkness)

What is this value it is giving me?? Just some standard used by Arduino? Is it a round about voltage seen by the A0 port?
Does anyone have an idea?

A photocell changes resistance depending on how much light it senses. If you hook it up in a voltage divider you can read this change as voltage levels. The precise meaning of any given level can be found in the graphs of the data sheet for the photocell.

An IR rangefinder emits a change in voltage on its signal pin depending on how close it is to something. Again, the graphs in the data sheet for the rangefinder are the key, although you could just empirically determine the values at whatever ranges you're interested in.

There's a tutorial on photocells at http://www.societyofrobots.com/schematics_photoresistor.shtml, (http://www.societyofrobots.com/schematics_photoresistor.shtml,) and another one worth reading at http://www.ladyada.net/learn/sensors/cds.html (http://www.ladyada.net/learn/sensors/cds.html)

Joe
Title: Re: Arduino Uno Serial read
Post by: rbtying on February 25, 2011, 12:24:00 AM
The value represents the voltage measured at the ADC pin.  Since floating-point operations don't work well on microcontrollers, it is instead scaled to a 10-bit representation.  To convert back to voltage, do this:

Code: [Select]
  float voltage = value * 0.0048828125; // 0.0048828125 = 5.0 / 1024