2018年5月14日月曜日

Cooperation between micro:bit and MIT App Inventor (No.3)

In the last article (No.2), communication between micro:bit and Android smartphone was done with Bluetooth UART service (serial over Bluetooth). I will also use this UART this time, but I would like to consider a simple example including NFC which is a short range wireless communication other than Bluetooth.

The figure below shows the contents. I prepared a big toy dice. We prepared six NFC tags on which the number of eyes on each side are written, and incorporated them on each surface of the dice. Turn the Android terminal upside down and touch the dice there. Then the number of eyes on the opposite side of the touched surface is read. The number of eyes read is sent to micro:bit by UART communication. Pressing the micro:bit buttonA will make it receive that information and display the number of eyes on the micro:bit LED.



please see also the following youtube:
https://youtu.be/aOb69nweq3c

Using NFC in addition to BLE UART

The Android program was created using MIT App Inventor. After reading NFC tag information (number of eyes of dice), it will send the number of eyes on the opposite side of that face to micro:bit using UART. At the same time, an image corresponding to the number of eyes should be displayed on Android's screen.

Android program (reading NFC tags and sending with UART)

On the micro:bit side, pressing buttonA gets the number of eyes sent from Android, so we just display it on the LED. The function "show_spots_on_dice" is defined with JavaSript as a custom block. In this example, since we received 4 as the number of eyes, the four outer corners of the LED are lit.


micro:bit program to receive the pips of a dice and to display it on the LED board

0 件のコメント:

コメントを投稿