Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/LocalSettings.php on line 193

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/LocalSettings.php on line 197

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338
[ Wikidébrouillard ] Petit Bot un robot controlable en Wifi

Petit Bot un robot controlable en Wifi

De Wikidebrouillard.

(Schéma de cablage)
(Schéma de cablage)
Ligne 35 : Ligne 35 :
=='''Schéma de cablage'''==
=='''Schéma de cablage'''==
-
[[Fichier:Petitbot.png]]
+
[[Fichier:Petitbot.png|400px]]
==Le code==
==Le code==

Version du 29 novembre 2016 à 22:21

Article incomplet en cours de rédaction
Modèle:Vidéo


Sommaire

Présentation de la réalisation

Tutoriel pour construire et un petit robot contrôlable en Wifi.

Il sera contrôlable depuis un ordinateur mais aussi tablette ou smartphone, quelque soit l'appareil.

Matériel

  • Carte wemos D1 mini | lien
  • Soit vous modifiez 2 servo 9G (SG90) en servo à rotation continue (Voir ce tutoriel en anglais ou Celui-ci), soit vous utilisez 2 Servos moteurs 360° (rotation continue) | Lien
  • 1 interupteur | Lien
  • 2 supports CI 8X1 livré avec le Wemos
  • 2 borniers broche mâle 3X1 livré avec le wemos

Version imprimée en 3D

A imprimer avec une imprimante 3D

Sans imprimante 3D

A réaliser dans du carton rigide :

  • un châssis de 12cm par 7,5cm.
  • réaliser en mode débrouille, un support pour 4 piles de 1,5V

La réalisation

Coller les différentes pièces du petit bot.

1 - l'axe des servo-moteurs aux roues

2 - Les servos à fixer au châssis

3 - installez un marqueur à l'avant

Schéma de cablage

Le code

////////////////
//Le Petit Bot//
////////////////
/* un programme conçu par Julien Rat sous licence CC-By-Sa. 
Ce programme sert à piloter le "Petit Bot". 
C'est un robot pédagogique, très peu cher, utilisé par les petits débrouillards*/

#include <ESP8266WiFi.h>

//////////////////////
//Définition du Wifi//
//////////////////////
const char WiFiAPPSK[] = "1234567890"; //password

//////////////////////////
//Définition des broches//
//////////////////////////

#include <Servo.h>

Servo monservo1;

Servo monservo2;

WiFiServer server(80);

void setup()
{
  initHardware();
  setupWiFi();
  server.begin();
  monservo1.attach(5);
  monservo2.attach(4);
  monservo1.write(91); 
  monservo2.write(93); 

}

void loop()
{
  // Regarder si un client s'est connecté
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Lit la première ligne de la requête
  String req = client.readStringUntil('\r');
  
  client.flush();

  // Test la requête pour indentifier la consigne
  int val = -1; 

  if (req.indexOf("/stop") != -1)
    val = 0; 
  else if (req.indexOf("/avance") != -1)
    val = 1;
  else if (req.indexOf("/recule") != -1)
    val = 2; 
  else if (req.indexOf("/gauche") != -1)
    val = 3; 
  else if (req.indexOf("/droite") != -1)
    val = 4; 



  // Prepare la page web de réponse. Débute par le "header" commun :
  String s = "HTTP/1.1 200 OK\r\n";
  s += "Content-Type: text/html\r\n\r\n";
  s += "<!DOCTYPE HTML>\r\n<html>\r\n";
  if (req.indexOf("/commande") != -1 ) {
    s += "<input type=\"button\" onclick=\"location.href='192.168.4.1/led/1';\" value=\" OFF \" />";
    s += "<input type=\"button\" onclick=\"location.href='192.168.4.1/led/0';\" value=\" ON \" />";

  }
  // If we're setting the LED, print out a message saying we did
  if (val == 2 ) //avance
  {
    s += " avance ";
    monservo2.write(0);  //avance
    monservo1.write(180);  //avance
  }
  if (val == 1)//this left over from the sparkfun demo, not currently used
  { // If we're reading pins, print out those values:
    s += " recule ";
    monservo2.write(180);  //recule
    monservo1.write(0);  //recule
  }
  if (val == 0)//this left over from the sparkfun demo, not currently used
  { // If we're reading pins, print out those values:
    s += " recule ";
    monservo1.write(91);  //recule
    monservo2.write(93);  //recule
  }
  if (val == 3)//this left over from the sparkfun demo, not currently used
  { // If we're reading pins, print out those values:
    s += " gauche ";
    monservo1.write(180);  //gauche
    monservo2.write(180);  //recule
  }
  if (val == 4)//this left over from the sparkfun demo, not currently used
  { // If we're reading pins, print out those values:
    s += " droite ";
    monservo1.write(0);  //droite
    monservo2.write(0);  //recule
  }


  s += "</html>\n";

  // Envoie la réponse au client
  client.print(s);
  delay(1);
  Serial.println("Client disconnected");
  client.flush();

}

void setupWiFi()
{
  WiFi.mode(WIFI_AP);
  uint8_t mac[WL_MAC_ADDR_LENGTH];
  WiFi.softAPmacAddress(mac);
  String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
                 String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
  macID.toUpperCase();
  String AP_NameString = "PetitBot";

  char AP_NameChar[AP_NameString.length() + 1];
  memset(AP_NameChar, 0, AP_NameString.length() + 1);//zero out AP_NameChar

  for (int i = 0; i < AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);

  WiFi.softAP(AP_NameChar, WiFiAPPSK, 7);
}

void initHardware()
{
  Serial.begin(115200);
} //See more at: http://www.esp8266.com/viewtopic.php?f=29&t=6419#sthash.gd1tJhwU.dpuf

Liens avec d'autres réalisation

Expériences sur Wikidébrouillard

Voir la Catégorie

Applications : liens avec le quotidien

le wifi peut être utilisé pour diverses applications, ici, contrôler un robot.

Lieux propices à sa réalisation

Fablab, dans l'atelier de bidouille électronique le plus proche ?

Catégories

Portail des ExplorateursWikidébrouillardLéon DitFLOGPhoto mystèreJ'ai FaitPortraits
AR
TE

Petit Bot un robot controlable en Wifi

Rechercher

Page Discussion Historique
Powered by MediaWiki
Creative Commons - Paternite Partage a l

© Graphisme : Les Petits Débrouillards Grand Ouest (Patrice Guinche - Jessica Romero) | Développement web : Libre Informatique