First Draft, serial print change based on distance
Embed:
(wiki syntax)
Show/hide line numbers
main.h
00001 #ifndef MAIN_H 00002 #define MAIN_H 00003 00004 /***************************************************************************//** 00005 * 00006 * @author Liam Cox 00007 * @date January 2022 00008 * 00009 * @brief This is the header section for my main code, it includes all the inputs, 00010 * outputs and member functions that will be used in the main source code 00011 * file 00012 * 00013 *******************************************************************************/ 00014 00015 #include "mbed.h" 00016 #include "N5110.h" 00017 #include "Joystick.h" 00018 #include "ultrasonic.h" 00019 #include "beep.h" 00020 00021 /***************************************************************************//** 00022 * 00023 * below I have defined the inputs and outputs on the PCB, this includes all the 00024 * push buttons that have been defined as interrupts, the piezo buzzer defined as 00025 * a pwm output, the LEDs that have been defined in a Bus output for ease of use, 00026 * the LCD output pins VCC,SCE,RST,D/C, MOSI,SCLK,LED and the joystick 00027 * y-coordinate x-coordinate and button. 00028 * 00029 *******************************************************************************/ 00030 00031 InterruptIn L(PTB18); 00032 InterruptIn R(PTB3); 00033 InterruptIn Start(PTC5); 00034 InterruptIn Back(PTB19); 00035 00036 Beep buzzer(PTC10); 00037 00038 BusOut LEDS(PTA1,PTA2,PTC2,PTC3,PTC4,PTD3); 00039 00040 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 00041 00042 Joystick joystick(PTB10,PTB11,PTC16); 00043 00044 /***************************************************************************//** 00045 * 00046 * below is a list of integars that have been defined, three objects have been 00047 * defined that will be used for the comparison to the sensed values later on in 00048 * the code. also there is an array of states for the LEDs in the FSM, states have 00049 * been defined in binary for ease of use, 0 is LED on, 1 is LED off so only one 00050 * LED is on in any state. the distance and flag integars have also been defined 00051 * here but given no value, this is because these will be set later in the code. 00052 * 00053 *******************************************************************************/ 00054 00055 int glass[] = {180,180,180,180,180,180}; 00056 00057 int firestick_box[] = {180,500,500,180,500,500}; 00058 00059 int Disaronno_bottle[] = {170,180,180,170,180,180}; 00060 00061 int fsm[6] = {0b111110, 0b111101, 0b111011, 0b110111, 0b101111, 0b011111}; 00062 00063 int Distance1, Distance2, Distance3, Distance4, Distance5, Distance6; 00064 00065 int Start_flag, Back_flag; 00066 00067 /***************************************************************************//** 00068 * 00069 * below the member functions that are to be used in the main source code file 00070 * have also been defined and the ultrasonice sensor trigger and echo pin have 00071 * been defined, it updates every .5 seconds and a timeout after 1 second and call 00072 * the function dist when the distance changes. 00073 * 00074 *******************************************************************************/ 00075 00076 void init_display(); 00077 00078 void main_menu(); 00079 00080 void sense_object(); 00081 00082 void Start_isr(); 00083 00084 void Back_isr(); 00085 00086 void calibrate_object(); 00087 00088 void dist(int distance); 00089 00090 void object_sense1(); 00091 00092 void object_sense2(); 00093 00094 void object_sense3(); 00095 00096 void object_sense4(); 00097 00098 void object_sense5(); 00099 00100 void object_sense6(); 00101 00102 void object_detection(); 00103 00104 ultrasonic Ultrasonic(PTD0, PTC12, .5, 1, &dist); 00105 00106 //int sense; 00107 00108 00109 #endif
Generated on Mon Aug 22 2022 16:53:08 by
1.7.2