Advertisement
barton2

Arduino 2channel read/write to serial

Nov 14th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   ReadTemp
  3.   Reads a TC input on Pin 0, converts it to voltage, and prints the result to the serial monitor.
  4.  
  5.  This example code is in the public domain.
  6.  */
  7. #include "Arduino.h"
  8. // the setup routine runs once when you press reset:
  9. void setup() {
  10.   // initialize serial communication at 9600 bits per second:
  11.   Serial.begin(9600);
  12. }
  13.  
  14. // the loop routine runs over and over again forever:
  15. void loop() {
  16.   // read the input on analog pin 0:
  17.   int sensorValue = analogRead(0);
  18.   int sensorValue2 = analogRead(1);
  19.   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  20.   float voltage = sensorValue * (5.0 / 1023.0);
  21.   float temperature = (voltage-1.25)/0.005;
  22.   // print out the value you read:
  23.   Serial.println(sensorValue);
  24.   Serial.print(" ");
  25.   Serial.println(sensorValue2);
  26.   Serial.print("\n");
  27.   delay(50);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement