(DA) Internet of Things and Smart Electronics- ELE3006M2122
/
ObjectDetection_LiamCox
First Draft, serial print change based on distance
main.h@17:02676e9bbc73, 2022-02-04 (annotated)
- Committer:
- liam94
- Date:
- Fri Feb 04 18:30:13 2022 +0000
- Revision:
- 17:02676e9bbc73
- Parent:
- 16:af15244242c2
final update to all comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
liam94 | 11:5a895d966a3e | 1 | #ifndef MAIN_H |
liam94 | 11:5a895d966a3e | 2 | #define MAIN_H |
liam94 | 5:98845ccaaacd | 3 | |
liam94 | 8:7e48229d678c | 4 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 5 | * |
liam94 | 8:7e48229d678c | 6 | * @author Liam Cox |
liam94 | 8:7e48229d678c | 7 | * @date January 2022 |
liam94 | 8:7e48229d678c | 8 | * |
liam94 | 8:7e48229d678c | 9 | * @brief This is the header section for my main code, it includes all the inputs, |
liam94 | 8:7e48229d678c | 10 | * outputs and member functions that will be used in the main source code |
liam94 | 8:7e48229d678c | 11 | * file |
liam94 | 8:7e48229d678c | 12 | * |
liam94 | 8:7e48229d678c | 13 | *******************************************************************************/ |
liam94 | 8:7e48229d678c | 14 | |
liam94 | 5:98845ccaaacd | 15 | #include "mbed.h" |
liam94 | 5:98845ccaaacd | 16 | #include "N5110.h" |
liam94 | 8:7e48229d678c | 17 | #include "Joystick.h" |
liam94 | 8:7e48229d678c | 18 | #include "ultrasonic.h" |
liam94 | 14:837945ccd8c0 | 19 | #include "beep.h" |
liam94 | 5:98845ccaaacd | 20 | |
liam94 | 8:7e48229d678c | 21 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 22 | * |
liam94 | 8:7e48229d678c | 23 | * below I have defined the inputs and outputs on the PCB, this includes all the |
liam94 | 15:d8ff594535fc | 24 | * push buttons that have been defined as interrupts, the piezo buzzer defined as |
liam94 | 15:d8ff594535fc | 25 | * a pwm output, the LEDs that have been defined in a Bus output for ease of use, |
liam94 | 15:d8ff594535fc | 26 | * the LCD output pins VCC,SCE,RST,D/C, MOSI,SCLK,LED and the joystick |
liam94 | 15:d8ff594535fc | 27 | * y-coordinate x-coordinate and button. |
liam94 | 8:7e48229d678c | 28 | * |
liam94 | 8:7e48229d678c | 29 | *******************************************************************************/ |
liam94 | 8:7e48229d678c | 30 | |
liam94 | 5:98845ccaaacd | 31 | InterruptIn L(PTB18); |
liam94 | 5:98845ccaaacd | 32 | InterruptIn R(PTB3); |
liam94 | 5:98845ccaaacd | 33 | InterruptIn Start(PTC5); |
liam94 | 5:98845ccaaacd | 34 | InterruptIn Back(PTB19); |
liam94 | 5:98845ccaaacd | 35 | |
liam94 | 14:837945ccd8c0 | 36 | Beep buzzer(PTC10); |
liam94 | 14:837945ccd8c0 | 37 | |
liam94 | 13:cc99df342c7f | 38 | BusOut LEDS(PTA1,PTA2,PTC2,PTC3,PTC4,PTD3); |
liam94 | 5:98845ccaaacd | 39 | |
liam94 | 8:7e48229d678c | 40 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
liam94 | 5:98845ccaaacd | 41 | |
liam94 | 5:98845ccaaacd | 42 | Joystick joystick(PTB10,PTB11,PTC16); |
liam94 | 5:98845ccaaacd | 43 | |
liam94 | 8:7e48229d678c | 44 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 45 | * |
liam94 | 17:02676e9bbc73 | 46 | * below is a list of integars that have been defined, three objects have been |
liam94 | 17:02676e9bbc73 | 47 | * defined that will be used for the comparison to the sensed values later on in |
liam94 | 17:02676e9bbc73 | 48 | * the code. also there is an array of states for the LEDs in the FSM, states have |
liam94 | 17:02676e9bbc73 | 49 | * been defined in binary for ease of use, 0 is LED on, 1 is LED off so only one |
liam94 | 17:02676e9bbc73 | 50 | * LED is on in any state. the distance and flag integars have also been defined |
liam94 | 17:02676e9bbc73 | 51 | * here but given no value, this is because these will be set later in the code. |
liam94 | 8:7e48229d678c | 52 | * |
liam94 | 8:7e48229d678c | 53 | *******************************************************************************/ |
liam94 | 5:98845ccaaacd | 54 | |
liam94 | 16:af15244242c2 | 55 | int glass[] = {180,180,180,180,180,180}; |
liam94 | 16:af15244242c2 | 56 | |
liam94 | 16:af15244242c2 | 57 | int firestick_box[] = {180,500,500,180,500,500}; |
liam94 | 16:af15244242c2 | 58 | |
liam94 | 16:af15244242c2 | 59 | int Disaronno_bottle[] = {170,180,180,170,180,180}; |
liam94 | 9:ada61082bbaa | 60 | |
liam94 | 6:18a4dd77057e | 61 | int fsm[6] = {0b111110, 0b111101, 0b111011, 0b110111, 0b101111, 0b011111}; |
liam94 | 5:98845ccaaacd | 62 | |
liam94 | 15:d8ff594535fc | 63 | int Distance1, Distance2, Distance3, Distance4, Distance5, Distance6; |
liam94 | 15:d8ff594535fc | 64 | |
liam94 | 15:d8ff594535fc | 65 | int Start_flag, Back_flag; |
liam94 | 8:7e48229d678c | 66 | |
liam94 | 17:02676e9bbc73 | 67 | /***************************************************************************//** |
liam94 | 17:02676e9bbc73 | 68 | * |
liam94 | 17:02676e9bbc73 | 69 | * below the member functions that are to be used in the main source code file |
liam94 | 17:02676e9bbc73 | 70 | * have also been defined and the ultrasonice sensor trigger and echo pin have |
liam94 | 17:02676e9bbc73 | 71 | * been defined, it updates every .5 seconds and a timeout after 1 second and call |
liam94 | 17:02676e9bbc73 | 72 | * the function dist when the distance changes. |
liam94 | 17:02676e9bbc73 | 73 | * |
liam94 | 17:02676e9bbc73 | 74 | *******************************************************************************/ |
liam94 | 17:02676e9bbc73 | 75 | |
liam94 | 5:98845ccaaacd | 76 | void init_display(); |
liam94 | 5:98845ccaaacd | 77 | |
liam94 | 5:98845ccaaacd | 78 | void main_menu(); |
liam94 | 5:98845ccaaacd | 79 | |
liam94 | 5:98845ccaaacd | 80 | void sense_object(); |
liam94 | 5:98845ccaaacd | 81 | |
liam94 | 5:98845ccaaacd | 82 | void Start_isr(); |
liam94 | 5:98845ccaaacd | 83 | |
liam94 | 5:98845ccaaacd | 84 | void Back_isr(); |
liam94 | 5:98845ccaaacd | 85 | |
liam94 | 6:18a4dd77057e | 86 | void calibrate_object(); |
liam94 | 6:18a4dd77057e | 87 | |
liam94 | 7:7464fbb0f3e1 | 88 | void dist(int distance); |
liam94 | 7:7464fbb0f3e1 | 89 | |
liam94 | 9:ada61082bbaa | 90 | void object_sense1(); |
liam94 | 9:ada61082bbaa | 91 | |
liam94 | 9:ada61082bbaa | 92 | void object_sense2(); |
liam94 | 9:ada61082bbaa | 93 | |
liam94 | 9:ada61082bbaa | 94 | void object_sense3(); |
liam94 | 9:ada61082bbaa | 95 | |
liam94 | 9:ada61082bbaa | 96 | void object_sense4(); |
liam94 | 9:ada61082bbaa | 97 | |
liam94 | 9:ada61082bbaa | 98 | void object_sense5(); |
liam94 | 9:ada61082bbaa | 99 | |
liam94 | 9:ada61082bbaa | 100 | void object_sense6(); |
liam94 | 9:ada61082bbaa | 101 | |
liam94 | 10:be53044119d1 | 102 | void object_detection(); |
liam94 | 10:be53044119d1 | 103 | |
liam94 | 16:af15244242c2 | 104 | ultrasonic Ultrasonic(PTD0, PTC12, .5, 1, &dist); |
liam94 | 8:7e48229d678c | 105 | |
liam94 | 15:d8ff594535fc | 106 | //int sense; |
liam94 | 9:ada61082bbaa | 107 | |
liam94 | 11:5a895d966a3e | 108 | |
liam94 | 8:7e48229d678c | 109 | #endif |