Robotique FIP / Mbed 2 deprecated Coupe Robotique FIP

Dependencies:   mbed HC_SR04_Ultrasonic_Library Nucleo_Sensor_Shield VL6180x_lib

Fork of Coupe Robotique FIP by Julien Tiron

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ultrasonic.h"
00003 #include "VL6180x.h"
00004 #include "easyspin.h"
00005 
00006 #define VL6180X_ADDRESS 0x29
00007 
00008 Easyspin myEasyspin;
00009 DigitalInOut sdaDummy(D14);
00010 DigitalInOut sclDummy(D15);
00011 
00012 VL6180xIdentification identification;
00013 // mbed uses 8bit addresses shift address by 1 bit left
00014 VL6180x sensor(D14, D15, VL6180X_ADDRESS<<1);
00015 
00016 int main()
00017 {
00018     sdaDummy.mode(PullUp);
00019     sclDummy.mode(PullUp);
00020     myEasyspin.Begin(2);
00021     while(1) {
00022         if(sensor.getDistance()<255) {
00023             myEasyspin.Run(0, FORWARD);
00024             myEasyspin.Run(1, FORWARD);
00025         } else {
00026             myEasyspin.Run(0, FORWARD);
00027             myEasyspin.Run(1, BACKWARD);
00028         }
00029         wait_ms(200);
00030     }
00031 }