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.
Fork of ROME2_P3 by
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 "IMU.h" 00012 #include "Controller.h" 00013 #include "StateMachine.h" 00014 #include "SerialServer.h" 00015 00016 int main() { 00017 00018 // create miscellaneous periphery objects 00019 00020 DigitalOut led(LED1); 00021 DigitalIn button(USER_BUTTON); 00022 00023 DigitalOut led0(PC_8); 00024 DigitalOut led1(PC_6); 00025 DigitalOut led2(PB_12); 00026 DigitalOut led3(PA_7); 00027 DigitalOut led4(PC_0); 00028 DigitalOut led5(PC_9); 00029 00030 // create motor control objects 00031 00032 DigitalOut enableMotorDriver(PB_2); 00033 DigitalIn motorDriverFault(PB_14); 00034 DigitalIn motorDriverWarning(PB_15); 00035 00036 PwmOut pwmLeft(PA_8); 00037 PwmOut pwmRight(PA_9); 00038 00039 EncoderCounter counterLeft(PB_6, PB_7); 00040 EncoderCounter counterRight(PA_6, PC_7); 00041 00042 // create distance sensor objects 00043 00044 DigitalOut enableIRSensors(PC_1); 00045 enableIRSensors = 1; 00046 00047 AnalogIn distance(PB_1); 00048 DigitalOut bit0(PH_1); 00049 DigitalOut bit1(PC_2); 00050 DigitalOut bit2(PC_3); 00051 00052 IRSensor irSensor0(distance, bit0, bit1, bit2, 0); 00053 IRSensor irSensor1(distance, bit0, bit1, bit2, 1); 00054 IRSensor irSensor2(distance, bit0, bit1, bit2, 2); 00055 IRSensor irSensor3(distance, bit0, bit1, bit2, 3); 00056 IRSensor irSensor4(distance, bit0, bit1, bit2, 4); 00057 IRSensor irSensor5(distance, bit0, bit1, bit2, 5); 00058 00059 // create robot controller objects 00060 00061 Controller controller(pwmLeft, pwmRight, counterLeft, counterRight); 00062 StateMachine stateMachine(controller, enableMotorDriver, led0, led1, led2, led3, led4, led5, button, irSensor0, irSensor1, irSensor2, irSensor3, irSensor4, irSensor5); 00063 00064 while (true) { 00065 00066 led = !led; // toggle led 00067 00068 wait(0.2f); // wait for 200 ms 00069 } 00070 } 00071
Generated on Thu Jul 14 2022 22:37:02 by
