// C++ code
//
/*
AnalogReadSerial
Reads an analog input (potentiometer) on pin 0,
prints the result to the serial monitor.
OPEN THE SERIAL MONITOR TO VIEW THE OUTPUT FROM
THE POTENTIOMETER >>
Attach the center pin of a potentiometer to pin
A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
long sensorValue = 0;
long val;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop()
{
// read the input on analog pin 0:
sensorValue = analogRead(A0);
val = sensorValue*750.0 / 1023.0;
// print out the value you read:
Serial.println(sensorValue);
Serial.println(val);
delay(10); // Delay a little bit to improve simulation performance
}