L'équipe robotique FIP a pour but de participer à la Coupe de France de Robotique (http://www.planete-sciences.org/robot/?section=pages&pageid=79). L'équipe est composée d'étudiants de l'école d'ingénieur Télécom Bretagne en filière par partenariat. Nous utilisons comme plateforme les microcontrôleurs STM32 associés aux cartes NUCLEO.
Dependencies: mbed HC_SR04_Ultrasonic_Library Nucleo_Sensor_Shield VL6180x_lib
Fork of Coupe Robotique FIP by
We are a team of students building an autonomous robot which will compete in the French Robotic Cup.
Diff: main.cpp
- Revision:
- 14:4f85e35de719
- Parent:
- 4:149c4509b35d
--- a/main.cpp Fri Apr 10 11:38:18 2015 +0000 +++ b/main.cpp Tue Jul 07 20:37:40 2015 +0000 @@ -1,23 +1,31 @@ #include "mbed.h" #include "ultrasonic.h" +#include "VL6180x.h" +#include "easyspin.h" - void dist(int distance) -{ - //code exécuté lorsque la distance change - printf("Distance changed to %dmm\r\n", distance); -} +#define VL6180X_ADDRESS 0x29 -ultrasonic mu(D8, D9, .1, 1, &dist); //Trigger: pin D8; Echo: pin D9 - //Updates toutes les 0.1 secondes et timeout après 1 seconde - //Appel de dist lorsque la distance change +Easyspin myEasyspin; +DigitalInOut sdaDummy(D14); +DigitalInOut sclDummy(D15); + +VL6180xIdentification identification; +// mbed uses 8bit addresses shift address by 1 bit left +VL6180x sensor(D14, D15, VL6180X_ADDRESS<<1); int main() { - mu.startUpdates();//démarre la mesure - while(1) - { - //Do something else here - mu.checkDistance(); //call checkDistance() as much as possible, as this is where - //the class checks if dist needs to be called. + sdaDummy.mode(PullUp); + sclDummy.mode(PullUp); + myEasyspin.Begin(2); + while(1) { + if(sensor.getDistance()<255) { + myEasyspin.Run(0, FORWARD); + myEasyspin.Run(1, FORWARD); + } else { + myEasyspin.Run(0, FORWARD); + myEasyspin.Run(1, BACKWARD); + } + wait_ms(200); } }