Ultrasonic sensor project. Displays readings on LCD. Reverse parking sensor.
Dependencies: N5110 SRF02 beep mbed
Diff: main.cpp
- Revision:
- 3:3dc3d2da405a
- Parent:
- 2:f48fe83aecca
- Child:
- 4:e485ad337011
--- a/main.cpp Thu May 07 15:40:58 2015 +0000 +++ b/main.cpp Thu May 07 15:49:17 2015 +0000 @@ -51,18 +51,25 @@ int brightness = light; // init the brightness to 1 int state = centimeter; // inie the state to 1 -// Interrupt Service Routine +/** +@Interrupt Service Routine +*/ void buttonPressed() { buttonFlag = 1; // set S3 flag } - +/** +@Interrupt Service Routine +*/ void buttonPressed2() { state = !state; // change the state when press the button } - +/** +read ten times results from the sensor in 1 second +calculate the average +*/ float getAverage()// calculate the average distance { int sum = 0; // sum = 0 @@ -84,10 +91,10 @@ } /** -Add up two variable -@param a - integer to add -@param b - integer to add -@use the a & b to dispaly the distance in inches and centimeter +RTC is used +The button S2 is used to change the unit +The button S3 is used to change the brightness +Display the result and time on the LCD */ int main() {