an ultrasonic sensor used as a car sensor
Dependencies: N5110 PowerControl beep mbed sensor
main.cpp File Reference
Program implementation. More...
Go to the source code of this file.
Functions | |
int | main () |
void | buttonPressed () |
when the button is pressed this action is called | |
void | welcomeMessage () |
Print welcome message. | |
void | getDistanceCm () |
gets the distance in cm by dividing 10 read values by 10 | |
void | getDistanceIn () |
gets the distance in inches by dividing 10 read values by 10 | |
void | getDistanceUs () |
gets the distance in us by dividing 10 read values by 10 | |
void | compDist () |
used to compare the distances | |
void | distanceA () |
compares the cases of each distance to set the Led's values and the buzzer |
Detailed Description
Program implementation.
Definition in file main.cpp.
Function Documentation
void buttonPressed | ( | ) |
void compDist | ( | ) |
used to compare the distances
looks for where the range of the reading is to set its conditions
calls this action to show the reading
each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
print formatted data to buffer
if string will fit on display
clears LCD
sets 2 rectangles
prints distance and the reading below it
refreshes LCD screen
compares distances and sets them in their specified range
sets case
sets case
sets case
sets case
sets case
sets case
calls this action to show the reading
each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
print formatted data to buffer
if string will fit on display
clears LCD
sets 2 rectangles
prints distance and the reading below it
refreshes LCD screen
compares distances and sets them in their specified range
sets case
sets case
sets case
sets case
sets case
sets case
calls this action to show the reading
each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
print formatted data to buffer
if string will fit on display
clears LCD
sets 2 rectangles
prints distance and the reading below it
refreshes LCD screen
compares distances and sets them in their specified range
sets case
sets case
sets case
sets case
sets case
sets case
void distanceA | ( | ) |
compares the cases of each distance to set the Led's values and the buzzer
- See also:
- This code was from a library I found
case 1 would have 2 LED's on
- See also:
- This code was from a library I found
case 3 would have 4 LED's on
- See also:
- This code was from a library I found
case 4 would have 5 LED's on
- See also:
- This code was from a library I found
case 5 would have 6 LED's on
- See also:
- This code was from a library I found
void getDistanceCm | ( | ) |
void getDistanceIn | ( | ) |
gets the distance in inches by dividing 10 read values by 10
- Returns:
- the average distance in inches
adds up 10 distances read by the sensor
there is a 70 ms delay between each reading
all of them are added to the sum
the sum is divided by 10 to get the average
void getDistanceUs | ( | ) |
int main | ( | ) |
the Ethernet cable is powered down
the LCD display is initialised when switch is on
the welcome message will appear
event generated on rising edge
sets a variable to change as the pot is changing
sets the brightness to the pot value
compares the distance to set it in a specific range
void welcomeMessage | ( | ) |
Print welcome message.
Shows the welcome message when the LCD is on.
bottom left rectangle is set
bottom right rectangle is set
bottom middle rectangle is set
is set over the bottom rectangles
circle is set on bottom middle box
big middle box is set over everything
top black rectangle is set
left middle black rect is set
middle black rect is set
right middle black rect is set
left bottom black rect is set
middle bottom black rect is set
right bottom black rect is set
rectangle is set over big middle box
left top black rect is set
top black rect is set
right top black rect is set
left bottom black rect is set
middle bottom black rect is set
right bottom black rect is set
rectangle under triangle is set
left line to complete triangle
right line to complete triangle
clears intersecting lines from rectangle
gets the distance after the message
Generated on Mon Jul 25 2022 18:37:11 by 1.7.2