Lab 2: Blinkie Lab. Objectives. Materials. Theory

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

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

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

Lab 2.4 Arduinos, Resistors, and Circuits

FABO ACADEMY X ELECTRONIC DESIGN

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

THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS.

Workshop 9: First steps in electronics

Lesson 3: Arduino. Goals

INA169 Breakout Board Hookup Guide

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

Arduino Lesson 1. Blink. Created by Simon Monk

MAKEVMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

Demon Pumpkin APPROXIMATE TIME (EXCLUDING PREPARATION WORK): 1 HOUR PREREQUISITES: PART LIST:

Arduino An Introduction

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

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

Module: Arduino as Signal Generator

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Coding with Arduino to operate the prosthetic arm

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Rodni What will yours be?

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

Exam Practice Problems (3 Point Questions)

The Motor sketch. One Direction ON-OFF DC Motor

ENGR 1181 Lab 3: Circuits

Two Hour Robot. Lets build a Robot.

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

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

TWEAK THE ARDUINO LOGO

The answer is R= 471 ohms. So we can use a 470 ohm or the next higher one, a 560 ohm.

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

Microcontrollers and Interfacing

Electronic Components

LED + Servo 2 devices, 1 Arduino

The Robot Builder's Shield for Arduino

The µbotino Microcontroller Board

EE 210: CIRCUITS AND DEVICES

Series and parallel resistances

Experiment P-24 Circuits and Series Resistance

Welcome to Arduino Day 2016

Training Schedule. Robotic System Design using Arduino Platform

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

Lab 06: Ohm s Law and Servo Motor Control

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

Light Emitting Diode IV Characterization

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

ZX Distance and Gesture Sensor Hookup Guide

Pulse Width Modulation and

WEEK. Learning Objective. Materials to Prepare LESSON

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

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

Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

1. (2 point deduction for failure to complete this problem!)

Breadboard Arduino Compatible Assembly Guide

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

Oregon State University Lab Session #1 (Week 3)

University of Jordan School of Engineering Electrical Engineering Department. EE 204 Electrical Engineering Lab

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

EET 1150 Lab 6 Ohm s Law

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

1Getting Started SIK BINDER //3

Pulse-Width-Modulation Motor Speed Control with a PIC (modified from lab text by Alciatore)

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

Understanding the Arduino to LabVIEW Interface

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

Laboratory Project 1a: Power-Indicator LED's

// Parts of a Multimeter

CDI Revision Notes Term 1 ( ) Grade 11 General Unit 1 Materials and Unit 2 Fundamentals of Electronics

Design and Technology

Chabot College Physics Lab Ohm s Law & Simple Circuits Scott Hildreth

Voltage Current and Resistance II

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

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

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

Electric Circuit I Lab Manual Session # 2

Experiment A6 Solar Panels I Procedure

Series and Parallel Circuits Basics 1

Chapter 1: DC circuit basics

Internet of Things Student STEM Project Jackson High School. Lesson 3: Arduino Solar Tracker

Basic Electronics Refresher

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

Experiment 8: Semiconductor Devices

APDS-9960 RGB and Gesture Sensor Hookup Guide

Electronics Merit Badge Kit Theory of Operation

Part 1. Using LabVIEW to Measure Current

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

WEEK. Learning Objective. Materials to Prepare. Summary of Class LESSON

Current, resistance, and Ohm s law

Voltage, Current and Resistance

DC CIRCUITS AND OHM'S LAW

Figure 1. CheapBot Smart Proximity Detector

Sidekick Basic Kit for Arduino V2 Introduction

Intelligent Systems Design in a Non Engineering Curriculum. Embedded Systems Without Major Hardware Engineering

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

MAE106 Laboratory Exercises Lab # 3 Open-loop control of a DC motor

Electrical Measurements

LAB II. INTRODUCTION TO LAB EQUIPMENT

ARDUINO / GENUINO. start as professional

Transcription:

Lab 2: Blinkie Lab Objectives This lab introduces the Arduino Uno as students will need to use the Arduino to control their final robot. Students will build a basic circuit on their prototyping board and wire the board to the Arduino. Students will learn the basic programming structure for the Arduino. The final project for the lab will have students develop a program to blink an LED. Materials ) Arduino Uno 2) Prototyping Circuit Board 3) 220 Ω Resistor 4) Wires for Building Circuits ) Wire Cutters 6) Wire Strippers Theory Introduction to Circuits An electrical circuit contains a closed loop of wire that connects any number of electrical components, such as batteries, light bulbs, switches, resistors, motors, etc. Electrical charge, measured in coulombs, C, flows through a circuit in the same way that water would flow though a pipe. Electrons are the tiny particles that carry the electric charge through the circuit. Each electron has a value of.60 0 9 coulombs (making one coulomb of charge a very large number of electrons, 0 20 ). Lifting a mass to some height, h, above the ground is an example of potential energy. Potential energy is converted to kinetic energy when the mass is released and falls to the ground. Similarly, a battery contains electrons waiting to be used. Like the mass, electrons will flow from a high potential to a lower potential, a potential which is called voltage, V, and measured in volts [V ]. Think of voltage as the force that pushes the electrons around the circuit. A battery creates a potential drop so that the electrical charges can flow through the wires in electrical components and bring power to the devices we want to use. The flow of charge is measured as a variable called current. Current, I, is measured in amperes [A] where ampere is defined a coulomb per second (A = C/s)/ Since C 0 20 electrons, you can see that trillions of electrons are flowing through a circuit in any given second. Resistance, R, is the measure of how difficult it is to push electrons through a substance or device. Resistance has the units of Ohms [Ω], which is defined as the unit of volts/ampere. Page of 9

