Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sensor Graph using Amarino Evaluation shield
/*
Sends sensor data to Android
(needs SensorGraph and Amarino app installed and running on Android)
First author: Bonifaz Kaufmann - December 2009
The source works for Amarino Evaluation shield from BuildCircuit.com
*/
#include <MeetAndroid.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 10, 9, 8, 7);
MeetAndroid meetAndroid;
int sensor = A1;
int redLed = 11;
void setup()
{
// use the baud rate your bluetooth module is configured to
// not all baud rates are working well, i.e. ATMEGA328 works best with 57600
Serial.begin(9600);
Serial.begin(9600);
lcd.write("Sensor Graph");
pinMode(sensor, INPUT);
meetAndroid.registerFunction(red, 'o');
pinMode(redLed, OUTPUT);
analogWrite(redLed, 20);
// we initialize pin 5 as an input pin
}
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