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: N5110 PowerControl SRF02 beep mbed
main.h
00001 /** 00002 @file main.h 00003 @brief Header file containing functions prototypes, defines and global variables. 00004 @brief Reverse Parking Sensor 00005 @author Andreas Konstantinou 00006 @date April 2015 00007 */ 00008 00009 #ifndef MAIN_H 00010 #define MAIN_H 00011 #include "mbed.h" 00012 #include "N5110.h" 00013 #include "SRF02.h" 00014 #include "beep.h" 00015 #include "PowerControl/PowerControl.h" 00016 #include "PowerControl/EthernetPowerControl.h" 00017 00018 #define USR_POWERDOWN (0x140) 00019 00020 /** 00021 @namespace srf02 00022 @brief ultrasonic distance sensor connects to I2C pins SDA and SCL 00023 */ 00024 SRF02 srf02(p28,p27); 00025 00026 00027 /** 00028 @namespace leds 00029 @brief The four LEDs on mbed 00030 */ 00031 BusOut leds(LED4, LED3, LED2, LED1); 00032 00033 /** 00034 @namespace lcd 00035 @brief NOKIA 5110 LCD display 00036 */ 00037 N5110 lcd(p7,p8, p9, p10,p11, p13,p26); //vcc,sce,rst,dc,mosi,clk,led 00038 /** 00039 @namespace buzzer 00040 @brief a piezo buzzer connected to PWM pin 00041 */ 00042 Beep buzzer(p21); 00043 00044 /** 00045 @namespace led_red 00046 @brief Red led connected to PWM pin for brightness 00047 */ 00048 DigitalOut led_red(p24); 00049 00050 /** 00051 @namespace led_yellow 00052 @brief Yellowonnected to PWM pin for brightness 00053 */ 00054 DigitalOut led_yellow(p23); 00055 00056 /** 00057 @namespace led_green 00058 @brief Green led connected to PWM pin for brightness 00059 */ 00060 DigitalOut led_green(p22); 00061 00062 /** 00063 @namespace ain2 00064 @brief Analog input for the potentiometer to control the frequency of the buzzer 00065 */ 00066 AnalogIn ain2(p20); 00067 00068 /** 00069 @namespace ain1 00070 @brief Analog input for the potentiometer to control the brightness of the lcd 00071 */ 00072 AnalogIn ain1(p19); 00073 00074 /** 00075 @namespace button_1 00076 @brief Set button_1 to be interrupt, coonected to GPIO 00077 */ 00078 InterruptIn button_1(p17); 00079 00080 /** 00081 @namespace button_2 00082 @brief set button_2 to be interrupt, coonected to GPIO 00083 */ 00084 InterruptIn button_2(p18); 00085 00086 /** 00087 @namespace button_3 00088 @brief set button_3 to be interrupt, coonected to GPIO 00089 */ 00090 00091 InterruptIn button_3(p16); 00092 00093 /** 00094 @namespace button_4 00095 @brief set button_4 to be interrupt, coonected to GPIO 00096 */ 00097 InterruptIn button_4(p15); 00098 00099 /** 00100 @namespace timer_red 00101 @brief ticker object used to control the time of red LED 00102 */ 00103 Ticker timer_red; 00104 00105 /** 00106 @namespace timer_yellow 00107 @brief ticker object used to control the time of yellow LED 00108 */ 00109 Ticker timer_yellow; 00110 00111 /** 00112 @namespace timer_green 00113 @brief ticker object used to control the time of green LED 00114 */ 00115 Ticker timer_green; 00116 00117 /** Get Avegare distance 00118 * 00119 * This function gets the avegare distance of 5 values of the sensor 00120 */ 00121 void Get_Average(); 00122 00123 /** Timer Expired red led 00124 * 00125 * This function sets the flag of the red led to high 00126 */ 00127 void timerExpired_red(); 00128 00129 /** Button1 Pressed 00130 * 00131 * This function sets the flag of button 1 to high 00132 */ 00133 void button1_Pressed(); 00134 00135 /** Button2 Pressed 00136 * 00137 * This function sets the flag of button 2 to high 00138 */ 00139 void button2_Pressed(); 00140 00141 /** Button3 Pressed 00142 * 00143 * This function sets the flag of button 3 to high 00144 */ 00145 void button3_Pressed(); 00146 00147 /** Button4 Pressed 00148 * 00149 * This function sets the flag of button 4 to high 00150 */ 00151 void button4_Pressed(); 00152 00153 /** Timer Expired yellow led 00154 * 00155 * This function sets the flag of the yellow led to high 00156 */ 00157 void timerExpired_yellow(); 00158 00159 /** Timer Expired green led 00160 * 00161 * This function sets the flag of the green led to high 00162 */ 00163 void timerExpired_green(); 00164 00165 /** Check states of the buttons 00166 * 00167 * This function checks the status between the buttons 2, 3, and 4 and based on the status of each one then executes the appropiate process 00168 */ 00169 void ButtonsOperation(); 00170 00171 /** Check state of button 1 00172 * 00173 * This function checks the state of the button 1. if button1 is pressed then 00174 * the leds and buzzer start blinking and making sound,repsectively, based on the measurements of the sensor 00175 */ 00176 void buttonOperation_1(); 00177 00178 /** Check state of button 2 00179 * 00180 * This functions checks the status of the button 2. if it is pressed then converts 00181 * the units of the sensor's measurements from meters to centimeters and displays them on the lcd 00182 */ 00183 void buttonOperation_2(); 00184 00185 /** Check state of button 3 00186 * 00187 * This functions checks the status of the button 3. if it is pressed then a new pattern is showed in the lcd 00188 * and displays the measured distance. 00189 */ 00190 void buttonOperation_3(); 00191 00192 /** Check state of button 4 00193 * 00194 * This functions checks the status of the button 4. if it is pressed then 00195 * a new pattern is displayed on lcd and displays the sensor's measurements 00196 */ 00197 void buttonOperation_4(); 00198 00199 /** Print Current Time and Date 00200 * 00201 * This function sets the current time and date and prints them on the dispaly 00202 */ 00203 void Print_Time_Date(); 00204 00205 int timerflag_red = 0; /*!< timer flag red LED set in ISR */ 00206 int timerflag_yellow = 0;/*!< timer flag yellow LED set in ISR */ 00207 int timerflag_green = 0;/*!< timer flag green LED set in ISR */ 00208 int setTimeFlag = 0;/*!< time flag set in ISR */ 00209 int button1_flag =0; /*!< button 1 flag set in ISR */ 00210 int button2_flag =0;/*!< button 2 flag set in ISR */ 00211 int button3_flag =0;/*!< button 3 flag set in ISR */ 00212 int button4_flag =0;/*!< button 4 flag set in ISR */ 00213 char buffer [5]; /*!< buffer used to display characters on lcd, each character is 6 pixels wide, screen is 84 pixels (84/6 = 14maximum)*/ 00214 float a1 ;/*!< a1 used to control the brightness of the LED background display by getting the value of the potentiometer1 */ 00215 float a2 ;/*!< a2 used to control the frequency of the buzzer by getting the value of the potentiometer2*/ 00216 float distance =0;/*!<this global variable used to get the average of 5 values of sensor */ 00217 float Distance_Array [5]; /*!< Distance_Array used to store 5 values of the sensor*/ 00218 00219 #endif
Generated on Wed Jul 13 2022 10:08:09 by
1.7.2