Skip to content

Instantly share code, notes, and snippets.

@hackolite
Last active January 6, 2016 23:00
Show Gist options
  • Save hackolite/4a500d5aacb7b352c02f to your computer and use it in GitHub Desktop.
Save hackolite/4a500d5aacb7b352c02f to your computer and use it in GitHub Desktop.
char val; // variable to receive data from the serial port
void setup() {
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
}
if( val == 'd' ) // if 'H' was received
{
int mq3_value = analogRead(A0);
Serial.print(" {'luminosity': ");
Serial.print(mq3_value);
Serial.println("}");
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment