LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

Similar documents
Arduino Lesson 1. Blink. Created by Simon Monk

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

Welcome to Arduino Day 2016

Downloading a ROBOTC Sample Program

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

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

smraza Getting Start Guide Contents Arduino IDE (Integrated Development Environment)... 1 Introduction... 1 Install the Arduino Software (IDE)...

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

UNIT 4 VOCABULARY SKILLS WORK FUNCTIONS QUIZ. A detailed explanation about Arduino. What is Arduino? Listening

Using the S5U13781R01C100 Shield Graphics Library with Atmel Studio

Saturday Academy Program

Internet of Things Student STEM Project Jackson High School. Lesson 2: Arduino and LED

Practical Assignment 1: Arduino interface with Simulink

Lesson 3: Arduino. Goals

Total Hours Registration through Website or for further details please visit (Refer Upcoming Events Section)

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

FABO ACADEMY X ELECTRONIC DESIGN

Coding with Arduino to operate the prosthetic arm

Servomotor Control with Arduino Integrated Development Environment. Application Notes. Bingyang Wu Mar 27, Introduction

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

Lab 2: Blinkie Lab. Objectives. Materials. Theory

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

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

How to Make Games in MakeCode Arcade Created by Isaac Wellish. Last updated on :10:15 PM UTC

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

Application Note. Communication between arduino and IMU Software capturing the data

MINIMUM SYSTEM REQUIREMENTS

ISSN: [Singh* et al., 6(6): June, 2017] Impact Factor: 4.116

Computer Science/Computer Engineering. Wheeler HS Fall 2018 Foundations of Engineering

Sheet Metal Punch ifeatures

Getting Started with the micro:bit

Overview... 3 Starting the Software... 3 Adding Your Profile... 3 Updating your Profile... 4

Endurance R/C Wi-Fi Servo Controller 2 Instructions

The USB Brotherlink 4 - or Cartridge Cable

On the front of the board there are a number of components that are pretty visible right off the bat!

GRAPHOGAME User Guide:

Light Emitting Diode IV Characterization

Open Loop Frequency Response

Module: Arduino as Signal Generator

Adafruit 16-Channel PWM/Servo HAT & Bonnet for Raspberry Pi

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

Understanding the Arduino to LabVIEW Interface

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

Arduino An Introduction

MIDLAND PROGRAMING G14

INSTRUCTIONS. 3DR Plane CONTENTS. Thank you for purchasing a 3DR Plane!

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Estimated Time Required to Complete: 45 minutes

Pulse Width Modulation and

Dermatology. Written By: Carmen McFatridge KOTM Informatics Educator 2011

The DesignaKnit USB Brotherlink 5

Online Check-in Information for 2016 Magic Cup

The DesignaKnit USB Brotherlink 3

Arduino Workshop 01. AD32600 Physical Computing Prof. Fabian Winkler Fall 2014

Blue Bamboo P25 Device Manager Guide

GPS TECHNOLOGY IN COMMUNITY SERVICES

Rodni What will yours be?

1Getting Started SIK BINDER //3

VBRC 5. Radio Communicator. Installer Manual

Getting Started Guide

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Lab 12 Laboratory 12 Data Acquisition Required Special Equipment: 12.1 Objectives 12.2 Introduction 12.3 A/D basics

Reviewing Your Tax Return In Your Portal

Arduino Setup & Flexing the ExBow

