Created
October 23, 2012 15:39
-
-
Save buildcircuit/3939541 to your computer and use it in GitHub Desktop.
LM35_temperature sensor and LED controller_ Amarino Evaluation Shield
This file contains 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 <MeetAndroid.h> | |
MeetAndroid meetAndroid; | |
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd(13, 12, 10, 9, 8, 7); | |
int redLed = 11; | |
int sensorPin = A0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
lcd.begin(16, 2); | |
Serial.begin(9600); | |
lcd.write("Temperature data"); | |
////////////////////////////////////////// | |
pinMode(sensorPin,INPUT); | |
meetAndroid.registerFunction(red,'o'); | |
pinMode(redLed,OUTPUT); | |
analogWrite(redLed,20); | |
} | |
void loop() | |
{ | |
meetAndroid.receive(); | |
int value = analogRead(sensorPin); | |
//Serial.print(value); | |
//Serial.print(" > "); | |
float millivolts = (value / 1024.0) * 5000; | |
float celsius = millivolts / 10; // sensor output is 10mV per degree Celsius | |
Serial.print(celsius); | |
Serial.println(" degrees Celsius, "); | |
Serial.print( (celsius * 9)/ 5 + 32 ); // converts to fahrenheit | |
Serial.println(" degrees Fahrenheit"); | |
Serial.print("From Amarino:"); | |
meetAndroid.send(celsius); | |
//meetAndroid.send("celsius"); | |
delay(1000); // wait for one second | |
} | |
void red(byte flag, byte numOfValues) | |
{ | |
analogWrite(redLed, meetAndroid.getInt()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment