Professional Documents
Culture Documents
What is Sensor
Sensors are those electronic components which convert physical data into
electronic data. This data is in analog format and is fed to the microcontroller on the
Arduino board. The microcontroller has inbuilt ADCs (Analog-2-Digital Converter)
which processes this data and converts it into digital format.
And once you have received the (electronically converted) physical data, you can
make your Arduino perform as you want.
On your Arduino board, there are analog pins named as A0, A1, A2, A3, A4, A5. The
number of these pins may vary depending on your Arduino board. For UNO, there
are only 6 analog pins while for MEGA there are 16. And remember this thing, any
sensor (or other components) that gives analog data and you wish to process it,
you'll have to connect it to your analog pins only. For now, I would say SENSORS
would always be connected to analog pins.
void loop()
{
int sensorValue = analogRead(A1); // read the input on analog pin 1:
Serial.println(sensorValue); // print out the value you read:
delay(1); //this delay in between reads for
stability
}
After burning this code to your Arduino, open the serial monitor and see the analog-
2-digital converted data on your serial terminal. Basically, it is 10-bit data since the
inbuilt ADC of your Arduino is a 10bit ADC.You will get the reading on your serial
monitor.