1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

How to read values from ATmega328P?

Discussion in 'Arduino' started by henkoegema, Apr 30, 2015.

  1. henkoegema

    henkoegema New Member

    Joined:
    Apr 30, 2015
    Messages:
    1
    Likes:
    0
    I have compiled and flashed (successfully) following program to the atmega328P (connected to a raspberry pi, MOSI-MISO-....).
    This program reads a voltage on pin A0

    Code (text):

    const int analogInPin = A0;

    float sensorValue = 0;

    void setup(){
    Serial.begin(9600);
    }

    void loop() {
    sensorValue = analogRead(analogInPin);

    Serial.print(¨Voltage Output = ");
    Serial.print(sensorValue*5/1023);
    Serial.println(" ");

    delay(100);
    }
     

    I only use the command line in the raspberry pi. (no GUI)

    When I've flashed the program I get the command prompt back. So far, so good.

    Q: How do I read the values of the program in the atmega328p back into my raspberry pi? :(

    (How I flashed it: $avrdude -p m328p -c gpio -e -U flash:w:build-cli/Arduino.hex)
     
    Last edited: May 1, 2015
  2. b.james

    b.james Member

    Joined:
    Feb 4, 2014
    Messages:
    167
    Likes:
    9
    I don't know or use the Pi
    Your serial terminal will display the reading as you have set it up above so you will have to get that serial output read by the Pi
     
  3. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,798
    Likes:
    134
    Location:
    morristown,tn
    It's easy as
    Code (text):
    cat /dev/ttyS0
    the last part needs to be where your arduino is the com port you have it on to program
     

Share This Page