Robot using IMU and IR sensor data to drive autonomously and create a map
Dependencies: mbed mbed-rtos LSM9DS1_Library_cal Motor
main.cpp
- Committer:
- wschon
- Date:
- 2016-04-10
- Revision:
- 2:fcf6f5901ee6
- Parent:
- 1:27c32ba9fe93
- Child:
- 3:70f624c5fe26
File content as of revision 2:fcf6f5901ee6:
#include "mbed.h" #include "rtos.h" AnalogIn infraredR(p20); //Right infrared distance sensor AnalogIn infraredL(p19); //Left infrared distance sensor AnalogIn infraredF(p17); //Front infrared distance sensor float leftDist, rightDist, frontDist; //Distances from robot to obstacles void left_thread(void const *args) { while (1) { leftDist = infraredL * 3.3f; Thread::wait(500); //wait 1/2 second before updating } } void right_thread(void const *args) { while (1) { rightDist = infraredR * 3.3f; Thread::wait(500); //wait 1/2 second before updating } } void front_thread(void const *args) { while (1) { frontDist = infraredF * 3.3f; Thread::wait(500); //wait 1/2 second before updating } } int main() { //Test Thread left(left_thread); Thread right(right_thread); Thread front(front_thread); while(1) { } }