155
155
Photo Cell Program
●
The program to the right will get an ADC
value from analog port 0.
●
Create a new program and enter the code.
●
To measure the voltage, the function
analogRead(port)
is used.
●
Six ports are available on the processor
board.
●
0,1,2,3,6,7
●
Refer to page 5 for the location.
●
Once the ADC value is read, it can be
converted to a voltage value. The code to
the right shows the equation which can be
used for all the analog ports.
●
The
Serial.println()
function that
displays the volts, includes a numeric
argument which specifies the number of
decimal places.
●
Save the program to a new file.
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a;
float volts;
a = analogRead(0);
Serial.println(a);
volts = (float)a/1023.0 * 5.0;
Serial.println(volts,2);
delay(200);
}
Summary of Contents for StenBOT Rover Kit
Page 1: ...1 StenBOT Rover Kit Stensat Group LLC Copyright 2013 ...
Page 4: ...4 Overview ...
Page 22: ...22 22 Assembly ...
Page 58: ...58 58 Processor Board and Arduino Software ...
Page 118: ...118 118 Completing The Robot Motion ...
Page 138: ...138 138 Digital Signal Connections ...
Page 166: ...166 166 Remote Control ...