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.

  • 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.

How to read values from ATmega328P?

Status
Not open for further replies.

henkoegema

New Member
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:
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:

b.james

Member
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
 

be80be

Well-Known Member
It's easy as
Code:
cat /dev/ttyS0
the last part needs to be where your arduino is the com port you have it on to program
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top