Created
May 30, 2015 10:13
-
-
Save buildcircuit/448168ba2f965d65fb1d to your computer and use it in GitHub Desktop.
Amarino lamp responding to phone call
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
#include <MeetAndroid.h> | |
// declare MeetAndroid so that you can call functions with it | |
MeetAndroid meetAndroid; | |
int redLed = 9; | |
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); | |
// register callback functions, which will be called when an associated event occurs. | |
meetAndroid.registerFunction(valuesensor, 'A'); | |
// 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()); | |
if(meetAndroid.getInt()==1) | |
{ | |
for (int i= 0; i<10;i++) | |
{ | |
analogWrite(redLed,255); | |
delay(2000); | |
analogWrite(redLed,0); | |
delay(2000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment