/* inputdevices_lm Reads two analogue inputs on A2 and A3 and compares with a set value Turns on LED if temperature difference greater than set point. Developed as part of an assignment for Fab Academy 2017 This example code is in the public domain. */ // the setup routine runs once when you press reset: #include SoftwareSerial mySerial(0,1); // Rx, TX int temptrip = 52; //ADC count difference correspons to 30C int tempdiff; void setup() { // initialize serial communication at 9600 bits per second: mySerial.begin(9600); pinMode(8, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue1 = analogRead(A2); int sensorValue2 = analogRead(A3); tempdiff = sensorValue2 - sensorValue1; if(tempdiff > temptrip) { digitalWrite(8,HIGH); } else { digitalWrite(8,LOW); } mySerial.print("ADC count difference is "); mySerial.print(tempdiff); mySerial.print('\n'); delay(1000); // delay in between reads for stability }