Difference between revisions of "Electronic Stopwatch"
(Created page with "{| style="width: 1000px;" |- | ==Overview== 600px|center Make a stopwatch which can time accurately, with one touch button controlling to sta...") |
|||
Line 45: | Line 45: | ||
==Program== | ==Program== | ||
===Required Program Blocks=== | ===Required Program Blocks=== | ||
− | *[[ | + | *[["OLED display-print" program block]] |
− | *[[ | + | *[["Touch button" program block]] |
− | *[[ | + | *[["Declare as", "variable assignment" program block]] |
− | *[[ | + | *[["Repeat doing" program block]] |
− | *[[ | + | *[["Time out begin" program block]] |
− | *[[ | + | *[["Duration" program block]] |
− | *[[ | + | *[["Calculate" program block]] |
− | *[[ | + | *[["Join" program block]] |
Line 64: | Line 64: | ||
Use variable to save the second number to display(in form of float). | Use variable to save the second number to display(in form of float). | ||
Use variable s_timer to save the millisecond number read from the timer (in form of integer). | Use variable s_timer to save the millisecond number read from the timer (in form of integer). | ||
− | Wait for the | + | Wait for the "start" button to be pressed. |
Timer1 starts to time. | Timer1 starts to time. | ||
[[File:mixly-ctrl-Stopwatch-code.jpg|600px|center]] | [[File:mixly-ctrl-Stopwatch-code.jpg|600px|center]] | ||
Line 70: | Line 70: | ||
'''When the touch button 4 is free, repeat executing.''' | '''When the touch button 4 is free, repeat executing.''' | ||
<br> | <br> | ||
− | Repeat executing before the | + | Repeat executing before the "stop" button is pressed. |
Save the value of timer1 into s_timer. | Save the value of timer1 into s_timer. | ||
Divide s_timer by10(remove the last number, namely the 0.001). | Divide s_timer by10(remove the last number, namely the 0.001). | ||
Save s_timer into s. | Save s_timer into s. | ||
Divide s by 100(move the tenth and the percentile to the right of the decimal point). | Divide s by 100(move the tenth and the percentile to the right of the decimal point). | ||
− | Display it in form of | + | Display it in form of "s: second" on OLED. |
[[File:mixly-ctrl-Stopwatch-code1.jpg|600px|center]] | [[File:mixly-ctrl-Stopwatch-code1.jpg|600px|center]] | ||
<br> | <br> | ||
Line 81: | Line 81: | ||
'''Test the result''' | '''Test the result''' | ||
<br> | <br> | ||
− | After upload the program, press the touch button of pin 6 to start timing, and then you can see the time changing on OLED; press the touch button of pin 4, then the timing ends, the time | + | After upload the program, press the touch button of pin 6 to start timing, and then you can see the time changing on OLED; press the touch button of pin 4, then the timing ends, the time won't change any longer; press the touch button of pin 6 again, it will start another time. |
<br> | <br> | ||
[[File:anywhere_Stopwatch.jpg|600px|center]] | [[File:anywhere_Stopwatch.jpg|600px|center]] | ||
Line 93: | Line 93: | ||
Add these behind all programs. | Add these behind all programs. | ||
<br> | <br> | ||
− | Wait for the | + | Wait for the "reset" button to be pressed (after the end of timing, the start starts to serve as reset button). |
− | Wait for the | + | Wait for the "reset" button to be released. |
Set the value of s to 0. | Set the value of s to 0. | ||
Display the second number after reset on OLED. | Display the second number after reset on OLED. |
Latest revision as of 08:52, 4 November 2016
ContentsOverviewMake a stopwatch which can time accurately, with one touch button controlling to start timing, and another controlling to stop timing, and display the time on OLED at the same time.
Module BillModule
Other Equipment
Module SetupSetup
ProgramRequired Program Blocks
Programming ThoughtWhen the start is pressed, it begins to time. Not until the stop button is pressed are the calculating time and display programs executed repeatedly. When the stop button is pressed, stop timing, the current time is kept on the screen. Start to ProgramDeclare a variable, wait for the touch button to be pressed, and then start to time.
Technical Specification
Related Cases
FAQ |