BBC micro:bit Cool Colours!

Similar documents
Don t Steal My BBC micro:bit Alarm!

Rocket Countdown Pencil Case

BBC micro:bit Emoji Bag

Controlling the Robotic Arm using the BBC micro:bit

INTRODUCTION HARDWARE

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

Micro:bit - an Educational & Creative Tool for Kids

solutions for teaching and learning

Electronic Brick Starter Kit

Train the Trainer Resources Hex Files Here -

Piano for Micro:bit User Manual

RKP08 Component List and Instructions

solutions for teaching and learning

OpenSprinkler v2.2u Build Instructions

Using the BBC micro:bit within D&T

BuffaloLabs WiFi Lantern Assembly guide version 1

Computing & Control Trainer Teaching Guide

micro:bit Lesson 2. Controlling LEDs on Breadboard

Arduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S

OpenSprinkler v2.1u Build Instructions

09/05/2014. Engaging electronics for the new D&T curriculum. Geoff Hampson Managing Director of Kitronik. Presentation overview

Replicape Rev B 3D printer controller board

INTRODUCING THE CODEBIT!

Installing Sentor. Hardware Installation

Key Stage 3. Introduction to the. BBC micro:bit

logic table of contents: squarebot logic subsystem 7.1 parts & assembly concepts to understand 7 subsystems interfaces 7 logic subsystem inventory 7

Micro USB Lamp Kit ESSENTIAL INFORMATION. Version 2.0 DESIGN A STYLISH LAMP WITH THIS

Deep Vibes. Wobbly Optical Vibe action

Electronics Construction Manual

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

Procedure: Determine the polarity of the LED. Use the following image to help:

Analog Input. Sure sure, but how to make a varying voltage? With a potentiometer. Or just pot.

RECORD & PLAYBACK KIT

EE 354 August 1, 2017 Assembly of the AT89C51CC03 board

Introduction to microcontrollers

MuseLab WiFi IoT Robotic Shield for BBC Micro:Bit Quick Start Guide Contents

UF-3701 Power Board Construction Guide

Grove Inventor Kit for micro:bit Project Guide

High Power (15W + 15W) Stereo Amplifier

Cartoon Network MakeCode: Garnet's Gauntlets from Steven Universe

MP3 Trigger v2 User Guide

ELECTRONIC DICE CHIP FACTORY ELECTRONIC DICE PROJECT. What is a microcontroller? Example use of a microcontroller.

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

Adafruit PowerBoost Charger

This is the Arduino Uno: This is the Arduino motor shield: Digital pins (0-13) Ground Rail

DEV-1 HamStack Development Board

Introduction 3. Worksheet 1 - Switch on the LED 4. Worksheet 2 - Make the LED flash 6. Worksheet 3 - Keep the LED lit for a short time 8

Building your own special-purpose embedded system gadget.

Featuring the SM700 RF Engine from Synapse TOWER SYSTEM. Quick Start Guide Wireless Mesh Networking Module featuring SNAP Technology (TWR-RF-SNAP)

BBC Micro:Bit. Year 7. Teacher Guide and Planning

ArcControl Version: 1.0

EZ-Bv4 Datasheet v0.7

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

Guide for SI Computer Operator

<Table of content> <Parts and description> <Circuit board Guide> <Pins> <Basics of Coding> <Intro to Arduino> <Intro> <Downloading Arduino IDO>

AXE Stack 18. BASIC-Programmable Microcontroller Kit. An inexpensive introduction to microcontroller technology for all ability levels

This, plus your Basic Stamp 2 or Stamp Stack 2 Microcontroller (not included) will let you customize your robot s behavior any which way you want!

Digital Pins and Constants

micro:bit Starter Kit Guide Your First Micro:bit Kit Funny Easy Suitable for Your Beginning YEAR

Accsense Wireless System. Temperature Monitor

Introduction To Arduino

Tutorial 3: Using the Waveform Viewer Introduces the basics of using the waveform viewer. Read Tutorial SIMPLIS Tutorials SIMPLIS provide a range of t

Laboratory of Sensors Engineering Sciences 9 CFU

Electronics Construction Manual

Rover 5. Explorer kit

SPDM Level 2 Smart Electronics Unit, Level 2

