A Day in the Life CTE Enrichment Grades 3-5 mblock Programs Using the Sensors

Similar documents
A Day in the Life CTE Enrichment Grades 3-5 mblock Robotics - Simple Programs

Some prior experience with building programs in Scratch is assumed. You can find some introductory materials here:

Your EdVenture into Robotics 10 Lesson plans

RoboCup Sumo Workshop. Margaux Edwards July 2018

RGB Line Follower. 1. Basic knowledge of RGB line follower

UNIT1. Keywords page 13-14

Agent-based/Robotics Programming Lab II

TETRIX PULSE Workshop Guide

Two Hour Robot. Lets build a Robot.

Introduction to Robotics Rubrics

Robot Programming Manual

Lets start learning how Wink s bottom sensors work. He can use these sensors to see lines and measure when the surface he is driving on has changed.

Lab book. Exploring Robotics (CORC3303)

e d u c a t i o n Detect Dark Line Objectives Connect Teacher s Notes

Revision for Grade 7 in Unit #1&3

Programming I (mblock)

Ev3 Robotics Programming 101

Scratch for Beginners Workbook

Robot Olympics: Programming Robots to Perform Tasks in the Real World

Programming 2 Servos. Learn to connect and write code to control two servos.

Robotics using Lego Mindstorms EV3 (Intermediate)

Part II: Number Guessing Game Part 2. Lab Guessing Game version 2.0

Competitive VEX Robot Designer. Terminal Objective 1.4: program and operate the Tumbler

Where C= circumference, π = 3.14, and D = diameter EV3 Distance. Developed by Joanna M. Skluzacek Wisconsin 4-H 2016 Page 1

Today s Menu. Near Infrared Sensors

The light sensor, rotation sensor, and motors may all be monitored using the view function on the RCX.

Line Detection. Duration Minutes. Di culty Intermediate. Learning Objectives Students will:

Welcome to. NXT Basics. Presenter: Wael Hajj Ali With assistance of: Ammar Shehadeh - Souhaib Alzanki - Samer Abuthaher

Session 11 Introduction to Robotics and Programming mbot. >_ {Code4Loop}; Roochir Purani

Starting from LEARNER NOTES edited version. An Introduction to Computing Science by Jeremy Scott

I.1 Smart Machines. Unit Overview:

DUBAI TECH & DIGITAL WINTER CAMP

A - Debris on the Track

A - Debris on the Track

Robotics Workshop. for Parents and Teachers. September 27, 2014 Wichita State University College of Engineering. Karen Reynolds

ADVANCED EV3 PROGRAMMING LESSON. Proportional Control. By Sanjay and Arvind Seshan

Learn about the RoboMind programming environment

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

A - Debris on the Track

understanding sensors

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Kinect2Scratch Workbook

For more add-on packs and building instructions, please visit:

Part of: Inquiry Science with Dartmouth

Introduction to programming with Fable

Lesson 3: Arduino. Goals

Robotic Programming. Skills Checklist

Capstone Python Project Features

The Robot Olympics: A competition for Tribot s and their humans

GE423 Laboratory Assignment 6 Robot Sensors and Wall-Following

In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

An Introduction to Programming using the NXT Robot:

LEGO Mindstorms Class: Lesson 1

EV3 Advanced Topics for FLL

1-11. Mini Sumo Bot. Building Instructions. Fun Projects for your LEGO MINDSTORMS NXT! Home Projects Help Contacts. Building: Program:

Arduino Lesson 1. Blink. Created by Simon Monk

Crowtail Start Kit for micro:bit User Guide

Module. Introduction to Scratch

Lesson 13. The Big Idea: Lesson 13: Infrared Transmitters

Create Your Own World

Chapter 14. using data wires

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

Devastator Tank Mobile Platform with Edison SKU:ROB0125

Copyright 2017 MakeUseOf. All Rights Reserved.

MESA Cyber Robot Challenge: Robot Controller Guide

Robots in Town Autonomous Challenge. Overview. Challenge. Activity. Difficulty. Materials Needed. Class Time. Grade Level. Objectives.

1. Controlling the DC Motors

Unit 5: What s in a List

FABO ACADEMY X ELECTRONIC DESIGN

OZOBLOCKLY BASIC TRAINING LESSON 1 SHAPE TRACER 1

EQ-ROBO Programming : bomb Remover Robot

Introducing Scratch Game development does not have to be difficult or expensive. The Lifelong Kindergarten Lab at Massachusetts Institute

Line-Follower Challenge

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

Pong Game. Intermediate. LPo v1

Automatic Headlights

Programming with Scratch

RUNNYMEDE COLLEGE & TECHTALENTS

Assessment. Self Assessment. Teacher Assessment. Date Learning Objective(s) Achievement or. NC Level: Game Control Student Booklet P a g e 1

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

EdPy app documentation

Objective of the lesson

Morse Code Autonomous Challenge. Overview. Challenge. Activity. Difficulty. Materials Needed. Class Time. Grade Level. Learning Focus.

VOICE CONTROLLED ROBOT WITH REAL TIME BARRIER DETECTION AND AVERTING

INTRODUCTION OF SOME APPROACHES FOR EDUCATIONS OF ROBOT DESIGN AND MANUFACTURING

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

Memory. Introduction. Scratch. In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

Pre-Activity Quiz. 2 feet forward in a straight line? 1. What is a design challenge? 2. How do you program a robot to move

Boe-Bot robot manual

Emergent Behavior Robot

Programming a Servo. Servo. Red Wire. Black Wire. White Wire

Princess & Dragon Version 2

Unit 4: Robot Chassis Construction

Hardware Implementation of an Explorer Bot Using XBEE & GSM Technology

Devantech SRF04 Ultra-Sonic Ranger Finder Cornerstone Electronics Technology and Robotics II

Sten BOT Robot Kit 1 Stensat Group LLC, Copyright 2016

Voice Guided Military Robot for Defence Application

- Introduction - Minecraft Pi Edition. - Introduction - What you will need. - Introduction - Running Minecraft

CS1301 Individual Homework 5 Olympics Due Monday March 7 th, 2016 before 11:55pm Out of 100 Points

Medb ot. Medbot. Learn about robot behaviors as you transport medicine in a hospital with Medbot!

Transcription:

Activity 1 - Reading Sensors A Day in the Life CTE Enrichment Grades 3-5 mblock Programs Using the Sensors Computer Science Unit This tutorial teaches how to read values from sensors in the mblock IDE. There are also tutorials which specifically focus on how to use the Makeblock sensors, for example the light sensor, the ultrasonic sensor and the line follower sensor. The easiest way to find out what value a sensor is giving is to have a Sprite (panda by default) say it. In the Looks Scripts, there is a say block: Of course, if we ask the panda to say Hello!, the panda is going to say Hello!. Fortunately, we can replace this text with the name of whatever sensor we wish to read. This is for the ultrasonic sensor: The line follower sensor: And the on-board light sensor: For the plug-in sensors, you have to make sure the port selected is the same port as the port you have plugged your sensor into. Now, you can click this block and it will tell you the value of the sensor. To make it continually update, you can put this block in a forever loop:

Computer Science Unit Challenge: 1. Can you find a way to display the values of different sensors at the same time? 2. Can you find out the range of possible values for all the sensors? Construct Your Dreams!

Activity 2 - The Light Sensor Computer Science Unit The light sensor on the mcore board measures light the lighter it is, the higher the value, the darker it is, the lower the value. The range of the light sensor is 0-1023. In this lesson, we are going to program the mbot to play a note if it senses there is a lot of light, and play a different not if it senses there is not a lot of light. For this, we will need the IF block. When we use an IF in programming, there are 3 parts to what we write: 1. The IF itself 2. The condition 3. The code that is run, if the condition is met. So we need to write something like this: If (condition) ---- Do this code The first thing I want to do in this lesson is to play some sound if it is dark. So the condition is it is dark, and the code is play sound : If (it is dark) ---- Play sound. Remember the light sensor returns a value between 0 and 1023, where high numbers represent a light environment. I would say a light sensor reading of less than 500 represents a dark environment. So we can write our code as: If (the value on the light sensor IS LESS THAN 500) ---- Play sound. Writing this in mblock code, we need: 1. An if

Computer Science Unit 2. A condition. The condition in this example is made up of 2 parts. We need the green less than block in the Operators Script: And we need the light sensor block from the Robtots scripts: The condition is the light sensor is less than 500, so we can put the light sensor block in the left side of the less than block and write 500 in the right side. When putting the blue block inside the green block, make sure the left side of the blue block is aligned with the appropriate space of the green block. When the space in the green block has a white outline it is ready to receive the blue block: And when dropped in, it looks like this: 3. Finally, we need some code that will be run if the condition is met: When this code is put together, it looks like this: When this code runs, it will test the condition once and then stop running. If we want it to continue to play music while dark we can add a forever loop. Also, remember to include a descriptive comment:

Computer Science Unit So, what if I wanted to play note C4 in the dark, but note D4 in the light. For this, we could use an if/else Control block: Challenge: 1. Develop a program where the robot runs forward in the light and stops in the dark. 2. Develop a program where the robot dances in the dark (be creative with your dance moves) and rests in the light. 3. Develop a program where the robot goes at different speeds depending on the light the lighter it is, the faster it goes. 4. Develop a program that plays lots of different notes the more light sensed, the higher the note. Construct Your Dreams!

