Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Orientation sensor_ Amarino Plugin
#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("Orientation 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("Orientation: ");
lcd.print(v);
Serial.println(v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.