It is a test program of wallbot library.

Dependencies:   mbed wallbot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "wallbot.h"
00003 
00004 wallbot wb;
00005 
00006 BusOut leds(LED1,LED2,LED3,LED4);
00007 
00008 int main() {
00009 
00010     wait(0.5);
00011     
00012     // Motor test.
00013     wb.forward(0.5);
00014     wait (2.0);
00015     wb.left(0.5);
00016     wait (2.0);
00017     wb.backward(0.5);
00018     wait (2.0);
00019     wb.right(0.5);
00020     wait (2.0);
00021     
00022     wb.stop();
00023 
00024     // Sensor & Switch test.
00025     while(1)
00026     {
00027         int bit;
00028         wb.GetLinePosition(&bit);
00029         printf("LeftSw:%d  RightSw:%d FloorSensor:%X\r\n",wb.GetLeftSw(),wb.GetRightSw(),bit);
00030         leds = bit;
00031         wait(0.1);
00032     }
00033  }