E3B USER'S GUIDE. for QT310 / QT320 QProx IC evaluation and development Overview. Fast Start

The GENIE Light Kit is ideal for introducing simple lighting projects, such as an electronic die, a wearable badge or a night-time warning system.

solutions for teaching and learning

Pitstop Fuel Timer. Operating Manual

Electronics & Control

Samsung Digital Discovery Centre. Code the collection: LED badges

GSV-1A4 M12/2 M12/2. Highlights

The Sumovore Arduino SumoShield

Getting Started Manual for CODIBOT

Necessary software and hardware:

Bend Sensor USB Glove Kit User Guide

RONDO 2 Single-Unit Audio Processor

M2 OLED Temperature Monitor Instructions PN 1841

revolution How does the ibutton work? Full kit including PCB, PICAXE-08M chip and ibutton key. Spare ibutton Key

To check for updates and new device support please see

An open-source hardware+software project. For design files and additional documentation, please visit:

LEGO BB-8 Release: LEGO BB-8. Learn how to automate a LEGO BB-8for motion, light, and sound using Crazy Circuits. Written By: Joshua

PRODUCT MANUAL LEDWizard Dynamic White LED Controller

DIY Laundry Assistant. Annette Ibarra, Sierra Scott, Sara Wille

Adafruit Powerboost 1000C

About SunFounder Preface SunFounder is a technology company focused on Raspberry Pi and Arduino open source community development. Committed to the pr

Owner s Hardware Service Manual Frank Control Computer System

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

Objectives: Learn how to input and output analogue values Be able to see what the Arduino is thinking by sending numbers to the screen

Programmable Control. Name Class Teacher. Ellon Academy Technical Faculty

An Automated Greenhouse Neil Kaul 7/9/01

Adafruit PowerBoost Charger

MP3 audio amplifier. Build Instructions. Issue 2.0

FuzzD s 3PDT Direct Connect DaughterBoard

Quick Start Guide NTC-40 Series - M2M WiFi Router

EK307 Lab: Microcontrollers

Construction Construction Instructions

Contivity Extranet Switch Installing Hardware Options Guide

M1000 INTELLIGENT ZONE CONTROL SYSTEM

Transcription:

Description This is a simple tutorial demonstrating how to use an analogue input with the BBC micro:bit. The BBC micro:bit is able to read analogue voltages from sensors like Light Dependent Resistors (LDRs) and Thermistors. This tutorial uses the analogue read function to change the colour of a tri-colour LED to correspond to the temperature of the thermistor. A thermistor is a special type of resistor that changes its resistance as it gets warmer. Learn how to: Program your BBC micro:bit to read an external sensor. Control a tri-colour LED. Measure temperature increases! Level of difficulty: Beginner. Parts List In order to complete this tutorial, you will need: 1 x BBC micro:bit. 1 x tri-colour LED. (in our tutorial we use a common cathode type) 1 x 4.7K thermistor. 1 x 4.7K resistor. 1 x USB to Micro USB lead. 2 x AAA battery cage with JST connector. 2 x AAA batteries. 7 x Crocodile leads. You will also need the following equipment: A computer with a USB port and internet access.

Step-by-step guide to making your BBC micro:bit Cool Colours Temperature Sensor Step 1 Go to the BBC micro:bit website, click Create Code then look for the Microsoft Research blocks banner and click New Project. Pick a name for your project and click create! Let s practice using the block system to build some code. The blocks are organised into categories and the categories are listed in a column down the left hand side of the screen. Step 2 First we need to create a forever loop. This is the block that the rest of our code will sit inside. The forever loop runs all the blocks inside it starting from the top and working its way to the bottom. Once it gets to the bottom block it starts again at the top and this process will continue forever. Click on the Basic category to open it and then drag the Forever block into the workspace. (This is the big white area in the middle of the screen). The forever block is useful as it runs the program again from the beginning once all of the steps have been completed.

Step 3 Our code will read from a sensor and use that reading to control the LED. This will require us to store and use data from a pin on the BBC micro:bit. To do this first we will create a variable, this is a location where we can store data in the BBC micro:bit s memory. We will then pull data from the pin and store it in that variable. Grab the Set item to block from the variables category. Rename the variable by clicking the dropdown and call it TemperatureRaw. We will use this variable to store data from the thermistor. We call it Raw because the data stored will be a number between 0 and 1024 as this is how the BBC micro:bit sees analogue data, not a temperature in C. Drop this block into the forever block you just placed and you should find it snaps into position. Step 4 Now that we have a variable ready to store temperature information we need to get the information from the sensor and put it into that variable. The way to do this is to perform an analog read. Attach an analog read pin block to the variable you just made. The analog read pin block is used to read data from a pin that you can select by clicking the drop down menu to the right hand side of the block. These blocks, when combined, will read the value from the selected pin and set the variable you created to that value.

Step 5 Let s put that variable to use with an If statement. An If statement will perform a process but only if certain conditions are met. They are great as they allow us to create programs that react to changes. In this case we will use the if,do,else block. This lets us set a condition (the if part) and tell the BBC micro:bit what to do if the condition is met (the do part) or what to do if the condition is not met (the else part). We can set a condition using blocks in the Logic and Maths categories and a process that will happen if the condition is met. Create a condition that checks if the variable TemperatureRaw goes over 520. The Do part should perform a digital write (1) to pin P1 and a digital write (0) to pin P2. It should also display the number stored in TemperatureRaw on the LED display. The Else part should perform a digital write (1) to pin P2 and a digital write (0) to P1. It should also display the number stored in TemperatureRaw on the LED display. Step 6 Now would be a good time to put what we ve just done to the test. First however, we need to set up the hardware. Put the batteries into the battery holder and push the JST connector into the socket on the BBC micro:bit. Connect your thermistor to your resistor with one crocodile lead. It doesn t matter which side of the resistor or thermistor you connect. Using another crocodile lead, connect the unattached leg of the resistor to the pin on your BBC micro:bit labelled GND and the unattached leg of the thermistor with a third crocodile lead to the pin labelled 3V. To finish connecting the sensor, connect the leg of the thermistor that is connected to the resistor with another clip to the pin on the BBC micro:bit labelled 0. This means that the thermistor has two crocodile clips on one of its legs. Finally we will connect the LED. The tri-colour LED will have 3 legs. If using a common cathode style tri-colour LED you need to connect the long centre leg to the pin on the BBC micro:bit labelled GND. Then connect one of the short legs to pin P1 and the other short leg to pin P2. It can be hard to tell which leg is the red LED and which is the green

LED so if you notice the wrong colour LEDs coming on you may want to swap the legs that pins P1 and P2 are connected to. Step 7 Now, let s try that out! Press compile* and after a few moments the code should appear as a download in your browser. If you plug your BBC micro:bit into a USB port it will show up as a storage device. Simply drag and drop the.hex file you just downloaded onto the BBC micro:bit. The file might not show up on the BBC micro:bit in the file explorer but it is there! Once the file has been transferred (the light on the BBC micro:bit will stop blinking rapidly) remove the BBC micro:bit from your computer. Now power up your BBC micro:bit with the batteries, then press the reset button next to the USB connector you should see the green LED light up. You should be able to warm the thermistor by holding it in your fingers or breathing on it. This will trigger the red LED. *If this is the first time you have used the compiler you will be asked to make an account. Ask your teacher for the code required to make an account. Further Tasks At the moment we just have a red or green light for hot or cold. The cool thing about tri-colour LEDs is that we can use the two colours simultaneously to mix and give an amber light. This also lets us take advantage of the analog read. Instead of having just hot and cold conditions we can add a warm condition too. Using the larger If, else, do, else if, do, else block we can set two If conditions and have them do two different things as well as giving a command what to do if neither condition is met. All with one decision block! Use the blocks in the Maths and Logic categories to create two If conditions. One that checks if the TemperatureRaw variable is between 520 and 550, this will be our warm condition. If this condition is met we need to do a digital write (1) to both pins P1 and P2, this will put both lights on giving us amber. The else if condition should check if TemperatureRaw goes above 550, if this condition is met we want to digital write (1) to P1 and digital write (0) to P2, this will put just the red light on. The last part of the block, the else statement, should digital write (1) to P2 and digital write (0) to P1, giving us just the green light.