Enable a Device to Interact with a Sprite on mBlock 5

On the Make a Sprite Move and Add Sounds and Costumes pages, we describe how to program a sprite, and on the Program a Device page, we describe how to program a device. 

This page describe how to use your hardware device to control a sprite or control your device through a sprite.

Example: interaction between CyberPi and the sprite Panda

mceclip0.png

1. Connect CyberPi to mBlock 5.

For details, see Program a Device. You can use another device and program it in the similar way.

2. Set the coding mode to Live.

3. Program CyberPi.

Set the operation on CyberPi.

mceclip1.png

4. Program Panda.

Set the action of Panda.

mceclip2.png

mceclip0.png

mceclip1.png

mceclip3.png

mceclip4.png

mceclip5.png

6. Program CyberPi.

Set the action of CyberPi.

mceclip6.png

mceclip7.png

mceclip10.png

mceclip11.png

The program is complete. 

When you press button A on CyberPi, Panda moves on the stage on mBlock 5.

Keep pressing button A.

When Panda touches an edge of the stage, it goes to a random position and the LEDs on CyberPi are lit up in red for one second.

Was this article helpful?
2 out of 2 found this helpful

Comments

2 comments
  • Hi, interesting to be able to interact between hardware and computer !

    It works well with CyberPi.

    But is there a way to interact with an Arduino Uno board ??

    1
  • Hi Mickael, this question will be better met on the forum, ask it here:

     

    https://forum.makeblock.com/

     

    Thanks!

    1

Please sign in to leave a comment.