nn
code: [select]
#include <softwareserial.h>
softwareserial bt(5, 6);
string readstring;
void setup()
{
// set digital pin control output
pinmode(13, output);
// set data rate softwareserial port
bt.begin(9600);
// send test message other device
bt.println("hello arduino");
}
void loop()
{
lecture();
if (readstring.length() >0) // vérifie que la variable contient de l'information
{
if (readstring == "allumer")
{
digitalwrite(13, high);
bt.println("led on");
}
if (readstring == "eteindre")
{
digitalwrite(13, low);
bt.println("led off");
}
if (readstring == "quoi")
{
bt.println("send 'allumer' turn led on");
bt.println("send 'eteindre' turn led off");
}
readstring="";
}
}
void lecture()
{
while (bt.available()) // if text arrived in bt serial...
{ delay(3);
char = bt.read();
readstring += a;
}
}
voila le code que j'ai utilisé pour communiquer avec mon smartphone
Arduino Forum > International > Français (Moderators: jfs, Snootlab) > NN
arduino
Comments
Post a Comment