Analog to Digital Conversion in ARDUINO
Analog to digital conversion module of ARDUINO UNO has 6 input ports. The number of the port varies with your ARDUINO model but the coding remains the same. The analog reading in the analog inputs are converted into corresponding 10bit(0-1023).
ARDUINO developers have made such an option that you can print anything and see it on the Serial monitor.
This example demonstrates analog input usage by reading an analog sensor on analog pin 0 and turning on and off a light emitting diode(LED) connected to digital pin 13 and also printing the corresponding ADC value.
The amount of time the LED will be on and off depends on the value obtained by analogRead().
Serial printing is enabled using Serial.begin(baud rate). You can mension the baud rate within the brackets followed by Serial.begin (here 9600).
Serial.print() is used to display the reading.
The circuit coonection is as given below:
- Potentiometer attached to analog input 0
- Center pin of the potentiometer to the analog pin
- One side pin (either one) to ground
- The other side pin to +5V
- LED anode (long leg) attached to digital output 13
- LED cathode (short leg) attached to ground
Note: Pin 13 is mostly preferred for testing purpose because most Arduinos have a built-in LED attached to pin 13 on the board, the LED is optional.
You can see the readings from Serial Monitor.
For more detail: Analog to Digital Conversion in ARDUINO
This Post / Project can also be found using search terms:
- arduino led clock conversion