Lesson 18 Automatic door

Similar documents
Lesson 25 Flood Warning System

Lesson 27 CPF Weather Station

Lesson 16 Musical Door Bell

Design and create an app which uses sequence, selection, repetition and variables. Program, debug and refine the code for their app.

Lesson 5 Cloud Upload

Lesson 7 Cloud Mood Indicator

Introductory Lesson 1 Working in the cloud

CPF Arduino Blockly V

QUICK START GUIDE. Setting up your AccuDate XL for use with the Jolt App

Main Features of the LIFE App. LIFE App Main Features

micro:bit Lesson 1. Using the Built-in Sensors

Sphero Lightning Lab Cheat Sheet

Version B Wi-Fi IP CAMERA

Controlling the Robotic Arm using the BBC micro:bit

Installation guide for IP Camera G2

What Is a Program? Pre-Quiz

Introduction to microcontrollers

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

In order to update you will have to uninstall the current version and install the newer version using the same procedure.

Ctdigi.com. Instruction manual. Production by S & W Technology Labs

mi:node User Manual Element14 element14.com/minode 1 User Manual V3.1

Lab 1: Introductory Project to Breadware

Don t Steal My BBC micro:bit Alarm!

Sygonix Home Starter Kit

Step 1 Turn on the device and log in with the password, PIN, or other passcode, if necessary.

Features: (no need for QR Code)

i wonder, therefore i am. Welcome to the Wonder League! This packet includes everything you need to know about Dash, Dot, and how to get started!

Task On Gingerbread On Ice Cream Sandwich Notification bar on lock screen Notification bar is not accessible on the lock screen.

MeetingPad User Manual. Manual Version PTAs1.0

Engineering Project-I. Module 1: Familiarization of LabVIEW and the Vernier Toolkit

QUICK GUIDE. Instruction Manual. UFO Camera

GOOD MORNING SUNSHINE

user manual Getting started... 3 Calibration... 3 Getting to know your robot... 4

Hello App Inventor! Android programming for kids and the rest of us. Chapter 2. by Paula Beer and Carl Simmons. Copyright 2015 Manning Publications

Block Programming Guide

Getting Started Guide

Saviour App User Manual. User Manual to use app. This documents describe the Saviour app functionalities for end user.

INTRODUCING THE CODEBIT!

ECE 463 Lab 1: Introduction to LabVIEW

Motion Sensor 2 with temperature sensor

Activity Inputs and Outputs VEX

Windows 10 Essentials

Video recorders Series DH

Lab - Working with Android

EV3 Programming Workshop for FLL Coaches

A guide to using Blockly to simulate and program a PICAXE microcontroller

HOME SECURITY KIT. USER MANUAL SMART PROTECTION WITH THE ALL-IN-ONE SOLUTION. SMART WINDOW SENSOR SMART POWER SOCKET SMART MOTION SENSOR SMART IP CAM

Digital Devices in the Digital Technologies curriculum (F-10) Steve Allen VCAA Digital Coding Specialist Teacher

D3D Security Pvt ltd

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

USER MANUAL. Mac Version

SECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing

create.tokylabs.com has a large number of blocks. They are divided into the following categories:

USER GUIDE. Security Multi-Sensor

SecurityProbe 5E Camera & Alerting Setup Manual

How to Use Passive Infrared Sensor Cameras

For this option, you need a flash drive or CD (CD-R or CD-RW). NOTE: If you use a CD-R, be careful not to close the session.

mblock Robotics Advanced Programs

Sphero. Draw your name using the Sphero Robot.

HSIP2 User Manual. ios Application Android Application PC Setup

OUTDOOR SECURITY CAMERA WITH LED FLOODLIGHT

HSIP2 User Manual. ios Application Android Application PC Setup

TABLE OF CONTENTS. Page 2 35

Panoramic Talking Camera

Crossley Fields - Computing Vocabulary

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

Chapter 1 Introduction of the Camera 4. Chapter 2 Install Reolink App System Requirement Install the App 5

Internet Explorer 11 QUICK START GUIDE ADDRESS BAR SEARCH ACCESSING FMS

iminicam 1080p Wireless Spy Camera User Manual

Discover Robotics & Programming CURRICULUM SAMPLE

All Blocks of Scratch

To lead your students through this activity, you will need your computer, attached to a projector, for projecting your code for students to see.

Micro:bit - an Educational & Creative Tool for Kids

Studuino Block Programming Environment Guide

Table Of Content 1. What s in the box 3 2. About the unit 4 3. Getting started 5 4. Networking options 6 5. Turning on the MTC-5000 Unit 7 6.

User s Guide. Attainment s. GTN v4.11

QUICK START GUIDE. Setting up your AccuDate XL for use with CrunchTime! KitchenSync

Techsense Bangladesh Ltd.

KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions

lab A.3: introduction to RoboLab vocabulary materials cc30.03 Brooklyn College, CUNY c 2006 Name: RoboLab communication tower canvas icon

Grove Inventor Kit for micro:bit Project Guide

Activity Inputs and Outputs VEX

Android Mobile Client. User Guide. Version 2.9.1

Robotics Adventure Book Scouter manual STEM 1

Arduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol

Fundamentals. Training Kit. Presentation Products, Inc. 632 W 28th St, 7th fl New York, NY f presentationproducts.

WideQuick Remote WideQuick Designer

Introduction. Built-in speaker. Infrared lights. Camera lens. Reset button. Indicator light. Micro- USB port for power supply.

Hardy EASY 8 Quick Start & Programming Guide. Function Block Description

NVR Equipment WEB Operation Guide ISSUE V1.1 DATE

DCS-8000LH. HW Version FW Version App Name App Version. A1 V Mydlink Lite V3.8.0

International Journal of Artificial Intelligence and Applications (IJAIA), Vol.9, No.3, May Bashir Ahmad

Package Content. QSG booklet. Warranty, legal & safety booklet. USB cable. Charger. Warranty ARCHOS 11,31

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. App Inventor Workbook

Microsoft Windows 10. Quick Reference. Watsonia Publishing 47 Greenaway Street Bulleen VIC 3105 Australia

Configuring an Android Device for inet Guardian

SG520 Series. Infrared Digital Scouting Camera User Manual. Page 1

Learn to Code. App Inventor Overview

WI-FI GARAGE DOOR CONTROLLER WITH CAMERA USER MANUAL

Studuino Programming Environment Manual

Transcription:

Lesson 18 Automatic door 1 What you will need CloudProfessor (CPF) PIR (Motion) sensor Servo Arduino Leonardo Arduino Shield USB cable Overview In this lesson, students explore automated systems such as automatic doors and lighting. Using a PIR sensor and a servo, students will write a program to simulate an automatic door. Learning Objectives Design and create an app which uses sequence, selection, repetition and variables. Program, debug and refine the code for their app. Understand and use selection in an algorithm (IF, Else and Else if) Learning Expectations (how learning / progress will be demonstrated) All Use sequences of instructions. Most Explain how their app works. Some Use logical reasoning to detect errors in their algorithms. Curriculum Links (Computing PoS) Designs simple algorithms using loops, and selection i.e. if statements. (AL) Uses logical reasoning to predict outcomes. (AL) Detects and corrects errors i.e. debugging, in algorithms. (AL) Creates programs that implement algorithms to achieve given goals. (AL) Understands that programming bridges the gap between algorithmic solutions and computers. (AB) Computational Thinking Concepts: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation. 1 Lesson 18: Room Alarm

Step-by-step instructions (Blockly) 1. Connect the power of CloudProfessor then press and hold the power button for two seconds; it will turn on and the power indicator will light up.. Insert the Android Shield into Arduino Leonardo and use the USB cable to connect the CloudProfessor with Arduino Leonardo. Attach the PIR (motion) sensor to port D6 and the servo to port D4.. When the CloudProfessor detects the Arduino Leonardo, a notification will appear on your device; click the notification to launch the Arduino Leonardo APP, and select the CPF Arduino Blockly app. Click on Lesson 9. 1 4. Press the execute button to enter the control user interface (UI). 5. Press the edit button to enter the program editing page. Edit button Execute button CPF Arduino app Control user interface (UI) Program editing page Lesson 18: Room Alarm

Code recap (Blockly) Let s explore some of the code used in the previous lessons. 1. PIR Motion Sensor Get Value: The PIR Motion Sensor Get Value block returns the status of the PIR motion sensor (Returns a numeric value of 0 if no motion detected and a 1 if triggered).. Servo Pin# D4: The Servo block allows the user to control the attached servo by specifying the angle (degrees) and delay (milliseconds).. If / else: The if / else block is used to conditionally run code depending on whether a Boolean condition is true or false. In this example, if the light sensor value is less than (<) 500, the RGB LED light will light up; or else (else), if the light sensor value is greater than or equal to 500, the RGB LED light will automatically turn off. 4. Title Name Panel Set: The Title Name Panel Set block displays a message on the screen. In this example it will display a Downloading message on the UI (User Interface). 5. Delay Time(Sec.): The Delay Time(Sec.) block is used to pause the code (time set in milliseconds). In the example above, the program is paused for 1000 milliseconds (1 second). 6. Set CPF control request: Finally, the Set CPF control request block at the end of the program tells the program to run the code from the beginning again. The program will continuously repeat until the user closes the app or stops the program manually. Lesson 18: Room Alarm

4 Step-by-step instructions (Blockly) - Part 1 Let s write the code for our automatic door. 1. Clear the existing code so that you have a blank canvas to create your new program. Click on the bin icon (1). Click on OK () to create a blank canvas. 1. Note: You can return to the original program at any time by clicking on the restore icon ().. First, let s give our app a title. Click on CPF UI. Drag the Title Name Panel Set block onto the empty canvas. Call your app CPF Door. 4. Next, we need to check the status of button d5 in the user interface (UI). We will use this button to turn on and off your Theremin. a) Click on the Variables tab. Drag the Set item to block and attach it to the Title block. Rename the new variable to d6 (4). 4 b) Click on the CPF UI tab. Select and drag the Get control panel value block and attach it to d6. From the drop down menu, select d6 (5). 5 5. Next, let s display the status of the PIR sensor on the user interface (UI). a) Click on the CPF UI tab. Select and drag the Set control panel value block and attach it to the end of your code. From the drop down menu, select port D6 (6). 6 b) Click on the Variables tab. Select d6 and place it inside the Set control panel value block (7). 7 4 Lesson 18: Room Alarm

4 Step-by-step instructions (Blockly) - Part 6. Next, we need to write the condition which checks to see if the PIR has detected movement (PIR = 1). For this, we will use an IF statement. a). Click on the Logic tab. Drag the if do block and attach it to the end of your code (8). 8 9 b). Click on the logic tab. Drag the = block and attach it to your if block (9). c). Click on the CPF Devices tab. Select and drag the Light Get Value block onto the first slot in your logic block (10). 10 d). Click on the Math tab. Drag the 0 block onto the second slot in your logic block. Change this value to a 1 (11). 11 7. Next, we need to rotate the servo 180 degrees when movement is detected else return the servo back to the starting position (0 degrees) when no movement is detected. a) Click on Output Devices. Select Motors and drag the Servo Pin# D4 block and attach it to your code. b) Change the number of degrees to 180 and the delay to 0 ms (1). 1 c) Click the cog inside your if block. Drag an else block inside the pop-up window (1). d) Click on Output Devices. Select Motors and drag the Servo Pin# D4 block inside the else statement. b) Change the number of degrees to 0 and the delay to 0 ms (14). 1 14 8. Finally, we want the program to run continuously until the user ends the program. Select the CPF Devices tab. Click and drag the Set CPF control repeat block and attach it to the end of your code. Your finished code should look like this. Try changing the delay and/or angle to see how it affects the servo. 5 Lesson 18: Room Alarm

Step-by-step instructions 1. Connect the power of CloudProfessor then press and hold the power button for two seconds; it will turn on and the power indicator will light up.. Insert the Android Shield into Arduino Leonardo and use the USB cable to connect the CloudProfessor with Arduino Leonardo. Attach the PIR (motion) sensor to port D6 and the servo to port D4.. When the CloudProfessor detects the Arduino Leonardo, a notification will appear on your device; click the notification to launch the Arduino Leonardo APP, and select the CPF Arduino app. Click on Socket Mode. 1 4. Press the execute button to enter the control user interface (UI). 5. Press the edit button to enter the program editing page. Edit button Execute button CPF Arduino app Control user interface (UI) Program editing page 6 Lesson 18: Room Alarm

Code recap (JavaScript) Let s explore some of the code used in the previous lessons. 1. cpf.get( light sensor ); The cpf.get( light sensor ); statement returns the value of the light sensor. (Returns a numeric value based on the brightness level of the environment) and stores it in a variable called value. ui.set( light sensor, value); reads the value taken from the light sensor and displays it in the program control Interface (UI).. cpf.set( rgb led, 0, 0, 0); The cpf.set( rgb led, r, g, b); statement sets the colour of the attached RGB LED.. If / else: The if / else statement is used to conditionally run code depending on whether a Boolean condition is true or false. In this example from lesson 1, if the light sensor value is less than (<) 500, the RGB LED light will light up (based on the values taken from the UI); or else (else), if the light sensor value is greater than (>) 500, the RGB LED light will automatically turn off: cpf.set( rgb led, 0, 0, 0); 4. Math.random() Through Math.random(), a random number between 0 and 0.999999 is generated. If we want to generate a whole number in a range such as 1 55 we first need to multiply the result of the random function by 55 and then round the result to produce a whole number e.g., 5. cpf.sleep(1000); The cpf.sleep(1000); statement is used to pause the code (time set in milliseconds). In the example above, the program is paused for 1000 milliseconds (1 second). 6. Set CPF control request: Finally, the cpf.repeat(); statement, usually found at the end of the program, tells the program to run the code from the beginning again. The program will continuously repeat until the user closes the app or stops the program manually. 7 Lesson 18: Room Alarm

Step-by-step instructions (JavaScript) 4 Let s write the code for our automatic doors. 1. Clear the existing code so that you have a blank canvas to create your new program. Press and hold on a selection of code and click on Select all (1). Click on Cut () to create a blank canvas (). 1 Note: You can return to the original program at any time by clicking on the restore icon in the Save/load menu.. First, let s give our new script a name. Click on line 1 and type in the following: //Servo. Next, we need to read the status of the PIR motion sensor and display the current status on the user interface (UI). Click on line and type in the following: //Control PIR var d6 = cpf.get( socket d6 ); ui.set( socket d6, d6); 4. Next, we need to write the condition which checks to see if the PIR has detected movement (PIR = 1). For this, we will use an IF statement. Click on line 7 and type in the following (making sure you leave a blank line on line 8): if(d6 == 1) { } 5. Next, we need to rotate the servo 180 degrees when movement is detected else return the servo back to the starting position (0 degrees) when no movement is detected. The syntax for moving the servo is cpf.set(socket, angle, delay). Click on line 8 and type in the following: cpf.set( socket d4, 180, 0); } else { cpf.set( socket d4, 0, 0); 6. Finally, we want the program to run until the user ends the program. Click on line 4 and type the following: cpf.repeat(); 7. Run your code. Your finished code should look like this. Try changing the delay and/or angle to see how it affects the servo. Try swapping the PIR sensor for a button. 8 Lesson 18: Room Alarm

5 Extension Students can connect a buzzer to port D5 or RGB LED to port D7 and program the CloudProfessor to warn when the door is opening (see lesson 16). Students could also attach a sound sensor to port A and operate the door with voice commands. Hint: var a = cpf.get("socket a"); if(d5 == 1) { 6 Differentiation To support students, provide step by step guides. To stretch students ask them to create a flowchart / pseudocode of their code first or code their solution using JavaScript. 7 Homework Students to write up a summary of what they ve learned; students to include screenshots and snippets of their code in their summary. Students to explore how automatic doors work and explain the benefits / drawbacks of automated systems. 8 Links How PIRs work: https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work How automatic doors work: https://www.scienceabc.com/innovation/automatic-sliding-doors-working-motion-detector -pressure-sensor-infrared.html Disclaimer: Use these sites at your own risk. Acer is not responsible for the content of external Internet sites. We recommend that you check the suitability of any recommended websites links before giving them to students. 9 Lesson 18: Room Alarm