Difference between revisions of "Smart Piggy Bank"
(→Start to Program) |
|||
Line 6: | Line 6: | ||
[[File:anywhere_piggy bank.jpg|600px|center]] | [[File:anywhere_piggy bank.jpg|600px|center]] | ||
− | Make a smart piggy bank, which can record the coin number and display it on OLED, and emit | + | Make a smart piggy bank, which can record the coin number and display it on OLED, and emit "ding" sound every time throw a coin into it. |
<br> | <br> | ||
Suitable kit: mCookie302 | Suitable kit: mCookie302 | ||
Line 48: | Line 48: | ||
==Program== | ==Program== | ||
===Required Program Blocks=== | ===Required Program Blocks=== | ||
− | *[[ | + | *[["OLED display-print" program block]] |
− | *[[ | + | *[["If-do" program block]] |
− | *[[ | + | *[["Declare as", "variable assignment" program block]] |
− | *[[ | + | *[["Repeat doing" program block]] |
− | *[[ | + | *[["Println" program block]] |
− | *[[ | + | *[["Calculate" program block]] |
− | *[[ | + | *[["Text" program block]] |
Line 68: | Line 68: | ||
'''The buzzer rings, the number counts, and it is displayed on the screen.''' | '''The buzzer rings, the number counts, and it is displayed on the screen.''' | ||
<br> | <br> | ||
− | The buzzer produce a | + | The buzzer produce a "ding" sound, variable coin adds 1. Pay attention to adjusting the direction of the screen according to the installation direction. Display the value of coin on the OLED. Wait for the distance value of the line finder to be larger than 220 (the coin fell into the bank.). |
[[File:mixly-ctrl-piggy bank-code.jpg|600px|center]] | [[File:mixly-ctrl-piggy bank-code.jpg|600px|center]] | ||
<br> | <br> | ||
Line 74: | Line 74: | ||
'''Test the result''' | '''Test the result''' | ||
<br> | <br> | ||
− | After upload, approach the line finder with a coin, and you can hear a | + | After upload, approach the line finder with a coin, and you can hear a "ding" sound produced by the buzzer, and the number on OLED counts once to the current coin number. |
<br> | <br> | ||
[[File:anywhere_piggy bank.jpg|600px|center]] | [[File:anywhere_piggy bank.jpg|600px|center]] | ||
Line 81: | Line 81: | ||
'''Q: If I take all coins in the bank away, how to reset the record? ''' | '''Q: If I take all coins in the bank away, how to reset the record? ''' | ||
<br> | <br> | ||
− | '''A: Add a touch button. Judge whether the touch button has been pressed with | + | '''A: Add a touch button. Judge whether the touch button has been pressed with "if-do" program block. If it has, reset the variable coin. ''' |
<br> | <br> | ||
<br> | <br> | ||
− | If the | + | If the "reset" button was pressed, the reset program will be executed. The buzzer will produce "ding" sound, and the value of variable coin will change into 0. Display the coin number again. |
[[File:mixly-ctrl-piggy bank-code2.jpg|600px|center]] | [[File:mixly-ctrl-piggy bank-code2.jpg|600px|center]] | ||
Latest revision as of 06:54, 4 November 2016
ContentsOverviewMake a smart piggy bank, which can record the coin number and display it on OLED, and emit "ding" sound every time throw a coin into it.
Module BillModule
Other Equipment
Module SetupSetup
ProgramRequired Program Blocks
Programming ThoughtJudge whether the distance value of the line finder is less than 180. If it is, there was coins thrown in (according to the material of the coins, the judgement value can be adjusted appropriately), the buzzer will produce a ding sound, the coin number will increase 1, and it will be displayed on the screen.Finally wait for the distance of the line finder to be larger than 220. Start to Program Judge if a coin has passed
Technical Specification
Related Cases
FAQ |