![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
First Draft, serial print change based on distance
main.h
- Committer:
- liam94
- Date:
- 2022-01-28
- Revision:
- 8:7e48229d678c
- Parent:
- 7:7464fbb0f3e1
- Child:
- 9:ada61082bbaa
File content as of revision 8:7e48229d678c:
#ifndef main_H #define main_H /***************************************************************************//** * * @author Liam Cox * @date January 2022 * * @brief This is the header section for my main code, it includes all the inputs, * outputs and member functions that will be used in the main source code * file * *******************************************************************************/ #include "mbed.h" #include "N5110.h" #include "Joystick.h" #include "ultrasonic.h" /***************************************************************************//** * * below I have defined the inputs and outputs on the PCB, this includes all the * push buttons that have been defined as interrupts, the LEDs that have been * defined in a Bus output for ease of use, the LCD output pins VCC,SCE,RST,D/C, * MOSI,SCLK,LED and the joystick y-coordinate x-coordinate and button. * *******************************************************************************/ InterruptIn L(PTB18); InterruptIn R(PTB3); InterruptIn Start(PTC5); InterruptIn Back(PTB19); BusOut output(PTA1,PTA2,PTC2,PTC3,PTC4,PTD3); N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Joystick joystick(PTB10,PTB11,PTC16); /***************************************************************************//** * * below is array of states for the LEDs in the FSM, states have been defined in * binary for ease of use, 0 is LED on, 1 is LED off so only one LED is on in any * state. the member functions that are to be used in the main source code file * have also been defined and the ultrasonice sensor trigger and echo pin have * been defined, it updates every .5 seconds and a timeout after 1 second and call * the function dist when the distance changes. * *******************************************************************************/ int fsm[6] = {0b111110, 0b111101, 0b111011, 0b110111, 0b101111, 0b011111}; volatile int Start_flag, Back_flag; void init_display(); void main_menu(); void sense_object(); void Start_isr(); void Back_isr(); void calibrate_object(); void dist(int distance); ultrasonic mu(PTD0, PTC12, .5, 1, &dist); #endif