提问

#楼主# 2018-1-16

跳转到指定楼层

Micro:bit is an educational product put forward by British Broadcasting Corporation (BBC), which aims to help young people to learn basic programming knowledge.
BBC micro:bit has rich board carrier resources such as button, 5*5 LED dot matrix, gyro, Bluetooth module, etc.. It is portable with only half size of a credit card. Maybe it is for keeping board size small, all IO ports on it do not lead to pins like Arduino . Today we are going to show you a small case to connect all pins on micro:bits with a breakout board.


(Picture 1)
In the following case, we will use micro:bit( breakout board connected) to produce a raining alarm module.
Requirement
When micro:bit senses raining,it will alarm with light and sound.
Materials
Micro:bit                  ×1
Breakout Board            ×1
Raining Sensor Module     ×1
Passive Buzzer Module     ×1
LED Module               ×1
Dupont Cable              ×3

(Picture 2)
IO Connection:
P0 connect to passive buzzer module;
P1 connect to raining sensor module;
P2 connect to LED module.
Note:Here, “P” stands for Pin.
You can refer to the following picture for IO connection:

(Picture 3)
Note: The bottom base of pins on micro:bit breakout board has 3 different colors. Black stand for GND, red for VCC, yellow for signal. These colors are completely relative to the color of dupont cable. You can connect cables according to the relative color.
Programming:
After we completed cable connection, click this link: https://makecode.microbit.org/ to open programming interface. We are going to do programming with Block method.
Here we have to note that the output of raining sensor module is analog signal and its correspond value read out by micro:bit is 0-1023.(In this case, 0 for no rain, 1023 for pour rain. Bigger value stands for heavier rain)  Now we set the threshold value as 200. If the value on P1 port tested beyond 200, then it is raining and we can see a sign of umbrella on LED screen of micro:bit. At the same time, buzzer will alarm with music. You can refer to the following picture (picture 4) for how to set threshold value.

(Picture 4)
As for the whole program, you can refer to the following picture:

(Picture 5)
After we download the code to micro:bits, it will start to run the program automatically. Now pour some water on the raining sensor module to analogue raining effect. Let’s do it and take a look!
You can download the HEX file for this case here:
Question
If we want to divide raining to several levels like small rain, middle rain and pour rain and show it with different light and sound, then how to program? Your further discussion is welcomed!



For more details, you can refer to our User Guide.


https://www.elecfreaks.com/8855.html
转播转播 分享淘帖
回复

使用道具

成为第一个回答人

B Color Link Quote Code Smilies
Archiver|手机版|小黑屋|MakerTime 创客时代  
Powered by Discuz! X3.3  © 2001-2017 Comsenz Inc.