ROBOT CONTRÔLÉ PAR ANDROID
Cet exemple vous montre l’exemple d’un
robot à deux roues commandées par une
application Android via Bluetooth.
Matériels
requis
·
Carte
Arduino Mega ADK (ou autre type de carte Arduino)
·
CI
de pilote de moteur L293D
·
2X
(petit) moteurs à courant continu
·
Fils
de raccordement
·
Module
Bluetooth HC05
Simulation
Routage
Application Android
L'application Android a étè developpe par l'outil MitAppInventor 2
Interface d'identification
Interface de commande
Code
/ *
DIY Electronics par Bessem BELGHITH
DIY Electronics par Bessem BELGHITH
Robot commandé par Bluetooth
via une application Android
* /
* /
// pins moteurs
//moteur gauche
int mg1=8;
int mg2=9;
int enableg=11 ;
//moteur droite
int md1=5;
int md2=6;
int enabled=4;
int vitesses=255;
//constantes
char c;
void setup(){
Serial.begin(9600);
pinMode(mg1,OUTPUT);
pinMode(mg2,OUTPUT);
pinMode(md1,OUTPUT);
pinMode(md2,OUTPUT);
pinMode(enabled,OUTPUT);
pinMode(enableg,OUTPUT);
}
void loop()
{
if( Serial.available() ) // if data is available to read
{
c=Serial.read();
Serial.println(c);
switch(c)
{
case 'E':
Avance();
delay(250);
Stop();
delay(250);
break;
case 'F':
Droite();
delay(250);
Stop();
delay(250);
break;
case 'G':
Gauche();
delay(250);
Stop();
delay(250);
break;
case 'H':
Arriere();
delay(250);
Stop();
delay(250);
break;
default: Stop();
}
}
}
Aucun commentaire:
Enregistrer un commentaire