Skip to content

Instantly share code, notes, and snippets.

@skierkowski
Created August 7, 2012 01:20
Show Gist options
  • Save skierkowski/3280389 to your computer and use it in GitHub Desktop.
Save skierkowski/3280389 to your computer and use it in GitHub Desktop.
Main analog loop for Aruino sensors
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