Created
December 7, 2013 09:52
-
-
Save davidperrenoud/7839190 to your computer and use it in GitHub Desktop.
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 <prismino.h> | |
#include <Bluetooth.h> | |
long since_last_bluetooth = 0; | |
void setup() | |
{ | |
// open Bluetooth communication and wait for port to open | |
delay(1000); | |
Bluetooth.begin(9600); | |
delay(1000); | |
Serial.begin(9600); | |
// set pin output mode (sources current) | |
pinMode(LED, OUTPUT); | |
} | |
void loop() | |
{ | |
if(Bluetooth.available()) | |
{ | |
char incoming[3]; | |
Bluetooth.readBytesUntil(0, incoming, 3); | |
int number1 = incoming[0] - 100; | |
int number2 = incoming[1] - 100; | |
setSpeed(number1, number2); | |
since_last_bluetooth = 0; | |
} | |
else | |
{ | |
since_last_bluetooth += 1; | |
// si pas de connexion Bluetooth depuis 600 fois, on s'arrete | |
if (since_last_bluetooth > 600) | |
{ | |
setSpeed(0, 0); | |
} | |
} | |
delay(1); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment