- If you don't already have a flowchart for this project, click
here to download one.
- Click here to download a partial program file.
- Add code to the program so that it will work as described
below:
- When you start up the program and press the button, the
LEDs will flash three times.
- When you press the button again, the LEDs will flash five
times.
Here are notes about the flowchart:
- PBd( ) is function
that returns a 1 if the button is pressed, and a 0 if it is not
pressed. This function debounces the signal from the button before
deciding whether to return a 1 or a 0.
- Blinks( ) is a
function that you write. Whatever number is sent to it determines the
number of blinks.
- The flowchart for the Blinks(
) function is on the right-hand side of the flowchart page.
- In the main program, the Blinks(
) function is called two times.
- When the program has just been started, the computer will
loop at the first flowchart decision block (a while loop), waiting for the
pushbutton to be pressed.
- Once the button is pressed, the main program will call the Blinks( ) function, sending a 3 to
it.
- Then, the computer will loop at the second decision block
(another while loop), waiting
for the button to be pressed a second time.
- Once the button is pressed (for the second time), the main
program will call the Blinks( )
function, sending a 5 to it.
- Use a for loop for
the decision block in the flowchart for the Blinks( ) function.
- Don't forget to declare
all your variables and to create
a funciton prototype.
|