Project tutorial

Graphical Programming Sonar Project © MIT

In this project, you can build and display a sonar system by using graphical programming software Kittenblock, developed based on Scratch3.0

  • 5,663 views
  • 1 comment
  • 7 respects

Components and supplies

Apps and online services

About this project

Overview

Ever wanted to build a sonar? We have been searching online for Radar or Sonar building tutorial, there are problems come in the way, either we are not familiar with Processing Development Environment(PDE) or the system is hard to build. So we are thinking to make a sonar system which program and completely display in graphical programming software Kittenblock, developed based on Scratch 3.0.

Graphical programming uses drag-and-drop blocks for programming and is very easy to get started with. Graphical blocks can help beginner to avoid loads of typing and syntax, creating a bridge to learn a powerful and commonly used programming language such as C++.

The sonar system consists of a detecter, the ultrasonic sensor, and a small servo motor for rotating the sonar, the main controller is RosBot baseboard, fully compatible with Kittenblock.

Parts

Hardware (can be adapted for your needs):

  • RosBot Baseboard x1
  • Ultrasonic Sensor x1
  • Ultrasonic Sensor Adapter x1
  • 9g Servo x1
  • Dupont wires x6
  • Micro-USB cable x1

You will need a base to support the 9g servo and ultrasonic sensor, in this project we use the KittenBot chassis.

Graphical programming software:

  • KittenBlock v1.27 (Based on Scratch3.0)

Download Here

Step 1: Assemble the Sonar System

First we will need an adapter for servo motor to rotate the ultrasonic sensor. Put tapping screws into the shaft and secure the adapter, attach the adapter on the servo.

Once you fasten the adapter, you will see the ultrasonic sensor and adapter connected like that.

Turn the ultrasonic sensor very gently all the way in one direction, then to the other direction to figure out the sonar rotating degrees, it should be a little bit over 180 degrees.

Step 2: Wiring

In the Kittenblock software, there is a wiring mode, you can organize the wires with ease and learn basic electrical circuit.

Connections for the 9g Micro Servo:

  • VCC to 5V
  • GND to RosBot's GND
  • Signal wire to pin4

Connections for the ultrasonic sensor:

  • VCC to 5V
  • Trig to D2
  • Echo to D3
  • GND to GND

Step 3: Graphical Programming

Before we start coding, let's load the default firmware to the RosBot Baseboard first.

Open Arduino panel and select "Restore > Arduino" to load default firmware into the edit box. Then press "Upload" button, the embedded Arduino IDE in KittenBlock may automatically compile and upload the default firmware.

Coding Flowchart:

So our sonar display algorithms shown as the following flowchart.

First we need to create three variables for later use, which are degree, distance and raw.

Since the Sonar display panel is using pen feature to draw out, we set the pen size to 2 and shade to 100. The degree variable will be altered from '-90' to '90', we initiate the degree to '-90'.

We repeat the drawing process 180 times, each time in the loop rotate the sensor by one degree, use green pen to draw out the frame.

Then we use a digital filter to handle the signal from ultrasonic sensor, this way we can regulate stable filtered values from ultrasonic sensor.

Set the variable distance to the filtered value, use red pen to draw distance within the range of 250 (Radius). In the end of loop, increase the degree by one degree. The block codes end here and the sonar system will rotate for one cycle.

Step 4: Enjoy Your Very Own Sonar

Try this fun project and share with us!

Comments

Similar projects you might like

Graphical Programming Drawing Robot On The Wall

Project tutorial by Team KittenBot

  • 14,446 views
  • 1 comment
  • 52 respects

Graphical Programming Obstacle Avoidance Robot

Project tutorial by Team KittenBot

  • 3,781 views
  • 1 comment
  • 16 respects

ESP8266 Arduino Programming Tutorial

by mialee

  • 8,770 views
  • 0 comments
  • 10 respects

Programming 8x8 LED Matrix

by SAnwandter1

  • 216,634 views
  • 40 comments
  • 202 respects

Programming 4 Digit 7 Segment LED Display

by SAnwandter1

  • 144,527 views
  • 45 comments
  • 109 respects

Arduino Sonar

Project tutorial by Tony ZHANG

  • 92,248 views
  • 36 comments
  • 182 respects
Add projectSign up / Login