Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Last active August 29, 2015 14:22
Show Gist options
  • Save buildcircuit/ebd786ab3b96f6fc7644 to your computer and use it in GitHub Desktop.
Save buildcircuit/ebd786ab3b96f6fc7644 to your computer and use it in GitHub Desktop.
Light sensor for Amarino Lamp with BuildCircuit app
/* visit www.amarino-toolkit.net to know about Amarino*/
#include <MeetAndroid.h>
// declare MeetAndroid so that you can call functions with it
MeetAndroid meetAndroid;
int redLed = 9;
void setup()
{
Serial.begin(9600);
// register callback functions, which will be called when an associated event occurs.
meetAndroid.registerFunction(valuesensor, 'm');
// set all color leds as output pins
pinMode(redLed, OUTPUT);
// just set all leds to high so that we see they are working well
digitalWrite(redLed, HIGH);
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
/*
* Whenever the multicolor lamp app changes the red value
* this function will be called
*/
void valuesensor(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