Last active
August 29, 2015 14:19
-
-
Save buildcircuit/88a69d7d019c019b81cd to your computer and use it in GitHub Desktop.
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
/* | |
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