Voici un programme afin d’interfacer le capteur VL6180X avec la carte Esus. Le capteur est relié par bus I2C à la carte Esus. Le capteur VL6180X est capteur de distance “Time of Flight” de mesure laser de distance de 0 à 200 mm.
#include <ESP8266WiFi.h>#include <WiFiUDP.h>#include <mrduino.h>static void read_receptionCommande(String Commande);int status = WL_IDLE_STATUS;const char* ssid = "YOUR_SSID"; // your network SSID (name)const char* pass = "YOUR_PASS"; // your network passwordunsigned int localPort = 12345; WiFiUDP Udp;int tries=0;void setup(){ // Open serial communications and wait for port to open: Serial.begin(115200); // setting up Station AP WiFi.begin(ssid, pass); // Wait for connect to AP Serial.print("[Connecting]"); Serial.print(ssid); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); tries++; if (tries > 30) { break; } } Serial.println(); printWifiStatus(); Serial.println("Connected to wifi"); Serial.print("Udp server started at port "); Serial.println(localPort); Udp.begin(localPort);}void loop(){int noBytes = Udp.parsePacket();String received_command = "";byte packetBuffer[512]; if ( noBytes ) { Serial.print("received a packet"); // We've received a packet, read the data from it Udp.read(packetBuffer,noBytes); // read the packet into the buffer for (int i=1;i<=noBytes;i++) { received_command = received_command + char(packetBuffer[i - 1]); } // end for Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); Udp.endPacket(); // execution de la commande Serial.println(received_command); } // end if}void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your WiFi shield's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip);}
Compiler et télécharger le programme dans le robot MRduino Wireless
Le programme de contrôle
Lien pour télécharger le programme de contrôle (dossier Zip): MrduinoControler
Remarque : programme pour Windows
Dézipper le dossier :
Lancer le programme MRduinoControler.exe
Ce programme permet de contrôler les mouvements du robot et les trois leds. Ne pas oublier de saisir l’adresse IP correct du robot.