IME-100 Interdisciplinary Design and Manufacturing

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

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

Arduino Prof. Dr. Magdy M. Abdelhameed

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

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

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

AT42QT101X Capacitive Touch Breakout Hookup Guide

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 Uno Microcontroller Overview

TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO

GET YOUR DRAGONBOARD UP TO DATE

Introduction to Microcontrollers Using Arduino. PhilRobotics

Introduction to Arduino. Wilson Wingston Sharon

Blinking an LED 1 PARTS: Circuit 2 LED. Wire. 330Ω Resistor

More Arduino Programming

Arduino Part 2. Introductory Medical Device Prototyping

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

keyestudio Keyestudio MEGA 2560 R3 Board

Arduino 07 ARDUINO WORKSHOP 2007

FUNCTIONS For controlling the Arduino board and performing computations.

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

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

EEG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

TABLE OF CONTENTS INTRODUCTION LESSONS PROJECTS

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

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

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

Arduino Programming Part 4: Flow Control

FUNCTIONS USED IN CODING pinmode()

Robotics/Electronics Review for the Final Exam

TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO

1/Build a Mintronics: MintDuino

Building your own special-purpose embedded system gadget.

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

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

USER MANUAL ARDUINO I/O EXPANSION SHIELD

ARDUINO LEONARDO WITH HEADERS Code: A000057

AT42QT1010 Capacitive Touch Breakout Hookup Guide

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

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

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

Laboratory 1 Introduction to the Arduino boards

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

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

Robotics and Electronics Unit 5

ARDUINO UNO REV3 Code: A000066

Arduino Programming. Arduino UNO & Innoesys Educational Shield

Arduino Uno R3 INTRODUCTION

Lab 2 - Powering the Fubarino. Fubarino,, Intro to Serial, Functions and Variables

Counter & LED (LED Blink)

DUAL PUSh BUTTON PLUG[v1.1]

BASIC ARDUINO WORKSHOP. Mr. Aldwin and Mr. Bernardo

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

Arduino ADK Rev.3 Board A000069

Introduction to Arduino

What s inside the kit

EXPERIMENT2. V3 Robot Navigates Autonomously with Feelers and Infrared Sensors

ARDUINO LEONARDO ETH Code: A000022

Sensors Provide Feedback to Real World Applications. Jared Gordon. Professor: Pushkin Kachroo. Transpotronics

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

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

How to use the Zduino LEE Module with the Trainer Board

ArdOS The Arduino Operating System Quick Start Guide and Examples

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

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

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

PDF of this portion of workshop notes:

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

Monitor your home remotely using the Arduino

Connecting Arduino to Processing

ARDUINO UNO REV3 SMD Code: A The board everybody gets started with, based on the ATmega328 (SMD).

Create your own wireless motion sensor with

PDF of this portion of workshop notes:

Lab 2 - Powering the Fubarino, Intro to Serial, Functions and Variables

Module 003: Introduction to the Arduino/RedBoard

Quickstart CHAPTER 1. Powering Up. Installing the Software

Arduino Uno. Arduino Uno R3 Front. Arduino Uno R2 Front

How to Use an Arduino

Arduino - DigitalReadSerial

CARTOOINO Projects Book

Lesson 8: Digital Input, If Else

ARDUINO. By Kiran Tiwari BCT 2072 CoTS.

The speaker connection is circled in yellow, the button connection in red and the temperature sensor in blue

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

ARDUINO YÚN Code: A000008

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

Electronic Brick Starter Kit

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

ARDUINO INDUSTRIAL 1 01 Code: A000126

Digispark DIY: the Smallest USB Arduino

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

micro:bit Lesson 2. Controlling LEDs on Breadboard

Introduction To Arduino

EK307 Lab: Microcontrollers

HOW TO INSTALL YAKINDU AND TRICKS ABOUT IT

Button Input: On/off state change

ARDUINO MEGA 2560 REV3 Code: A000067

RESET SIK GUIDE SCL SCA AREF GND ~11 ~10 13 RX TX ~9 8 7 ~6 ~5 4 ~3 DIGITAL (PWM~) 7-15V ON

SX1509 I/O Expander Breakout Hookup Guide

Quickstart Guide: Programming the Arduino ESP 8266

Transcription:

IME-100 Interdisciplinary Design and Manufacturing Introduction Arduino and Programming Topics: 1. Introduction to Microprocessors/Microcontrollers 2. Introduction to Arduino 3. Arduino Programming Basics Several online Tutorials are also available on the Arduino website http://arduino.cc/en/tutorial/homepage Online Arduino book http://www.introtoarduino.com/downloads/introarduinobook.pdf Simulate Arduino online http://123d.circuits.io/ 1

Introduction to Microprocessors The earlier processors were implemented in multiple printed circuit boards. Microprocessor is a processor implemented in a single integrated circuit. Brief history o In 1971, Intel introduced the first microprocessor in a single chip, the Intel 4004, which was a 4-bit processor running at 400 KHz clock Disadvantages o Does not have on-chip memory. o Cannot drive the I/O devices. o Does not have peripheral functions such as parallel I/O ports, timers, A/D converter, and so on. Microcontroller A computer on a chip. The chip contains: o Processor o RAM for holding data o EPROM/Flash for holding the programs o Input and output pins (link the microcontroller to the rest of the world). 2

Introduction to Arduino Arduino is an open-source physical computing platform based on a simple microcontroller board It has development environment for writing software for the board. Its programming language: Simplified version of C/C++. (Easy to learn) Why Arduino? o Inexpensive: ATmega328p: $2.50, Pre-assembled Arduino Uno board < $30 o Cross-platform o Simple and clear programming environment o Open source and extensible software C++ libraries and AVR-C code can be added o Open source and extensible hardware Hardware design is also open Users can extend it USB interface chip Digital connections USB port Crystal 5 V regulator Microcontroller Power connector 3 Analog inputs

Arduino Programming Process Arduino IDE is an Integrated development environment o Used for writing and downloading program to Arduino chip Setup process o Select a board type (the IDE supports several types of Arduino compatible boards) o Select a serial port (the communication interface between the Arduino board and your PC) Program structure All Arduino programs (sketches) contain: o void setup() o void loop() Uploading a sketch 1. Verify your code 2. Convert to binary 3. Upload to Arduino 4

Arduino Prep This should have already been done on your lab PCs. No need to do it again. Follow the following steps if you want to set up the Arduino programming environment on your own computer. Video tutorial is available on youtube, check out the following: http://www.youtube.com/watch?v=fcxza9_kg6s 1. Install the Arduino IDE software 2. Install a USB driver to let your computer recognize an Arduino board. This will install a serial port device through which the computer can talk to the Arduino. Installing the Arduino IDE Software Go to http://arduino.cc/en/main/software Download the latest version of Arduino for your system. o For the computers in the lab we the Windows version of the Arduino IDE software, but it is also available for other operating systems. o You can download the Windows installer which gets an executable file that automatically installs the software or get a zip file. If you get the zip file, you need to unzip it and you will see a folder named after the zip filename. o Open the folder. Finally you will see arduino-1.x.x folder (where x represents the version number). This is the folder where the Arduino software is installed in. There is no fancy installation tool or setup the software. o You can just copy the folder to anywhere on your disk drive. 5

Arduino Sketch Open the folder arduino-1.x.x Create a short cut on the Desktop for the executable, arduino.exe. o Right click on the exe and select Send to Desktop. Execute arduino.exe. o Ignore Security Warning and click the Run button. o Sketchbook folder disappeared message will be shown. o Do not worry. Just click OK You can find the Arduino folder is newly created. o This is your Sketchbook folder that is a kind of workspace where your source code will be saved. o Saving your source code into this folder is strongly recommended for later uses. Arduino Board Type Several options are available In this lab you will be using an Arduino Uno board o See http://arduino.cc/en/main/products for details o Select Arduino Uno from the Tools Board menu 6

Serial Port Serial Port is an entry or exit door through which you can send or receive data between the Arduino and your PC Modern laptops do not have serial ports anymore Do not worry! We can create a virtual serial port from a USB port o This means that the USB port connected to a cable will be considered as a serial port A virtual serial port should be installed for your computer to communicate with an Arduino board o The latest versions of the Arduino IDE handle this automatically o However, if the driver is not installed on your computer you need to follow the step-by-step instructions given below Please remember you have to select a serial port in Sketch after completing the instructions USB Driver Install This step is optional. It is needed only if the USB driver was not automatically installed as part of the Arduino IDE installation through the Windows installer. Connect an Arduino board to your computer using a USB cable o The Driver Software Installation message box will appear o Sooner or later it will fail o No need to worry, we are on the right track 7

USB Driver Install Open Device Manager from [Control Panel -- System and Security] Locate Other devices Unknown device Click Update Driver Software Select Browse my computer for device software. Find the drivers folder inside the arduino-1.x.x folder. Ignore this warning. Select Install this driver software anyway. 8

USB Driver Install To verify that the USB Driver is successfully installed: Make sure that Arduino UNO R3 is installed in the Ports (COM & LPT) Anytime when you connect the Arduino board to the PC, the port will be shown under the ports list Your computer can now talk to the Arduino through the serial port Selecting the Arduino Serial Port The final and important step is to select a serial port for your Arduino Sketch. Now your PC is ready to talk the Arduino via the serial port. 9

Arduino Programming Basics Refer to the Arduino Language Reference: http://arduino.cc/en/reference/homepage Sketch o That is what a program called in Arduino lingo o It is code that is uploaded to and run on the Arduino board Comments used to enhance program readability and documentation o Multiline comments /* comments start with the slash and * sign it can be multilines should end with * and the slash just like the line below */ Everything between /* and */ is comment and will be ignored by the processor o Single line comments // two slashes are an indicator of starting comments. Variable o A place for storing a piece of data o It has a Name, a Type, a Value Example: int ledpin = 13; ledpin is the variable Name, int the Type, 13 is value o Whenever you use the variable name in the code, the value will be retrieved o The value can be changed while your program is running This is why we call it a variable Data type o boolean: true/false o char: -128 ~ 127 byte: 0 ~ 255 o int: -32,768 ~ 32,767 unsigned int: 0 ~ 65,535 o long: 32-bits integer unsigned long: 32-bits o float: 32-bits real number double: (= float in Arduino Uno) 10

Function A named piece of code with a specific task and that can be called/used as many times as needed 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 your Arduino sketch: setup() loop() Digital vs. Analog Signals This is called once when your program starts Good place to initialize anything This is called over and over, indefinitely Digital: Only two values are allowed o 1 or 0 o True or False o HIGH or LOW Analog: Continuous range of values o 0~1023 The pins on the Arduino o They can be configured as either inputs or outputs Sneak peek of basic functions to know o pinmode: Configure the specified pin to either an input or output o digitalwrite: Write a HIGH or LOW to a digital PIN o digitalread: Read a value from the specified digital pin. Returns HIGH or LOW o analogread: Read analog value from the specified analog pin. Returns 0~1023 o analogwrite: Write analog value to the specified pin o delay: Pauses the program for the amount of the specified time (in milliseconds) 11

Arduino Programming Example You can find helpful tutorials and examples at the Arduino website: http://arduino.cc/en/tutorial/homepage The following example shows how to work with an Arduino connected to a 10 KΩ resistor, a pushbutton switch and an on-board LED. A program is implemented to control the on-board LED (attached to pin 13) based on the external switch input. So if the button is pressed the LED is on and when the button is released the LED is off. 12

/* Button - Turns on and off a light emitting diode (LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2. The circuit: * LED attached from pin 13 to ground * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground created 2005 by DojoDave <http://www.0j0.org> modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/tutorial/button */ // constants won't change. They're used here to // set pin numbers: const int buttonpin = 2; // the number of the pushbutton pin const int ledpin = 13; // the number of the LED pin // 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); } } Exercise: Modify your program so that when the button is pressed the LED is turned on, stays on for 3 seconds and then turns itself off. When the button is not pressed the LED remains off. Hint: use the Arduino delay(.) function. 13

Exercise: Traffic Lights Controller 1. Build the traffic lights circuit First build the traffic lights circuit by wiring three LEDs (green, yellow, red) in series to 120Ω resistors each to three digital pins of the Arduino. To control the operating mode of the traffic lights connect a switch to a digital pin using a 10KΩ resistor in a configuration similar to that shown in the schematic diagram in page 19. 2. Write Arduino program to control the traffic lights Write a program that implements the behavior for a proper operation of the traffic lights similar to what you find at an intersection on a street. The traffic lights will be controlled by the switch. When the program starts, it checks the status of the switch and if the switch is ON the lights behave as follows: a) Green LED is on for 5 seconds (yellow and red are off) b) Yellow LED is on for 2 seconds (green and red are off) c) Red LED is on for 3 seconds (green and yellow are off) d) Red LED goes off for 1 second before returning back to the first step a) e) The program repeats the above steps a) to d) as long as the switch stays on When the control switch is turned OFF, the traffic lights switch to flashing red light mode. In this mode the red LED turns on for 1 second and turns off for 1 second. It repeats this mode as long as the control switch stays off. The program continues indefinitely, running in either of the two operating modes based on the status of the switch. 14