28 August 204 MENG 89L Blinkie Lab Figure : Resistor Another way to think of resistance is the ratio of voltage drop to the current for a given circuit. For example, a high resistance means that a large voltage drop is required to achieve a given current. When a voltage is applied across a circuit a current that depends on the equivalent resistance of the circuit is generated. Figure 2 The relationship between voltage (V ), current (I), and resistance (R) can be defined by Ohm s Law. The voltage drop needed to keep the charges moving through the wire is determined by the resistance. The resistance, or the ratio of voltage drop to current remains constant for all applied voltage drops. It is given by Equation (): R = V I () More commonly, this relationship is written V = IR. A schematic of this circuit is shown in Figure 3: Page 2 of 9

28 August 204 MENG 89L Blinkie Lab - AAA Battery + V I R (a) (b) Figure 3: (a) Breadboard. (b) Connectivity Diagram. On a more advanced side note, Benjamin Franklin established the convention that current flows from the positive to negative side of the voltage as shown in Figure 3. It was discovered many years later (unfortunately) that the current carriers are electrons and that they actually travel in the opposite direction of the established current convention (negative to positive). Anode Cathode (-) Anode (+) Cathode (a) (b) Figure 4: (a) LED. (b) LED Circuit Symbol A light emitting diode, or LED, is a two-lead semiconductor light source. An LED emits light when an appropriate current flows. The LED s brightness is dependent upon the current. Placing a resistor in series with an LED determines the circuit current which helps prevent burning out the LED, as connected below. R V Figure : Basic LED Circuit Breadboard Basics Prototyping circuit boards (or breadboards) are a more convenient way to test circuits than soldering components together. Wires or components can be pushed directly into the breadboard. However, certain conventions on the breadboard must be followed in order for the Page 3 of 9

VIN A0 A A2 A3 A4 A 9 8 7 6 4 3 2 28 August 204 MENG 89L Blinkie Lab circuit to work properly. A B C D E F G H I J A B C D E F G H I J Connected 0 0 Not Connected 20 20 0 0 2 2 30 30 (b) A B C D E F G H I J (a) Figure 6: (a) Real Circuit. (b) Circuit Schematic Diagram. A breadboard schematic is shown in Figure 6. Letters are used to identify vertical columns, and numbers are used to identify horizontal rows. The second image shows how the vertical columns are connected. Current flows only along these internal connections. An advantage of this setup is that you can supply power, say +V, to and entire column on the breadboard or to a set of horizontal sockets. By connecting multiple groups of the horizontal sockets, you can carry the same voltage across greater proportions of the breadboard. Arduino AREF L 3 2 0 DIGITALr(PWM= ) TX RX Arduino TM ICSP 0 RESET ICSP2 TX0 RX0 ON IOREF RESET 3V3 V POWER ANALOGrIN Figure 7: Arduino UNO Arduino is a small computer (or microcontroller) that can easily interface with hardware. We can program the Arduino with another computer though the USB connection. Arduino can run with other computers or independently. It has a brain that called microcontroller which does all the computation. The microcontroller has different pins which communicate with other components. Page 4 of 9

28 August 204 MENG 89L Blinkie Lab In electronics there are two types of signals, analog and digital. An analog signal consists real voltage within a specific range. It can be 0, 2., -04.2443 or other values depends on the range. A digital signal consists of a series of binary values (0s and s). A 0 refers to off or low voltage (LOW) and refers to on or high voltage (HIGH). Arduino has 3 types of pins. Digital in and out (I/O), analog out, and analog in. The Arduino s pins can be used in many different situations and combinations. Arduino can change the value of output pins with respect to the computer s commands or the value of input pins. More than pins, there are some preassembled circuits that can easily attach to the Arduino that are called shields. With shields, Arduino can connect to different instruments directly. Figure 8: Arduino Sketch Pad Arduino comes with a software to write codes (or algorithms) named sketch pad. Codes in sketch pad are compiled (or collected) and then sent (or flashed) onto the Arduino s microcontroller with communication through the USB cable. There are several examples and tutorials in the sketch pad. More than regular codes there are several prewritten codes (libraries) which are available in sketch pad. There are different commands in codes. There are several libraries that provide access to prewritten commands. Sketch pad has some libraries and we can add more in case we need more commands. Code Structure Commenting is necessary for good programming practices. Comments are not executed in the program and allow a programmer explain how the code works for future reference. For commenting a single line, use two forward slashes (//) and the write the comment. // Blink LED code, c r e a t e d 8/2/4 Page of 9

28 August 204 MENG 89L Blinkie Lab To add a comment that spans multiple lines, enter /* to start the comment section and */ to end the comment. /* 2 Arduino Blink LED 3 Robotics LLC Lab, c r e a t e d 8/2/4 4 */ The setup function is one of two main loops in any Arduino code. This function contains instructions that are used only once when the Arduino is turned or reset. void setup ( ) 2 { 3 4 } The setup function is useful for setting up which pins are inputs or outputs and other functions. Pins set to be inputs receive signals and output pins control physical hardware (like lighting an LED). Example code is shown below: void setup ( ) 2 { 3 pinmode ( 2, OUTPUT) ; // Set d i g i t a l pin 2 as output 4 pinmode (, INPUT) ; // Set d i g i t a l pin as input } The main loop contains the main code that is executed repeatedly. Example code is shown below: /* 2 Arduino Blink LED 3 Robotics LLC Lab, c r e a t e d 8/2/4 4 */ 6 void setup ( ) 7 { 8 9 } 0 void loop ( ) 2 { 3 // Main code i s placed here 4 } Laboratory Exercises. Wait for the TAs to explain how the pins are connected to each other in the breadboard, properties of LEDs, and the Arduino. Try to find input and output pins. 2. Use Figure 2 to read the resistor value. After the TAs explained the multimeter, use the multimeter to measure the resistor value. Be sure you have the right resistor (220 Ω). For future reference, DO NOT MEASURE CURRENT IN PARALLEL. Page 6 of 9

28 August 204 MENG 89L Blinkie Lab 0 o RX0 2 3 4 6 7 8 9 0 2 DIGITALWnPWM= ICSP2 TX0 RESET 3 AREF 3. Use jumper wires and make the circuit that you have in the figure below. (DO NOT CONNECT ANY THING TO THE USB PORT OR POWER SOURCE BEFORE CHECKING WITH TAs). The wrong connection in Arduino can damage the main board. L TX RX ON TM Arduino I F G H A B C D E 0 A B C D E F G H I J 30 30 A A4 A3 A2 2 2 A A0 VIN 20 20 V 3V3 RESET ANALOGWIN 0 POWER J IOREF ICSP Figure 9: Connection Diagram 4. Now open the sketchpad and wait for TAs to show you how to find the right port number and settings.. In sketchpad, follow the file path File, Examples, 0.Basics, and click on Blink. Copy the whole code and paste the code into a new sketch. Wait for the TAs to explain how the program functions. There are some extra spaces in handout for your notes. Be sure you take notes for your later references. Ask TAs if you do not understand something in the code. Figure 0: File Path Page 7 of 9

28 August 204 MENG 89L Blinkie Lab /* 2 Blink 3 Turns on an LED on f o r one second, then o f f f o r one second, r e p e a t e d l y. 4 This example code i s i n the p u b l i c domain. 6 */ 7 8 // Pin 3 has an LED connected on most Arduino boards. 9 // g i v e i t a name : 0 i n t l e d = 3 ; 2 // the setup r o u t i n e runs once when you p r e s s r e s e t : 3 void setup ( ) { 4 // i n i t i a l i z e the d i g i t a l pin as an output. pinmode ( led, OUTPUT) ; 6 } 7 8 // the loop r o u t i n e runs over and over again f o r e v e r : 9 void loop ( ) { 20 d i g i t a l W r i t e ( led, HIGH) ; // turn the LED on (HIGH i s the v o l t a g e l e v e l ) 2 delay (000) ; // wait f o r a second 22 d i g i t a l W r i t e ( led, LOW) ; // turn the LED o f f by making the v o l t a g e LOW 23 delay (000) ; // wait f o r a second 24 } 6. After you copied the code and TAs explained them to you, you can send your code to the Arduino. Connect your USB cable to the computer and the larger end to the Arduino. Now click the Upload (or Arrow) button to send the code to the Arduino. Changing the Blinking parameters. Now we want to change some parameters to have the LED on for 0. second and off for 0. second (eg: delay(000) = delay for second. 2. With your knowledge try to change the blinking pattern to have the LED on for 0. sec and off for 0. sec. (Hint: you do not have to change any thing in the hardware. It is just some small changes in the code). Try to find the parameters that can change the pattern. Ask a TA if you have any questions. 3. To save the file for latter, ask a TA on how to save the code to your U-drive. You can also email the code to yourself, save the code on a flash drive, or other methods. 4. Unassemble the circuit and put every thing back in the boxes.. Please do not leave the lab if you have questions about the lab exercises. Page 8 of 9