fbpx
Magicblocks Lesson 10: Ultrasonic Distance Sensor
Magicblocks Project

Use Ultrasonic Sensor with Magicbit [Magicblocks]

This tutorial will teach you to use the Ultrasonic Sensor with your Magicbit using Magicblocks.

Components Required

Story

Hello and Welcome, This short tutorial will teach you to use an Ultrasonic sensor with your Magicbit using Magicblocks.

There are 1 main method of achieving this goal;

  • By using Dashboard Gauge.

First, log into your Magicblocks account,

Magicblocks is easy visual programming software for the program of your Magicbit. Anyone can program their microcontroller by using magicblocks.io and there is no need for programming knowledge. You can sign up for free.

Start and Open the Playground.

Next, make sure your Magicbit is connected to the internet and plugged in, and also linked to your account through Device Manager.

All Done? Then scroll down to Method 1

Setting Up the Inject Block

1. Drag & drop the Inject block from the input nodes section on the left of the screen to the Flow.

2. Set the Payload as timestamp and set the Repeat to the interval.

Setting Up the Ultrasonic Block

1. Drag & drop the Ultrasonic block from the input nodes section on the left of the screen to the Flow.

2. Double-click on the Ultrasonic block and select your unique Device id from the drop-down menu.

 

3. Connect the Ultrasonic sensor in the below configuration to the ‘PIN 33’ or ‘PIN 32’ (In this tutorial PIN 32 will be used).

Ultrasonic Sensor with Magicbit pic 6

Ultrasonic Sensor with Magicbit pic 7

Ultrasonic Sensor with Magicbit pic 8

Setup the Gauge Block

1. Drag & drop the Gauge block from the dashboard nodes section to the Flow.

2. Change the Range of the Guage to 0 – 150.

[Optional] Import Already Setup Nodes

If you had trouble setting up nodes, you can use the import feature in Magicblocks to get the nodes which has been already setup.

  • First copy this code to your clipboard;
[{"id":"a34bfbf2.906628","type":"inject","z":"d2db2033.c2624","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":2700,"wires":[["be96e7d5.2c9668"]]},{"id":"be96e7d5.2c9668","type":"US","z":"d2db2033.c2624","name":"","epId":"","x":480,"y":2720,"wires":[["328702ee.9f182e"]]},{"id":"328702ee.9f182e","type":"ui_gauge","z":"d2db2033.c2624","name":"","group":"6e81dbf8.7888c4","order":0,"width":0,"height":0,"gtype":"gage","title":"Ultrasonic","label":"units","format":"{{value}}","min":0,"max":"150","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":670,"y":2740,"wires":[]},{"id":"6e81dbf8.7888c4","type":"ui_group","z":"","name":"Ultrasonic Sensor Module","tab":"1e4dddd7.63fc02","order":1,"disp":true,"width":"11","collapse":false},{"id":"1e4dddd7.63fc02","type":"ui_tab","z":"","name":"MagicbitWorkshop","icon":"dashboard","order":1}]
  • Click on the options menu on the top right-hand corner of the screen.
  • Next hover your cursor over the Import sub-menu.
  • Then click on Clipboard and paste the code on your clipboard to the text field
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device id on the Ultrasonic node properties.

Finally Deploying the Blocks

  • Make sure all the blocks are connected.
  • Click on Deploy button on the top right-hand corner of the screen.
  • After deploying go to the dashboard ui by clicking the link to dashboard URL on the top right-hand corner of the screen.

  • Interact with the Ultrasonic Sensor to display the change in the Dashboard Gauge.

Ultrasonic Sensor with Magicbit pic 17

Troubleshooting

  • Check whether your Magicbit is connected to the internet.
  • Check whether the correct PINs is used (e.g., ‘PIN 32’ or ‘PIN 33’).

If you need help or couldn’t understand a step be sure to check out our YouTube video by clicking here: Youtube Video

Related Posts
Leave a Reply