# mBot: Discrete Guitar (Gr. 6-8)

## Using the sensors on the mBot to split continuous data, into discrete data, and playing music along the way.

Description

Turn your robot into an instrument!? Is that possible? Well just like frets on a guitar, which split up the strings into notes, we can do the same thing with the ultrasonic sensor on our robot. This is a useful skill that will bring your coding abilities to the next level.

The mBot has sensor data streaming into it, but sometimes it needs to be controlled, and categorized. This is one important reason students are introduced to the difference between discrete and continuous data. In this lesson, students turn their mBot into an instrument, breaking up the continuous sensor data, into discrete notes using if statements and threshold values.

Objectives

Students will be able to understand:

• Discrete and Continuous Data (Lesson Focus)
• Loops
• Nested If Statements
• Sensor Inputs
• Intro to Syntactical Programming

Lesson Procedure

• Class 1 - Intro to mBlock, If Statements, and the Ultrasonic Sensor (~30min)
• Class 2 - Nested If Statements and Making Music (~20min)
• Class 3 - Looking Inside the Code (Syntax) (~30min)

# Curriculum Connections Summary

• Ontario - Mathematics - Algebra (Coding)
• Quebec - Mathematics
• Nova Scotia - ICT
• Alberta - ICT/CTF
• British Columbia - Mathematics & ADST
• Newfoundland & Labrador - Mathematics
• Yukon Territories - Follow's B.C.'s Curriculum
• Northwest Territories - Follows Alberta's Curriculum
• Nunavut - Follows Alberta's Curriculum

Robots and Accessories

• mBots

Supplies

• Laptops
• Makeblock Software
• Cardboard/Paper and Tape (optional for instrument customization)

## Find Out More

mBot

mbot is the best of both worlds, transitioning students from Scratch Blocks to Text Code