Analog read signal using arduino (ATMEGA328) program - Arduino Tutorials

This is a basic and Hello World program in the arduino world. This program just reads from one pin (say pin A) and writes to serial monitor what it read from the first pin (pin A).

Analog Read Signal Program in Arduino:
setup() {
  Serial.begin(9600);
}

void loop() {
  int sense = analogRead(A0);
  Serial.println(sense);
  delay(1);        
}

Explanation:

setup():

In the Setup Loop serial communication is initialized at 9600 baud rate (bits per second).  

loop():

In Loop function read the Analog pin 0 (A0) and store it as a integer sense.
Then print or writes to serial monitor what it read from A0.
delay is given for stability.

How to check output:

Connect the center pin of the potentiometer to the pin A0 and the outside pin to +5 and ground.
Then download the program to the arduino device. That's it your first hello world aka analog read signal program using arduino is successflly executed.

Cheers!!!!
-> Let Us Embed <-