Created
August 7, 2012 01:20
-
-
Save skierkowski/3280389 to your computer and use it in GitHub Desktop.
Main analog loop for Aruino sensors
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
void loop() { | |
// read the value from the sensor: | |
if(Serial.available() > 0) | |
{ | |
while(1) | |
{ | |
while(Serial.available()>0) | |
{ | |
int incoming_byte=Serial.read(); | |
} | |
float moist = readMoisture(); | |
float light = readLight(); | |
float temp_f=readTemperatureF(); | |
float humidity=readHumidity(); | |
Serial.print("{\"light\": \""); | |
Serial.print(light, DEC); | |
Serial.print("\", \"moisture\": \""); | |
Serial.print(moist, DEC); | |
Serial.print("\", \"temperature\": \""); | |
Serial.print(temp_f, DEC); | |
Serial.print("\",\"humidity\": \""); | |
Serial.print(humidity, DEC); | |
Serial.println("\"}"); | |
Serial.flush(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment