IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

Similar documents
IME-100 ECE. Lab 4. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

IME-100 Interdisciplinary Design and Manufacturing

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

University of Portland EE 271 Electrical Circuits Laboratory. Experiment: Arduino

micro:bit Lesson 2. Controlling LEDs on Breadboard

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

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

Arduino Prof. Dr. Magdy M. Abdelhameed

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

Introduction to Microcontrollers Using Arduino. PhilRobotics

Arduino Programming. Arduino UNO & Innoesys Educational Shield

Specification. 1.Power Supply direct from Microcontroller Board. 2.The circuit can be used with Microcontroller Board such as Arduino UNO R3.

Thursday, September 15, electronic components

Serial.begin ( ); Serial.println( ); analogread ( ); map ( );

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

Lab 02 Arduino 數位感測訊號處理, SPI I2C 介面實驗. More Arduino Digital Signal Process

Arduino - DigitalReadSerial

Arduino Uno Microcontroller Overview

GET YOUR DRAGONBOARD UP TO DATE

ME456: Mechatronics. Prof. Clark Radcliffe. Do you have the knack? Joonho Lee, TA. What s Mechatronics? Mechatronics

TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO

Robotics/Electronics Review for the Final Exam

EXPERIMENT 7 Please visit to learn all features of arduino before you start the experiments

More Arduino Programming

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

Arduino Part 2. Introductory Medical Device Prototyping

TABLE OF CONTENTS INTRODUCTION LESSONS PROJECTS

PDF of this portion of workshop notes:

TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO

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

DUAL PUSh BUTTON PLUG[v1.1]

Arduino Programming Part 4: Flow Control

1/Build a Mintronics: MintDuino

Create your own wireless motion sensor with

Freeduino USB 1.0. Arduino Compatible Development Board Starter Guide. 1. Overview

Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas

Outline for Today. Lab Equipment & Procedures. Teaching Assistants. Announcements

keyestudio Keyestudio MEGA 2560 R3 Board

3.The circuit board is composed of 4 sets which are 16x2 LCD Shield, 3 pieces of Switch, 2

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Building your own special-purpose embedded system gadget.

IME-100 ECE. Lab 5. Electrical and Computer Engineering Department Kettering University

Smart Objects. SAPIENZA Università di Roma, M.Sc. in Product Design Fabio Patrizi

Arduino Micro Breadboard Laboratory Interface Processor (Micro BLIP) User Manual

What s inside the kit

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut

USER MANUAL ARDUINO I/O EXPANSION SHIELD

3. The circuit is composed of 1 set of Relay circuit.

Introduction To Arduino

ARDUINO MINI 05 Code: A000087

Experiment 4.A. Speed and Position Control. ECEN 2270 Electronics Design Laboratory 1

Goal: We want to build an autonomous vehicle (robot)

FUNCTIONS For controlling the Arduino board and performing computations.

Intro to Arduino. Zero to Prototyping in a Flash! Material designed by Linz Craig and Brian Huang

Prototyping & Engineering Electronics Kits Basic Kit Guide

AT42QT101X Capacitive Touch Breakout Hookup Guide

ECE 2036 Lab 4 Setup and Test mbed I/O Hardware Check-Off Deadline: Thursday, March 17, Name:

Laboratory 1 Introduction to the Arduino boards

Workshop on Microcontroller Based Project Development

Introduction to Programming. Writing an Arduino Program

SIK Experiment Guide for Arduino - V3.3

Digispark DIY: the Smallest USB Arduino

AT42QT1010 Capacitive Touch Breakout Hookup Guide

PDF of this portion of workshop notes:

Introduction to Arduino. Wilson Wingston Sharon

cs281: Introduction to Computer Systems Lab03 K-Map Simplification for an LED-based Circuit Decimal Input LED Result LED3 LED2 LED1 LED3 LED2 1, 2

Overview. Multiplexor. cs281: Introduction to Computer Systems Lab02 Basic Combinational Circuits: The Mux and the Adder

Arduino Workshop. Overview. What is an Arduino? Why Arduino? Setting up your Arduino Environment. Get an Arduino based board and usb cable

ARDUINO. By Kiran Tiwari BCT 2072 CoTS.

Robotics and Electronics Unit 5

Figure 26 CC Debugger Interface

Arduino: What is it? What can it do?

Microcontrollers for Ham Radio

Arduino Course. Technology Will Save Us - Tim Brooke 10th August Friday, 9 August 13

Lecture 6: Embedded Systems and Microcontrollers

BASIC ARDUINO WORKSHOP. Mr. Aldwin and Mr. Bernardo

WEEK PRactice. Turning on LED with a Switch. Learning Objective. Materials to Prepare. Summary of Class. Project Goal. Hardware Expression

Physics 364, Fall 2012, Lab #9 (Introduction to microprocessor programming with the Arduino) Lab for Monday, November 5

StenBOT Robot Kit. Stensat Group LLC, Copyright 2018

Arduino: Serial Monitor Diagrams & Code Brown County Library

1 Overview. 2 Basic Program Structure. 2.1 Required and Optional Parts of Sketch

Project 2: Sensor Light

Review of the syntax and use of Arduino functions, with special attention to the setup and loop functions.

LAMPIRAN I (LISTING PROGRAM)

ENGR 40M Project 4b: Displaying ECG waveforms. Lab is due Monday June 4, 11:59pm

Touch Board User Guide. Introduction

Digital I/O Operations

ARDUINO LEONARDO WITH HEADERS Code: A000057

Introduction to Arduino

CARTOOINO Projects Book

ARDUINO LEONARDO ETH Code: A000022

Microcontrollers and Interfacing week 8 exercises

Arduino 07 ARDUINO WORKSHOP 2007

Contents at a Glance.

Thumb Joystick Retail. Tools and parts you'll need. Things you'll want to know. How does it work? Skill Level: Beginner. by MikeGrusin March 22, 2011

Rear Distance Detection with Ultrasonic Sensors Project Report

Schedule. Sanford Bernhardt, Sangster, Kumfer, Michalaka. 3:10-5:00 Workshop: Build a speedometer 5:15-7:30 Dinner and Symposium: Group 2

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.

Digital Design through. Arduino

Transcription:

IME-100 ECE Lab 3 Electrical and Computer Engineering Department Kettering University 3-1

1. Laboratory Computers Getting Started i. Log-in with User Name: Kettering Student (no password required) ii. iii. iv. IME-100 information (Lab presentation, files, etc.) in folder on desktop Arduino programming software on desktop At the end of lab, Logout of computer; arrange keyboard and mouse 2. Laboratory kit i. Arduino board, circuit prototyping breadboard, electronic components: LEDs, resistors, pushbutton switch, potentiometer ii. At the end of lab, turn instrument power off, dismantle circuit, unplug Arduino USB from PC, neatly arrange leads on bench 3-2

IME-100, ECE Lab3 Arduino Microcontroller In this laboratory exercise, you will do the following: Learn about microcontrollers Identify the main components of Arduino microcontroller Understand the Arduino programming process Write program to Arduino microcontroller Build simple LED and switch circuits on a breadboard and connect to Arduino Exercise: Build a traffic light circuit based on Arduino 3-3

What is a Microcontroller? Microcontroller is a single computer chip that incorporates a processor (CPU) and lots of other modules such as: Memory Timer functions Serial communication interfaces A/D, D/A converter Parallel I/O interface CPU is the central processing unit that is in charge of executing program instructions and controlling the system. Embedded systems A special purpose computer system designed to perform a dedicated function. Very specific requirements. 3-4

Embedded Microprocessors are Everywhere In your home: Alarm Clock, TV, microwave, thermostat In the office: copy machine, telephone, computer monitor In the hospital: MRI machine, heart monitor Even in your pocket: cell phone, car key remote 5

Arduino What is Arduino? A low-cost, open-source physical computing platform based on a simple microcontroller board Development environment for writing software for the board. Programming language: Simplified version of C/C++. (Easy to learn) USB port USB interface chip Power connector Digital connections Microcontroller 5 V regulator Crystal Analog inputs Refer to the Arduino website for more information: https://www.arduino.cc/en/guide/introduction https://www.arduino.cc/en/tutorial/foundations 3-6

Programming the Arduino The Arduino Programming environment is accessible from your PC desktop. The Arduino software programming environment is free and can be downloaded from the following website: http://www.arduino.cc/en/main/software Start the program by double clicking its icon on your PC desktop: 3-7

Programming the Arduino A good starting point to learn programming is to go over example code: Open the Blink example code: File -> Examples -> 01.Basics -> Blink 3-8

Programming the Arduino Click to Verify syntax correctness of program Click to upload code to the Arduino board Comment (for humans only, ignored by the Arduono) setup (section of the code run only once at beginning) loop (section of the code That runs forever ) 3-9

Variable Programming the Arduino Basic Programming Concepts A place for storing a piece of data. It has a Name, a Type, a Value. Example: int ledpin = 13; ledpin: Name int: Type 13: Value Whenever you use the variable name in the code, the value will be retrieved. The value can be changed while your program is running. This is why we call it a variable. Data type. Arduino supports the following data types for variables boolean : true/false char : -128 ~ 127 byte : 0 ~ 255 int : -32,768 ~ 32,767 unsigned int : 0 ~ 65,535 long unsigned long : float double : (= float in Arduino). 3-10

Function A named piece of code that can be used form elsewhere in your program. Example: void setup() // return type, name of the function, parameters { pinmode(ledpin, OUTPUT); //call pinmode function with two parameters } Two special functions that you should include in Arduino. setup() This is called once when your program starts. Good place to initialize anything. loop() Programming the Arduino Basic Programming Concepts This is called over and over. 3-11

Programming the Arduino Basic Programming Concepts Comments Multiline comments /* comments start with the slash and * sign it can extend on multiple lines should end with * and the slash just like the line below */ Everything between /* and */ will be ignored. Single line comments // two slashes are an indicator of starting comments. 3-12

Programming the Arduino Basic Programming Concepts Digital: Only two values are allowed. 1 or 0 True or False HIGH or LOW Analog: Continuous range of values 0~1023 The pins on the Arduino They can be configured as either inputs or outputs. Sneak peek of basic functions to know pinmode: Configure the specified pin to either an input or output. digitalwrite: Write a HIGH or LOW to a digital PIN. digitalread: Read a value from the specified digital pin. Returns HIGH or LOW. analogread: Read an analog value from the specified analog pin. Returns 0~1023. analogwrite: Write an analog value to the specified pin. delay: Pauses the program for the amount of the specified time (in milliseconds). Refer to the Arduino website for more information: https://www.arduino.cc/en/reference/homepage 3-13

Programming the Arduino Basic Programming Concepts /* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int ledpin = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinmode(ledpin, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalwrite(ledpin, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalwrite(ledpin, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } 3-14

Programming the Arduino Breadboard Also known as Proto Board A construction base for prototyping electronics. Soldering is not required. Sockets are already connected as shown Outside (both ends): vertically Inside: horizontally. 3-15

Programming the Arduino Breadboard From Schematic diagram to actual wiring: Build an LED circuit on the Breadboard and test your Arduino code with it 220 Ω 3-16

Controlling LED with a button Add a pushbutton switch to control the LED: Read the status of the button and turn on the LED if the button is pressed, and turn it off otherwise. 220 Ω 10 kω 3-17

Controlling LED with a button const int buttonpin = 7; const int ledpin = 9; // variables will change: int buttonstate = 0; // variable for reading the //pushbutton status void setup() { // initialize the LED pin as an output: pinmode(ledpin, OUTPUT); // initialize the pushbutton pin as an input: pinmode(buttonpin, INPUT); } void loop() { // read the state of the pushbutton value: buttonstate = digitalread(buttonpin); // check if the pushbutton is pressed. // if it is, the buttonstate is HIGH: if (buttonstate == HIGH) { // turn LED on: digitalwrite(ledpin, HIGH); } else { // turn LED off: digitalwrite(ledpin, LOW); } } 3-18

Traffic Light Controller using Arduino Wire three LEDs (red, yellow, green) on your breadboad to the Arduino pins 5, 4, and 3, and connect 100 Ω series resistors to ground for each LED as shown in the diagram. Modify your previous Arduino program so that it blinks the three LEDs in the following manner: First, only the Green LED is ON for four second Next, only the Yellow LED is ON for one second Then, only the Red LED is ON for four seconds The program will repeat the above sequence indefinitely until the power is disconnected. 3-19

Traffic Light Controller using Arduino int redpin = 5; int yellowpin = 4; int greenpin = 3; void setup() { pinmode(redpin, OUTPUT); pinmode(yellowpin, OUTPUT); pinmode(greenpin, OUTPUT); } void loop() { digitalwrite(greenpin, HIGH); digitalwrite(yellowpin, LOW); digitalwrite(redpin, LOW); delay(4000); //wait 4 seconds digitalwrite(greenpin, LOW); digitalwrite(yellowpin, HIGH); delay(1000); //wait 1 second digitalwrite(yellowpin, LOW); digitalwrite(redpin, HIGH); delay(4000); //wait 4 second } 3-20

Exercise 1: Traffic Light with override feature Add a pushbutton switch to control the operating mode of the traffic light: First, wire a pushbutton switch as shown in slide 17, using a 10 kω resistor to one of the pins on your Arduino. Next, write an Arduino program that controls your traffic light to operate in one of two operating modes at any time based on the status of the pushbutton switch. If the button is not pressed the traffic light operates in a normal sequence (Green Yellow Red) with the same timing as before. Otherwise, when an officer needs to override the normal operating mode he/she can press the button, in which case only the red light flashes on and off once per second. Demonstrate your working traffic light circuit with the button control option to your instructor 3-21

Exercise 2: Traffic Light with Pedestrian Crossing Timer The task in this exercise is to provide pedestrians with control for activating a walk signal to cross a street. Assume the traffic signal stays green until pedestrians presses the button when they want to cross the street. After the button is pressed wait for 5 seconds and switch the signal to yellow, which will then turn to red after 1 second. Use white LED as a walk signal for pedestrians. Turn on the walk signal ( white LED) for 5 seconds to notify pedestrians that it is safe to cross the street. After the 5 seconds pass, flash the white LED for 3 seconds as a warning for the pedestrians before switching off the white LED. After turning off the white LED for one second then turn the traffic signal back to green. 3-22

Homework: Making Connections and For the Curious You Due: Beginning of 4 th Week Lab Making Connections You are now able to design and implement a traffic light circuit using two different solutions: a) Using a hardware approach b) Using a microcontroller, programming, and basic circuit elements Discuss the benefits and drawbacks of each approach based on different criteria, such as cost, complexity, time to market, and design flexibility. For the Curious You Research and brainstorm/painstorm with your lab partners and present innovative ways of improving specific existing products/services by using a microcontroller such as the Arduino. For extra credit opportunity propose new a product/service with good analysis on its market potential. Turn in a 2-3 pages report for your answers. 3-23

Homework: Online tutorial From the online tutorial and additional resources come prepared to the next week class with background information on the following topics: Displaying data to serial terminal Analog output Interfacing sensors Bluetooth communication Next week: Use a motor control circuit to drive the robot Basic robot control Robotic sensors Use ultrasonic sensor to avoid crashes Light sensor and line following algorithm 3-24

Finishing Up (and to get full-credit in the lab) 1. Clean-up at bench Leave it better than you found it! i. Pick-up any spare parts, wire-trimmings, etc ii. Detangle and coil wire leads iii. Soldering stations and tools neatly arranged iv. Turn off instrument power, arrange neatly v. Logout of computer; arrange keyboard and mouse vi. Neatly arrange the chairs 2. Check-out with the instructor i. Leave the check-out sheet with your group names at your station 3-25

Lab 3 Check-Out Sheet (to be left on the bench at the end of lab) Group Members (please print name clearly): Instructor (check all that apply): Traffic Light basic operation demonstrated Traffic Light with override feature demonstrated Traffic Light with potentiometer for timing control and with override feature demonstrated Computer Logout Bench clean-up Wires, detangled and coiled, Disposal of wire clipping, etc. Arduino circuit dismantled Arduino unplugged from PC USB Instrument power off and arranged Keyboard and Mouse arranged Chairs arranged Additional Comments: 3-26