Milli Developer Kit Reference Application Published on Silver Spring Networks STAGE (

Setting up Volumio to get great audio

Kodiak Corporate Administration Tool

Sheet Metal OverviewChapter1:

TETRIX PULSE Workshop Guide

Adafruit 16-Channel PWM/Servo HAT for Raspberry Pi

MILL ONE. Assembly Manual. Manual Illustrated by Gontarz Design Studio

OverDrive for Kindle, Kindle Paperwhite, Kindle Voyage, and Kindle Oasis (not Kindle Fire and Fire Tablet) Contents

INTRODUCTION to MICRO-CONTROLLERS

Arduino Programming In 24 Hours Sams Teach Yourself Sams Teach Yourself 24 Hours Paperback

Arduino Hacking Village THOTCON 0x9

O Reilly Ebooks Your bookshelf on your devices!

10.2. Scanning Document Camera Scoring. Page 1 of 5. How do I score answer sheets using a document camera? STEP 1

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Preface. If you have any TECHNICAL questions, add a topic under FORUM section on our website and we'll reply as soon as possible.

Physical Inventory System User Manual. Version 19

1 Overview Introduction Acronyms & abbreviations...2

Programming Arduino Next Steps: Going Further With Sketches PDF

How Do You Make a Program Wait?

The DesignaKnit USB Brotherlink 1

ezsystem elab16m Light Sensing Robot

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Switching to Sub Category and Collapsible Skins

ZX Distance and Gesture Sensor Hookup Guide

APDS-9960 RGB and Gesture Sensor Hookup Guide

EOS 80D (W) Wireless Function Instruction Manual ENGLISH INSTRUCTION MANUAL

ARDUINO / GENUINO. start as professional. short course in a book. faculty of engineering technology

1. ASSEMBLING THE PCB 2. FLASH THE ZIP LEDs 3. BUILDING THE WHEELS

Program.

Warehouse Instruction Guide

Adafruit 16-Channel Servo Driver with Arduino

1 Day Robot Building (MC40A + Aluminum Base) for Edubot 2.0

stored on the micro SD card supplied with the product and accessed when you come back to your computer.

Transcription:

LESSONS Lesson Lesson : Microcontrollers and SBCs Microcontrollers and SBCs The Big Idea: This book is about computer science. It is not about the Arduino, the C programming language, electronic components, or the mathematics of electricity even though we refer to them extensively in the lessons in this book. The Arduino, the C programming language, electronic components, and the mathematics of electricity are the tools this book uses to teach computer science. These tools allow readers to learn by doing, to learn with their hands. Every lesson is either an experiment or a project. Some projects, lighting LEDs, for example, are simple. Others are complex. Laser tag is an excellent example. But simple or complex, none of the projects does anything unless some computer science has been applied to bring them to life. Background: What, precisely, is computer science? For the purposes of this text, computer science is the application of numbers and logic to make devices, algorithms, and languages that, together, can model just about anything. This book uses the tools listed in Table -. Table -. Tools this book uses Tool Description devices The Arduino family of Single-Board Computers (SBCs). algorithms The collection of programming techniques, tools, and libraries we use to build our models. language The C programming language. Lesson Microcontrollers and SBCs

The key word is model. Consider Table -2, examples of the uses of models in computing. Table -2. Examples of models in computing Example What is modeled How model connects to world League of Legends Digital medical imaging via Magnetic Resonance Microsoft Word Aircraft Autopilot A fantasy world where characters possess magical and physical powers. The detailed densities of the portions of the body being scanned. The appearance of formatted text as if it were typed directly onto a piece of paper. The stable flight of an aircraft. Players (humans) participate by controlling the actions of some of the characters. High quality graphics and game play allow the user to suspend disbelief and pretend the world is real and that the player is actually the character being controlled. By collecting data about minute movement of molecules in response to a changing magnetic field, a model of the scanned object is created. This model is presented to the user as startlingly detailed 2D and 3D images of what would be found if the subject were opened surgically. The user can add to and modify both the content and appearance of this text and can cause a copy of the model to be printed on paper. The computer collects data (speed, direction, physical orientation of the aircraft, altitude) and uses the model to control wing surfaces and engine speed. Notice that in each case the computer creates and maintains a model. That model might be something that exists in reality or something entirely fictional. And the output from the model may be information that appears on a screen, instructions that control physical devices, or a physical product, such as text or graphics printed on paper or plastic. The important takeaway is this: all computer programs are models. The lessons in this book contain experiments and projects that explore concepts and build models that control lights, make sounds, run robots, turn motors, detect and compose messages, and more. Some of these models will collect and respond to data from their environments. Some will provide text as their output, and others will control physical devices. But every experiment and project is controlled by an Arduino running a model of what is being built. And, that model will be written with the C programming language. 2 Learn to Program in Arduino TM C: 8 Lessons, from setup() to robots

Table -3. Vocabulary Term Definition algorithm A means of or steps to performing a specific task. For a computer, an algorithm is usually expressed in a set of computer program instructions. Arduino A single-board computer and an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. C programming language The programming language used to write sketches for the Arduino SBC. The syntax is similar to several other commonly used programming languages, including C++, C#, and Java. Integrated Development Environment (IDE) A collection of computer programs used to create other computer programs. microcontroller A complete self-contained computer in a chip, including the memory for a program and its data. This small microprocessor also contains the necessary electronics to communicate with external devices. microprocessor A complex electronic integrated circuit that performs the processing tasks of a computer, including input, output, and computation. output Information of any sort that comes out of a computer. single-board computer (SBC) An entire microcomputer on a single printed circuit board. Abbreviated SBC. Examples include the Arduino and the Raspberry Pi. sketch A computer program written for the Arduino. Description: Arduino is a name given to a family of single-board computers (SBCs). The particular family member used in lessons in this book is the Arduino Uno. All Arduinos contain an integrated circuit called a microcontroller. A microcontroller is a small but complete microprocessor capable of input, output, and computation. In addition, a microcontroller includes storage memory for a computer program and its data. Lesson Microcontrollers and SBCs 3

Figure -. The Arduino Uno Surrounding this microcontroller are the electronic components, connectors, and rows of sockets necessary to bring power to the microcontroller, allow it to receive information from the outside world, and to transmit information. The term single-board means that the entire computer fits on a single circuit board. Different members of the Arduino family have different features. Some are small and light enough to be sewn into clothing, while others are sufficiently powerful to perform complex tasks very quickly. But they are a family in that they are all programmed with the same language. The syntax of this language is so very close to C that it is referred to as the C language. Mastery of this language serves as an excellent base for other commonly used programming languages, including C++, C#, and Java. The upcoming lessons explore most of the features of the Arduino Uno. This first lesson begins with installation and testing of the set of computer programs used to write and install Arduino sketches. This collection of computer programs is called the Arduino Integrated Development Environment (IDE). A program written for the Arduino is called a sketch. 4 Learn to Program in ArduinoTM C: 8 Lessons, from setup() to robots

Goals: By the end of this lesson you will:. Know the purpose of an Integrated Development Environment (IDE). 2. Know how to locate, download, and install the Arduino IDE. 3. Be able to modify, save, upload, and run simple sketches for the Arduino. 4. Know that sketch refers to a computer program written for the Arduino. Materials: Quantity Arduino Uno USB Cable Part Image Notes Computer with at least one USB port and access to the Arduino website, http://www.arduino. cc. --- Single-board computer. This board is delicate and should be handled with care. When you are not using it, keep it in a box or plastic bag. This is the standard USB adapter cable with the flat connector on one end and the square connector on the other. The operating system of this computer must be Windows, Macintosh OS/X, or Linux. Catalog Number 302 230 --- Procedure: Important These instructions are for Windows and will work in most situations. For Macintosh and Linux, refer to the instructions on the Arduino website: http://www.arduino.cc Lesson Microcontrollers and SBCs 5

Part I: Download, install, and test the Integrated Development Environment. Open Internet Explorer or another Internet browser and navigate to the Arduino website http://www. Arduino.cc. 2. Locate the "Download" section of the page and select [Windows]. This will begin the download of the package that will install the IDE. 3. Double-click the Arduino icon. A warning message may appear. If it does, click the [Run] button. 6 Learn to Program in Arduino TM C: 8 Lessons, from setup() to robots

4. The IDE work space should then appear. Part II: Connect and test the Arduino Uno. Connect the Arduino Uno to the computer using the USB cable. A small green light should appear on the Arduino, indicating it has power. A small message may appear in the lower-right tray of Windows indicating to which COM port the Arduino is assigned. If it does, remember it because it may be needed later. 2. Click the [Tools] menu at the top of the IDE. From the dropdown menu select [Board], and from that menu select [Arduino Uno]. Lesson Microcontrollers and SBCs 7

3. Select [File]. From the dropdown menu, select [Examples], then [Basics], then [Blink]. An Arduino program, called a sketch, will appear in the IDE. Notice that the name of the sketch, Blink, is in the tab. 4. Verify the IDE is communicating with the Arduino by clicking the [Upload] button on the IDE toolbar. If communication is successfully established, the message "Uploading to I/O board" will appear at the bottom of the IDE. It will be followed by the message "Done uploading." A small light should now be blinking: on for one second, then off for one second. 8 Learn to Program in Arduino TM C: 8 Lessons, from setup() to robots

Exercises: Exercise -. Verify success of Blink sketch. Under the File menu is a submenu called Preferences. Open [Preferences] to verify that the Sketchbook location is the Arduino folder in Documents. Then click [OK] at the bottom of the screen. 2. Save the Blink sketch as MyBlink by selecting the [File] menu, then [Save as], then naming the file [MyBlink]. Click the [Save] button. Notice that the tab in the IDE should now say [MyBlink]. Lesson Microcontrollers and SBCs 9

3. Modify the MyBlink sketch to make the light blink on and off at half-second intervals by changing the number 000 to 500 in the two delay statements. Don't be concerned about understanding the sketch at this time. The intent of this step is simply to verify the proper operation of the Arduino Uno and the IDE. 4. Save the modified sketch by selecting [File] then [Save]. 5. Upload the sketch to the Arduino. If you're successful, the light should blink twice as fast as before. Exercise -2. Verify sketch runs on Arduino and experiment with time delays. Verify that the modified sketch is, in fact, running on the Arduino and not on the computer to which the Arduino is connected. This can be done by unplugging the Arduino from its USB cable and providing power to the Arduino by means of a wall-plug power supply (30 in Parts Catalog) or a battery pack. Note: The light should blink even though the Arduino is now independent of the computer. 2. The number used in the delay statement, delay(500);, is a measure of time in milliseconds. The number "500" is 500 milliseconds, or one half second. This is a common technique used to save power. For example, roadside flashers turn their lights on for short periods of time while leaving them off for a longer period. Experiment with the values of MyBlink to find the shortest blink time that still appears to be long enough to be noticed by a casual observer. 0 Learn to Program in Arduino TM C: 8 Lessons, from setup() to robots

3. Experiment with at least six values of delay for time on. Set the delay for the light off to be one second. That is 000 milliseconds. Complete Exercise Table -. Exercise Table -. Time delay experiment table Condition Time On, in Milliseconds Light on longer than necessary: Light not on long enough to be noticed reliably: Optimal time on: Lesson Microcontrollers and SBCs

2 Learn to Program in Arduino TM C: 8 Lessons, from setup() to robots