Created
December 2, 2017 15:14
-
-
Save smetronic/dc95e62cab90619730033831dc575601 to your computer and use it in GitHub Desktop.
ATMega 328p : Analog Voltage to Serial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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