Skip to content

Instantly share code, notes, and snippets.

@davidperrenoud
Created December 7, 2013 09:52
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 davidperrenoud/7839190 to your computer and use it in GitHub Desktop.
Save davidperrenoud/7839190 to your computer and use it in GitHub Desktop.
#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