How to read analog data with Arduino Uno

My next project is I want to know how analog reading is working

Material needs:
- Arduino Uno
- Potensiometer 10k Ohm.
- Jumper wire

You have to set the arduino and potensiometer as below.
Schematic

Visual by arduino
Use pin A0 for analog input
Write down this sketch or you can se detail in here.

void setup()  
{ 
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
 }

// the loop routine runs over and over again forever:
void loop()  
{
                                                       // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
                                                      // print out the value you read:
  Serial.println(sensorValue);
  delay(1);                                      // delay in between reads for stability 
 }


See the result data in Serial Monitor.
Klik on Tools --> Serial Monitor

Sensor value will shown in monitor.
You can use the value for reference your design.

Ensure the baud rate is 9600.

Thanks a lot

Comments

Popular posts from this blog

Membuat lampu otomatis menggunakan arduino dan RTC (Untuk 2 lampu)

Cara menggunakan tombol keypad pada LCD shield (How to use keypad on LCD shield)

Cara membuat gelombang sinus dengan PWM arduino (Make a sine wave with PWM arduino)