Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Created October 23, 2012 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buildcircuit/3939653 to your computer and use it in GitHub Desktop.
Save buildcircuit/3939653 to your computer and use it in GitHub Desktop.
Light Sensor using Amarino Evaluation Shield
#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 ledPin = 11;
void setup()
{
// use the baud rate your bluetooth module is configured to
// not all baud rates are working well, i.e. ATMEGA168 works best with 57600
lcd.begin(16, 2);
lcd.print("Light sensor");
// initialize the serial communications:
Serial.begin(9600);
// register callback functions, which will be called when an associated event occurs.
// - the first parameter is the name of your function (see below)
// - match the second parameter ('A', 'B', 'a', etc...) with the flag on your Android application
// small letters are custom events, capital letters inbuilt Amarino events
meetAndroid.registerFunction(intValue, 'A');
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void intValue(byte flag, byte numOfValues)
{
int v = meetAndroid.getInt();
analogWrite(ledPin,v);
lcd.clear();
lcd.print("Light data:");
lcd.print(v);
Serial.println(v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment