How to Access Analog pins of Arduino using Raspberry pi

How to Access Analog pins of Arduino using Raspberry pi

  1. Connect the arduino uno with raspberry pi using usb cable adapter

  2. Connect the Potentiometer middle pin(output pin) to A0 in arduino board (connection can made by wires)

  3. Connect the potentiometer input pin to +5v in arduino board

  4. Connect the ground pin of potentiometer to gnd pin in arduino board

  5. Go to the Lxterminal in raspberry pi

  6. Type sudo arduino

  7. Click on the File->Examples->Basics->AnalogReadSerial

  8. You program will like this

    /*

    AnalogReadSerial

 Reads an analog input on pin 0, prints the result to the serial monitor.

 Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is in the public domain.

 */

 // the setup routine runs once when you press reset:

 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

 }

  9.Click verify icon to compile the program

 10.Click upload icon to upload the program

 11.Now select serial monitor icon on the right top of your arduino IDE

 12.It will open like a window and your serial monitor will shows the potentiometer value

 Note:

  • By changing the analog pin number A0-A7 you can access the Analog ports 0-7 respectively

  • No need install interfacing software like (pyserial,nanpy) more than once .

  • Once nanpy,pyserial installed correctly it will communicate arduino automatically

 

 

 

 

 

You are here: Home Document Embedded Systems How to Access Analog pins of Arduino using Raspberry pi