Activity 3 - The Ultrasonic Sensor Computer Science Unit The ultrasonic sensor measures distance. One of the eyes transmits a sound, and the other waits for the echo of the sound to return. From the time this process takes, the distance of the object from the sensor can be calculated. The ultrasonic sensor has a range of 3-400cm. If an object is outside this range, the sensor will return a value of 400. In this lesson, I want to get the robot to go forward until it is close to an object, then turn away from the object and go off in a new direction: Forever: ---- If an object is detected ---- ---- Turn to a new direction ---- Else ---- ---- Go forward And in code, that looks like this: On testing this, I found that the robot wasn t turning enough when it encountered an object, so I added a wait command after the turn. Now I would like to get it to turn in

Computer Science Unit a random direction sometimes left and sometimes right. Fortunately, there is an Operator block that I can use to do just that: The robot can only turn left or right, so I am going to choose a random number between 0 and 1. If the random number is 0, then the robot will turn left. If the random number is 1, then the robot will turn right. So then the turning behavior will look like this: Challenge: 1. Can you put the code above together to make the completed program? 2. Can you write a program that follows an object? So if the object is too close, the robot goes backwards, if the object is far away, it goes forward, and if the object is not near or far, the robot stops. 3. Can you change your program from question 2, to make the robot move at different speeds? Construct Your Dreams!

Activity 4 - The Line Follower Computer Science Unit The line follower has 2 sensors which can detect a white surface (within the range of 1-2cm). It works by emitting IR (InfraRed) light and recording how much is reflected back. If a lot is reflected back, it can be deduced it is close to a white surface. If a little is reflected back, it can be deduced that the surface is black, or the sensor is not near a surface. A light surface reflects a lot of infrared light back to the receiver: A dark surface only reflects a little light back to the receiver: In mblock there are 2 blocks associated with the line follower:

Computer Science Unit The first block will return a number between 0 and 3 based on the following values: The second block will return either true or false. Using the Line Follower block to program: If we want to have our robot follow a black line, we have the following pseudocode: If( line follower = 0) ---- Go forward Else if (line follower = 1) ---- Turn Left Else if(line follower = 2) ---- Turn Right Else if(line follower = 3) ---- Aaargh!! Help!! Where is the line? So let s now put that into mblock code:

Computer Science Unit And it doesn t work the robot often goes off the track. This is because this program is run from the mblock IDE. Remember it takes time for the signals and commands to be sent from the robot to the computer and back again. In this case, that delay interferes with how the robot performs the line following. We need to upload this program onto the board to reduce this delay. Then the program will work. For the mbot, we use the mbot program block, go into Arduino mode and Upload to Arduino : Now the robot successfully follows the line. Using the Line Follower (port)(side)is(black/white) block to program: Using this block: If((Right is black) AND (Left is black)) ---- Go forward Else if((right is white) AND (Left is black)) ---- Turn Left Else ((Right is black) AND (Left is white)) ---- Turn Right

Else ((Right is white) AND (Left is white)) ---- Aaargh!! I m lost AGAIN?!? Computer Science Unit So for this we need an and block to combine the 2 conditional statements: So the final code looks like this: Challenge: 1. The robot moves does not turn smoothly. Why is that? Can you fix it? 2. Can you write a program so the robot moves around a (white) table in a random fashion without falling off? (Remember the line follower sensor detects if light is reflected or not reflected) 3. Can you write a program that follows a line AND avoids objects if an obstacle is detected, the robot should stop the motors and wait for the object to be removed. Construct Your Dreams!

Activity 5 - The Ultrasonic Theremin Computer Science Unit A theremin is a musical instrument that plays notes according to where the musician s hands are. It has been around since about 1929 and this tutorial looks at how to make an mbot Theremin, using the ultrasonic sensor. If an object is less than 10cm away ---- Play a high note Else If an object is less than 20cm away ---- Play a lower note Else If an object is less than 30cm away ---- Play a lower note Else If... The start of my code looks like this: Challenge: 1. Can you finish off the program? Make it as long or as short as you want, and then get playing your theremin. 2. The higher notes play more quickly than the lower notes. Why is that? Can you change the program so that the notes all play at the same speed? Construct Your Dreams!

Activity 6 - Sumo mbot Computer Science Unit Get your mbot ready for battle in the ancient Japanese art of sumo wrestling. Program your robot to search for your opponent (with the ultrasonic sensor), and when found, attack. NOTE: This lesson is intended for use with 2 mbots fighting on a table. Please note that the mbots may fall off the table. Appropriate measures must be taken to ensure that no damage is caused while engaging in this activity. Remember the values that are returned by the line follower sensor: So there are 2 different sensors which affect the behavior of the mbot. This can be displayed in the following table: Now we have the actions clearly defined, we can write some pseudocode for our program: Forever { ---- While (the robot has not detected an edge) { ---- ---- If (an enemy is detected) ---- ---- ---- Charge ---- ---- Else ---- ---- ---- Move forward ---- } ---- Turn } Transferring this into code looks like this:

Computer Science Unit Challenge: 1. Use the LEDs and the buzzer to signal the different actions. 2. Have a competition. Can you change the code to make the mbot do better in the competition? Construct Your Dreams!