Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Last active August 29, 2015 14:19
Show Gist options
  • Save buildcircuit/88a69d7d019c019b81cd to your computer and use it in GitHub Desktop.
Save buildcircuit/88a69d7d019c019b81cd to your computer and use it in GitHub Desktop.
/*
Sends sensor data to Android
(needs SensorGraph and Amarino app installed and running on Android)
*/
#include <MeetAndroid.h>
MeetAndroid meetAndroid;
int sensor = A1;
int redLed = 11;
void setup()
{
// use the baud rate your bluetooth module is configured to
Serial.begin(9600);
pinMode(sensor, INPUT);
meetAndroid.registerFunction(red, 'o');
pinMode(redLed, OUTPUT);
analogWrite(redLed, 20);
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
meetAndroid.send(analogRead(sensor));
// add a little delay otherwise the phone is pretty busy
delay(100);
}
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