Skip to content

Instantly share code, notes, and snippets.

@smetronic
Created December 2, 2017 15:14
Show Gist options
  • Save smetronic/dc95e62cab90619730033831dc575601 to your computer and use it in GitHub Desktop.
Save smetronic/dc95e62cab90619730033831dc575601 to your computer and use it in GitHub Desktop.
ATMega 328p : Analog Voltage to Serial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
mySerial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A5);
float voltage = sensorValue * (5.0 / 1023.0);
int data = voltage * 100;
String res = String(data);
Serial.println(res);
mySerial.println(res);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment