Open Arduino IDE and write code

How it's done

Write the following code in Arduino IDE:

int sensor = A0; //Sensor pin

void setup() {

void loop() {
 int x = analogRead(sensor);

Extra info:

Code explanation:

int sensor = A0; //Sensor pin defines which pin we use to read sensor value.

pinMode(sensor,INPUT); // Defines that sensor pin will be used as input (to read).

Serial.begin(9600); // Allows us to read data on serial monitor.

int x = analogRead(sensor); // Declare integer variable x and initialize it with analog read value from sensor.

Serial.println(x); // Print value of x variable in serial monitor with line break.

Activity Q&A

Need help with this activity?Add the first post