Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Main.cpp
00001 /* 00002 * Main.cpp 00003 * Copyright (c) 2018, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #include <cstdlib> 00008 #include <mbed.h> 00009 #include "EncoderCounter.h" 00010 #include "IRSensor.h" 00011 #include "Controller.h" 00012 #include "StateMachine.h" 00013 00014 int main() { 00015 00016 // create miscellaneous periphery objects 00017 00018 DigitalOut led(LED1); 00019 DigitalIn button(USER_BUTTON); 00020 00021 DigitalOut led0(PC_8); 00022 DigitalOut led1(PC_6); 00023 DigitalOut led2(PB_12); 00024 DigitalOut led3(PA_7); 00025 DigitalOut led4(PC_0); 00026 DigitalOut led5(PC_9); 00027 00028 // create motor control objects 00029 00030 DigitalOut enableMotorDriver(PB_2); 00031 DigitalIn motorDriverFault(PB_14); 00032 DigitalIn motorDriverWarning(PB_15); 00033 00034 PwmOut pwmLeft(PA_8); 00035 PwmOut pwmRight(PA_9); 00036 00037 EncoderCounter counterLeft(PB_6, PB_7); 00038 EncoderCounter counterRight(PA_6, PC_7); 00039 00040 // create distance sensor objects 00041 00042 DigitalOut enableIRSensors(PC_1); 00043 enableIRSensors = 1; 00044 00045 AnalogIn distance(PB_1); 00046 DigitalOut bit0(PH_1); 00047 DigitalOut bit1(PC_2); 00048 DigitalOut bit2(PC_3); 00049 00050 IRSensor irSensor0(distance, bit0, bit1, bit2, 0); 00051 IRSensor irSensor1(distance, bit0, bit1, bit2, 1); 00052 IRSensor irSensor2(distance, bit0, bit1, bit2, 2); 00053 IRSensor irSensor3(distance, bit0, bit1, bit2, 3); 00054 IRSensor irSensor4(distance, bit0, bit1, bit2, 4); 00055 IRSensor irSensor5(distance, bit0, bit1, bit2, 5); 00056 00057 // create robot controller objects 00058 00059 Controller controller(pwmLeft, pwmRight, counterLeft, counterRight); 00060 StateMachine stateMachine(controller, enableMotorDriver, led0, led1, led2, led3, led4, led5, button, irSensor0, irSensor1, irSensor2, irSensor3, irSensor4, irSensor5, led); 00061 00062 while (true) { 00063 00064 led = !led; // toggle led 00065 00066 wait(0.2f); // wait for 200 ms 00067 } 00068 } 00069
Generated on Thu Jul 14 2022 09:49:36 by
