Distributed Real- Time Control Systems. Lecture 3 Embedded Systems Interfacing the OuterWorld

Size: px
Start display at page:

Download "Distributed Real- Time Control Systems. Lecture 3 Embedded Systems Interfacing the OuterWorld"

Transcription

1 Distributed Real- Time Control Systems Lecture 3 Embedded Systems Interfacing the OuterWorld 1

2 Bibliography ATMEGA 328 Datasheet. arduino.cc Book: Arduino Cookbook, 2nd Ed. Michael Margolis O Reilly,

3 Interfaces I/O Digital I/O Analog Input PWM Serial (USART) SPI TWI 3

4 Digital I/O Port function (input/output) is programmablebyenablingand disabling some switches. 4

5 Output Modes Output High Output Low 5

6 Input Modes Input floating (high impedance) Input with Internal Pull Up 6

7 Digital I/O Registers 7

8 Basic Digital Output - Driving LED s Caution! Source/Sink limits 40mA at5vcc How much current passes through the LED s? const int led1 = 7; // LED1 connected to digital pin 7 const int led2 = 8; // LED2 connected to digital pin 8 const int rate = 500; // Delay in ms to commute leds int counter = 0; // loop counter void setup() // enable output on the led1 pin pinmode(led1, OUTPUT); // enable output on the led2 pin pinmode(led2, OUTPUT); // initialize serial comms to host Serial.begin(9600); void loop() Serial.println(++counter); // print rate to serial monitor digitalwrite(led1, HIGH); // set the LED1 on digitalwrite(led2, HIGH); // set the LED2 off delay(rate); // wait duration digitalwrite(led1, LOW); // set the LED1 off digitalwrite(led2, LOW); // set the LED2 on delay(rate); 8

9 Basic Digital Input Reading Switches Must use pull- ups. int inputpins[] = 2,3,4,5; // create an array of switch inputs int ledpins[] = 10,11,12,13; // create array of output LEDs void setup() for(int index = 0; index < 4; index++) pinmode(ledpins[index], OUTPUT); // LED as output pinmode(inputpins[index], INPUT); // pushbutton as input digitalwrite(inputpins[index],high); // enable pull- ups void loop() for(int index = 0; index < 4; index++) int val = digitalread(inputpins[index]); // read input value // check if the switch is pressed if (val == LOW) // turn LED on if switch is pressed digitalwrite(ledpins[index], HIGH); else // turn LED off digitalwrite(ledpins[index], LOW); 9

10 Digital Inputs Switch Debouncing // debounce returns true if the switch in the given pin // is closed and stable boolean debounce(int pin) boolean state; boolean previousstate; // store switch state previousstate = digitalread(pin); for(int counter=0; counter < debouncedelay; counter++) // wait for 1 millisecond delay(1); // read the pin state = digitalread(pin); if( state!= previousstate) // reset the counter if the state changes counter = 0; // and save the current state previousstate = state; // here when the switch state has been stable // longer than the debounce period return state; 10

11 Reading Incremental Encoders Incremental RotaryEncoders have two quadrature channels. Direction of rotation can be measured by detectingthe raising/falling edge of one channel and checking the value of the other. 11

12 Reading Incremental Encoders Polling based solution const int encpina = 4; const int encpinb = 2; const int encspr=16; //Steps Per Revolution : Depends on HW int angle = 0; int val; int encpos = 0; boolean encalast = LOW; // remembers the previous state void setup() pinmode(encpina, INPUT); pinmode(encpinb, INPUT); digitalwrite(encpina, HIGH); //enable pull ups digitalwrite(encpinb, HIGH); Serial.begin(9600); void loop() boolean enca = digitalread(encpina); if ((encalast == HIGH) && (enca == LOW)) (digitalread(encpinb) == LOW? encpos- - : encpos++); angle=(encpos%encspr)*360/encspr; Serial.print(encoderPos); Serial.print(" "); Serial.println(angle); encoderalast = encodera; 12

13 Reading Incremental Encoders Interrupt Based Solution An Interrupt Service Routine (ISR) can associated to a falling edge on encoder channel A. Notes: Only one ISR can run at a time. ISR cannot have paramenters nor return values. Variables that are changed in ISRs must be marked volatile. Code in the ISR should be as fast as possible. Serial data received while in the ISR may be lost. In Arduino UNO you can attachinterrupts to Pins 2 and 3. Function millis() do not increment while in an ISR. Function delay() does not work inside and ISR. Function delaymicroseconds() does not use conters so it works. const int encoderpina = 2; const int encoderpinb = 4; int Pos, oldpos; volatile int encoderpos = 0; //maychange at any time void doencoder() //ISR for FALLING edge on channel A if (digitalread(encoderpina) == digitalread(encoderpinb)) encoderpos++; // count up if both encoder pins are the same else encoderpos- - ; // count down if pins are different void setup() pinmode(encoderpina, INPUT); pinmode(encoderpinb, INPUT); digitalwrite(encoderpina, HIGH); digitalwrite(encoderpinb, HIGH); Serial.begin(9600); attachinterrupt( digitalpintointerrupt( encoderpina ), doencoder, FALLING); void loop() nointerrupts(); //disable interrupts Pos = encoderpos; //critical section interrupts(); //enable interrupts if(pos!= oldpos) Serial.println(Pos,DEC); oldpos = Pos; delay(1000); 13

14 Reading Pulse Width Signal Some sensorscommunicate output via Pulse Width Duration. Arduino has a function (pulsein()) to read pulse durations. Example: Parallax PING))) Sonar. const int pingpin = 5; void setup() Serial.begin(9600); void loop() int cm = ping(pingpin) ; Serial.println(cm); delay(500); int ping(int pingpin) long duration, cm; // The PING))) is triggered by a HIGH pulse of 2 or more usec. pinmode(pingpin, OUTPUT); digitalwrite(pingpin, LOW); delaymicroseconds(2); digitalwrite(pingpin, HIGH); delaymicroseconds(5); digitalwrite(pingpin, LOW); pinmode(pingpin, INPUT); duration = pulsein(pingpin, HIGH); // speed of sound 29 usec per centimeter. cm = duration/29/2; return cm ; 14

15 Analog Input ARDUINO UNO ATMEL 328 ADC Characteristics 10- bit Resolution (0x000 0x3FF) 0.5 LSB Integral Non- linearity ± 2 LSB Absolute Accuracy μs Conversion Time Free Running or Single Conversion Mode Interrupt on ADC Conversion Complete Sleep Mode Noise Canceler The ADC is optimized for analog signals with an output impedance of approximately 10 kω or less. Up to 76.9 ksps (Up to 15 ksps at Maximum Resolution) 6 Multiplexed Single Ended Input Channels Temperature Sensor Input Channel 0 - VCC ADC Input Voltage Range Selectable 1.1V ADC ReferenceVoltage Voltage Range Externally Selectable 15

16 Analog Input Example Light depedent LED blinking. Analog Read returns values between 0 (min) and 1024 (max). const int ledpin = 13; // LED connected to digital pin 13 const int sensorpin = 0; // connect sensor to analog input 0 // the next two lines set the min and max delay between blinks const int minduration = 100; // minimum wait between blinks const int maxduration= 1000; // maximum wait between blinks void setup() pinmode(ledpin, OUTPUT); // enable output on the led pin Serial.begin(9600); // initialize Serial void loop() int rate = analogread(sensorpin); // read the analog input //scales the blink rate between the min and max values rate = map(rate, 200, 800, minduration, maxduration); rate = constrain(rate, minduration,maxduration); // saturate Serial.println(rate); // print rate to serial monitor digitalwrite(ledpin, HIGH); // set the LED on delay(rate); // wait duration dependent on light level digitalwrite(ledpin, LOW); // set the LED off delay(rate); 16

17 Measuring Voltages If voltages are in the range [0 5]V, they can bemeasured directly. Otherwise we need voltage dividers. Question: How to measure negative voltages? 17

18 Analog Output via PWM Analog Output can be emulated via Pulse Width Modulation. Arduino function analogwrite(pin, value) generates a PWM signal with frequency ~500Hz and duty cycle proportionalto value. 0 <= value <= 255 pin = 3,5,6,9,10,11 18

19 Modulate LED Brightness via PWM Fade LED brightness in and out. const int firstled= 3; const int secondled = 5; const int thirdled = 6; int brightness = 0; int increment = 1; void setup() // pins driven by analogwrite do not need to be declared as outputs void loop() if(brightness > 255) increment = - 1; // count down after reaching 255 else if(brightness < 1) increment = 1; // count up after dropping back down to 0 brightness = brightness + increment; // write the brightness value to the LEDs analogwrite(firstled, brightness); analogwrite(secondled, brightness); analogwrite(thirdled, brightness ); delay(10); // mean 2.55 secs to fade up or down 19

20 Generating Frequencies Example: Playing Tones const int speakerpin = 9; // connect speaker to pin 9 const int pitchpin = 0; // frequency of the tone const int durationpin = 1; // duration of the tone void setup() void loop() int sensor0reading = analogread(pitchpin); // frequency int sensor1reading = analogread(durationpin); // duration // map the analog readings to a meaningful range int frequency = map(sensor0reading, 0, 1023, 100,5000); int duration = map(sensor1reading, 0, 1023, 100,1000); tone(speakerpin, frequency, duration); // play the tone delay(duration); //wait for the tone to finish 20

21 Driving High Power Devices Arduino PINs can source/sink 40 ma at most. To drive more than 40mA: Use amplification (transistors, opamps, etc). Check datasheets. Use multiple pins (limited to 400mA if USB power). 21

22 Drive a DC Motor in a Single Direction When the motor does not need to reverse direction, a simple PWM drive is as follows: 22

23 Drive a DC motor in both directions To drive a DC motor in both directions we need what is typically called a H- Bridge. Solutions: make a H- bridge with discrete components. Buy an IC with H- bridges. Buy a motor shield for arduino. 23

24 Drive a DC motor in both directions Example with the L239 H- Bridge. const int enpin = 5; // H- Bridge enable pin const int in1pin = 7; // H- Bridge input pins const int in2pin = 4; void setup() Serial.begin(9600); pinmode(in1pin, OUTPUT); pinmode(in2pin, OUTPUT); Serial.println("Speed (0-9) or + - to set direction"); void loop() if ( Serial.available()) char ch = Serial.read(); if(isdigit(ch)) // is ch a number? int speed = map(ch, '0', '9', 0, 255); analogwrite(enpin, speed); else if (ch == '+') //Rotate CW digitalwrite(in1pin,low); digitalwrite(in2pin,high); else if (ch == '- ') //Rotate CCW digitalwrite(in1pin,high); digitalwrite(in2pin,low); else Serial.print("Unexpectedcharacter "); Serial.println(ch); 24

25 Hobbyist Servo Motors HobbyistServo Motors use a potentiometer attached to a DC motor shaft to perform position control. The position reference is commanded bypulse Position Modulation PPM and is not the same as the analogwrite() PWM signal. Onecan use the Servo library to implement the PPM signals. 25

26 Drive a Hobby Servo Externalpower may be required. Do not forget to connect the Grounds. The Servo library uses Timer 1, thus disables PWM on pins 9 and 10. #include <Servo.h> Servo myservo; // create servo object to control a servo int angle = 0; // variable to store the servo position void setup() myservo.attach(9,1000,2000); //Servo on pin 9. //Minimal position corresponds to 1000microsec. //Maximal position corresponds to 2000microsec. //These values may need to be adjusted, // depending on the servo model. void loop() for(angle = 0; angle < 180; angle += 1) myservo.write(angle); delay(20); for(angle = 180; angle >= 1; angle - = 1) myservo.write(angle); delay(20); 26

27 Devices with Different Voltage Levels Do not connect the ARDUINO to devices with other voltage levels. This may damage the I/O ports. One way to prevent damage is to use opto- couplers. Example: control a TRS camera shutter. //TAKE 20 PICTURES AND EXIT int focus = 4; //optocoupler attached to focus int shutter = 3; //optocoupler attached to shutter long exposure = 250; //exposure time in milliseconds long interval = 10000; //time between shots, in milliseconds void setup() pinmode(focus, OUTPUT); pinmode(shutter, OUTPUT); for (int i=0; i<20; i++) //camera will take 20 pictures takepicture(exposure); //takes picture delay(interval); //wait to take the next picture void loop() //NO LOOP void takepicture(long exposuretime) int wakeup = 10; //camera take time to wake up and focus //adjust this to suit your camera digitalwrite(focus, HIGH); //wake the camera and focus delay(wakeup); //wait for it to wake up and focus digitalwrite(shutter, HIGH); //open the shutter delay(exposuretime); //wait for the exposure time digitalwrite(shutter, LOW); //release shutter digitalwrite(focus, LOW); //release the focus 27

28 Final Note Always read the documentation (datasheets) of the devices to interface! 28

Arduino Prof. Dr. Magdy M. Abdelhameed

Arduino Prof. Dr. Magdy M. Abdelhameed Course Code: MDP 454, Course Name:, Second Semester 2014 Arduino What is Arduino? Microcontroller Platform Okay but what s a Microcontroller? Tiny, self-contained computers in an IC Often contain peripherals

More information

More Arduino Programming

More Arduino Programming Introductory Medical Device Prototyping Arduino Part 2, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Programming Digital I/O (Read/Write) Analog

More information

Arduino Part 2. Introductory Medical Device Prototyping

Arduino Part 2. Introductory Medical Device Prototyping Introductory Medical Device Prototyping Arduino Part 2, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Programming Digital I/O (Read/Write) Analog

More information

PROGRAMMING WITH ARDUINO

PROGRAMMING WITH ARDUINO PROGRAMMING WITH ARDUINO Arduino An open-source hardware platform based on an Atmel AVR 8-bit microcontroller and a C++ based IDE Over 300000 boards have been manufactured Arduino Due is based on a 32-bit

More information

ARDUINO. By Kiran Tiwari BCT 2072 CoTS.

ARDUINO. By Kiran Tiwari BCT 2072 CoTS. ARDUINO By Kiran Tiwari BCT 2072 CoTS www.kirantiwari.com.np SO What is an Arduino? WELL!! Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Why Arduino? Simplifies

More information

FUNCTIONS For controlling the Arduino board and performing computations.

FUNCTIONS For controlling the Arduino board and performing computations. d i g i t a l R e a d ( ) [Digital I/O] Reads the value from a specified digital pin, either HIGH or LOW. digitalread(pin) pin: the number of the digital pin you want to read HIGH or LOW Sets pin 13 to

More information

MEDIS Module 2. Microcontroller based systems for controlling industrial processes. Chapter 4: Timer and interrupts. M. Seyfarth, Version 0.

MEDIS Module 2. Microcontroller based systems for controlling industrial processes. Chapter 4: Timer and interrupts. M. Seyfarth, Version 0. MEDIS Module 2 Microcontroller based systems for controlling industrial processes Chapter 4: Timer and interrupts M. Seyfarth, Version 0.1 Steuerungstechnik 1: Speicherprogrammierbare Steuerungstechnik

More information

Chapter 2 The Basic Functions

Chapter 2 The Basic Functions Chapter 2 The Basic Functions 2.1 Overview The code you learn to write for your Arduino is very similar to the code you write in any other computer language. This implies that all the basic concepts remain

More information

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

Arduino Course. Technology Will Save Us - Tim Brooke 10th August Friday, 9 August 13 Arduino Course Technology Will Save Us - Tim Brooke 10th August 2013 Arduino Projects http://www.instructables.com/id/20-unbelievable-arduino-projects/ Blink /* Blink Turns on an LED on for one second,

More information

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

Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas Physics 364 Arduino Lab 1 Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas Vithayathil/Kroll Introduction Last revised: 2014-11-12 This lab introduces you to an electronic development

More information

SECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing

SECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing SECOND EDITION Arduino Cookbook Michael Margolis Beijing Cambridge Farnham Koln Sebastopol O'REILLY- Tokyo Table of Contents Preface xi 1. Getting Started 1 1.1 Installing the Integrated Development Environment

More information

Steering Engine Sample Sketch

Steering Engine Sample Sketch Steering Engine Sample Sketch #include #include #define LEFT_CENTER 93 #define RIGHT_CENTER 95 #define SPEED 5 Servo servo_left; Servo servo_right; SoftwareServo servo_scanner;

More information

Introduction to Arduino. Wilson Wingston Sharon

Introduction to Arduino. Wilson Wingston Sharon Introduction to Arduino Wilson Wingston Sharon cto@workshopindia.com Physical computing Developing solutions that implement a software to interact with elements in the physical universe. 1. Sensors convert

More information

Introduction to Microcontrollers Using Arduino. PhilRobotics

Introduction to Microcontrollers Using Arduino. PhilRobotics Introduction to Microcontrollers Using Arduino PhilRobotics Objectives Know what is a microcontroller Learn the capabilities of a microcontroller Understand how microcontroller execute instructions Objectives

More information

Introduction to Arduino Programming. Sistemi Real-Time Prof. Davide Brugali Università degli Studi di Bergamo

Introduction to Arduino Programming. Sistemi Real-Time Prof. Davide Brugali Università degli Studi di Bergamo Introduction to Arduino Programming Sistemi Real-Time Prof. Davide Brugali Università degli Studi di Bergamo What is a Microcontroller www.mikroe.com/chapters/view/1 A small computer on a single chip containing

More information

ROS Interface with Low Level Control - Arduino

ROS Interface with Low Level Control - Arduino ROS Interface with Low Level Control - Arduino Welcome Dr. Ahmad Kamal Nasir 12.02.2015 Dr. Ahmad Kamal Nasir 1 Today s Objectives Introduction to Arduino Writing simple Arduino sketches Serial Communication

More information

The Arduino Briefing. The Arduino Briefing

The Arduino Briefing. The Arduino Briefing Mr. Yee Choon Seng Email : csyee@simtech.a-star.edu.sg Design Project resources http://guppy.mpe.nus.edu.sg/me3design.html One-Stop robotics shop A-Main Objectives Pte Ltd, Block 1 Rochor Road, #02-608,

More information

Arduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol

Arduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol Arduino Cookbook Michael Margolis O'REILLY* Beijing Cambridge Farnham Koln Sebastopol Tokyo Table of Contents Preface xiii 1. Getting Started 1 1.1 Installing the Integrated Development Environment (IDE)

More information

EXPERIMENT 7 Please visit https://www.arduino.cc/en/reference/homepage to learn all features of arduino before you start the experiments

EXPERIMENT 7 Please visit https://www.arduino.cc/en/reference/homepage to learn all features of arduino before you start the experiments EXPERIMENT 7 Please visit https://www.arduino.cc/en/reference/homepage to learn all features of arduino before you start the experiments TEMPERATURE MEASUREMENT AND CONTROL USING LM35 Purpose: To measure

More information

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

IME-100 ECE. Lab 4. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE, IME-100 ECE Lab 4 Electrical and Computer Engineering Department Kettering University 4-1 1. Laboratory Computers Getting Started i. Log-in with User Name: Kettering Student (no password required) ii.

More information

Arduino Uno Microcontroller Overview

Arduino Uno Microcontroller Overview Innovation Fellows Program Arduino Uno Microcontroller Overview, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Microcontroller Nawin Somyat Department of Electrical and Computer Engineering Thammasat University Outline Course Contents 1 Introduction 2 Simple Computer 3 Microprocessor

More information

/* to use: enter key aray and make sure that the userentered has the same number of zeros

/* to use: enter key aray and make sure that the userentered has the same number of zeros to use: enter key aray and make sure that the userentered has the same number of zeros ex: int Keyarray[] = {1,2,3,4; int userentered[] = {0,0,0,0; ex2: int Keyarray[] = {1,2,3,4,1,2,3; int userentered[]

More information

FUNCTIONS USED IN CODING pinmode()

FUNCTIONS USED IN CODING pinmode() FUNCTIONS USED IN CODING pinmode() Configures the specified pin to behave either as an input or an output. See the description of digital pins for details on the functionality of the pins. As of Arduino

More information

Copyright 2011 Michael Margolis and Nicholas Weldin. All rights reserved. Printed in the United States of America.

Copyright 2011 Michael Margolis and Nicholas Weldin. All rights reserved. Printed in the United States of America. Arduino Cookbook by Michael Margolis Copyright 2011 Michael Margolis and Nicholas Weldin. All rights reserved. Printed in the United States of America. Published by O Reilly Media, Inc., 1005 Gravenstein

More information

PROGRAMMING ARDUINO COURSE ON ADVANCED INTERACTION TECHNIQUES. Luís Carriço FCUL 2012/13

PROGRAMMING ARDUINO COURSE ON ADVANCED INTERACTION TECHNIQUES. Luís Carriço FCUL 2012/13 Sources: Arduino Hands-on Workshop, SITI, Universidad Lusófona Arduino Spooky projects Basic electronics, University Pennsylvania Beginning Arduino Programming Getting Started With Arduino COURSE ON ADVANCED

More information

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 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 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S Overview Motivation Circuit Design and Arduino Architecture Projects Blink the LED Switch Night Lamp

More information

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

University of Portland EE 271 Electrical Circuits Laboratory. Experiment: Arduino University of Portland EE 271 Electrical Circuits Laboratory Experiment: Arduino I. Objective The objective of this experiment is to learn how to use the Arduino microcontroller to monitor switches and

More information

Introduction To Arduino

Introduction To Arduino Introduction To Arduino What is Arduino? Hardware Boards / microcontrollers Shields Software Arduino IDE Simplified C Community Tutorials Forums Sample projects Arduino Uno Power: 5v (7-12v input) Digital

More information

Lab 3 XBees and LCDs and Accelerometers, Oh My! Part 1: Wireless Communication Using XBee Modules and the Arduino

Lab 3 XBees and LCDs and Accelerometers, Oh My! Part 1: Wireless Communication Using XBee Modules and the Arduino University of Pennsylvania Department of Electrical and Systems Engineering ESE 205 Electrical Circuits and Systems Laboratory I Lab 3 XBees and LCDs and Accelerometers, Oh My! Introduction: In the first

More information

TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO

TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO AGENDA RECAP ALGORITHMIC APPROACHES TIMERS RECAP: LAST WEEK WE DID: ARDUINO IDE INTRO MAKE SURE BOARD AND USB PORT SELECTED UPLOAD PROCESS COVERED DATATYPES

More information

Introduction to Arduino Diagrams & Code Brown County Library

Introduction to Arduino Diagrams & Code Brown County Library Introduction to Arduino Diagrams & Code Project 01: Blinking LED Components needed: Arduino Uno board LED Put long lead into pin 13 // Project 01: Blinking LED int LED = 13; // LED connected to digital

More information

Introduction to Arduino Diagrams & Code Brown County Library

Introduction to Arduino Diagrams & Code Brown County Library Introduction to Arduino Diagrams & Code Project 01: Blinking LED Components needed: Arduino Uno board LED Put long lead into pin 13 // Project 01: Blinking LED int LED = 13; // LED connected to digital

More information

Arduino and Matlab for prototyping and manufacturing

Arduino and Matlab for prototyping and manufacturing Arduino and Matlab for prototyping and manufacturing Enrique Chacón Tanarro 11th - 15th December 2017 UBORA First Design School - Nairobi Enrique Chacón Tanarro e.chacon@upm.es Index 1. Arduino 2. Arduino

More information

Introduction to Arduino

Introduction to Arduino Introduction to Arduino Paco Abad May 20 th, 2011 WGM #21 Outline What is Arduino? Where to start Types Shields Alternatives Know your board Installing and using the IDE Digital output Serial communication

More information

keyestudio Keyestudio MEGA 2560 R3 Board

keyestudio Keyestudio MEGA 2560 R3 Board Keyestudio MEGA 2560 R3 Board Introduction: Keyestudio Mega 2560 R3 is a microcontroller board based on the ATMEGA2560-16AU, fully compatible with ARDUINO MEGA 2560 REV3. It has 54 digital input/output

More information

TABLE OF CONTENTS INTRODUCTION LESSONS PROJECTS

TABLE OF CONTENTS INTRODUCTION LESSONS PROJECTS TABLE OF CONTENTS INTRODUCTION Introduction to Components - Maker UNO 5 - Maker UNO Board 6 - Setting Up - Download Arduino IDE 7 - Install Maker UNO Drivers - Install Maker UNO Board Package 3 LESSONS.

More information

Arduino Programming and Interfacing

Arduino Programming and Interfacing Arduino Programming and Interfacing Stensat Group LLC, Copyright 2017 1 Robotic Arm Experimenters Kit 2 Legal Stuff Stensat Group LLC assumes no responsibility and/or liability for the use of the kit and

More information

CprE 288 Introduction to Embedded Systems (Timers/Input Capture) Instructors: Dr. Phillip Jones

CprE 288 Introduction to Embedded Systems (Timers/Input Capture) Instructors: Dr. Phillip Jones CprE 288 Introduction to Embedded Systems (Timers/Input Capture) Instructors: Dr. Phillip Jones 1 Announcements HW 4, Due Wed 6/13 Quiz 5 (15 min): Wed 6/13, Textbook reading: Section 9.1, 9.2 (your one-side

More information

STEPD StepDuino Quickstart Guide

STEPD StepDuino Quickstart Guide STEPD StepDuino Quickstart Guide The Freetronics StepDuino is Arduino Uno compatible, uses the ATmega328P Microcontroller and works with most Arduino software. The StepDuino can be powered automatically

More information

Make your own secret locking mechanism to keep unwanted guests out of your space!

Make your own secret locking mechanism to keep unwanted guests out of your space! KNOCK LOCK Make your own secret locking mechanism to keep unwanted guests out of your space! Discover : input with a piezo, writing your own functions Time : 1 hour Level : Builds on projects : 1,,3,4,5

More information

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

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface. Introductory Medical Device Prototyping Arduino Part 1, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB Interface

More information

Eng.mohammed Albhaisi. Lab#3 : arduino to proteus simulation. for simulate Arduino program that you wrote you have to have these programs :

Eng.mohammed Albhaisi. Lab#3 : arduino to proteus simulation. for simulate Arduino program that you wrote you have to have these programs : Lab#3 : arduino to proteus simulation for simulate Arduino program that you wrote you have to have these programs : 1-Arduino C 2-proteus 3- Virtual Serial Port Driver 4-Arduino library to proteus You

More information

How to Use an Arduino

How to Use an Arduino How to Use an Arduino By Vivian Law Introduction The first microcontroller, TMS-1802-NC, was built in 1971 by Texas Instruments. It owed its existence to the innovation and versatility of silicon and the

More information

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD MODULE-1 C Programming Language Introduction to C Objectives of C Applications of C Relational and logical operators Bit wise operators The assignment statement Intermixing of data types type conversion

More information

Introduction to Arduino

Introduction to Arduino Introduction to Arduino Mobile Computing, aa. 2016/2017 May 12, 2017 Daniele Ronzani - Ph.D student in Computer Science dronzani@math.unipd.it What are Microcontrollers Very small and simple computers

More information

Sensors and Motor Control Lab

Sensors and Motor Control Lab Sensors and Motor Control Lab Individual lab report #1 October 16, 2015 Menghan Zhang TeamA Amit Agarwal Harry Golash Yihao Qian Zihao Zhang Individual progress Challenges Teamwork a) Used potentiometer

More information

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform. Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform www.sierraradio.net www.hamstack.com Topics Introduction Hardware options Software development HamStack project

More information

Interrupts Arduino, AVR, and deep dark programming secrets. What is an Interrupt?

Interrupts Arduino, AVR, and deep dark programming secrets. What is an Interrupt? Interrupts Arduino, AVR, and deep dark programming secrets What is an Interrupt? A transfer of program control that is not directed by the programmer Like a phone call in the middle of a conversation Stop

More information

TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO

TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO AGENDA ARDUINO HARDWARE THE IDE & SETUP BASIC PROGRAMMING CONCEPTS DEBUGGING & HELLO WORLD INPUTS AND OUTPUTS DEMOS ARDUINO HISTORY IN 2003 HERNANDO

More information

SPDM Level 2 Smart Electronics Unit, Level 2

SPDM Level 2 Smart Electronics Unit, Level 2 SPDM Level 2 Smart Electronics Unit, Level 2 Evidence Folder John Johns Form 3b RSA Tipton 1.1 describe the purpose of circuit components and symbols. The candidate can describe the purpose of a range

More information

EEL 5666C - Intelligent Machine Design Lab Final report

EEL 5666C - Intelligent Machine Design Lab Final report EEL 5666C - Intelligent Machine Design Lab Final report Date: 04/21/14 Student Name: Shaoyi SHI Robot Name: Alin E-mail: ssytom@hotmail.com TA: Instructors: Josh Weaver A. Antonio Arroyo Eric M. Schwartz

More information

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software! Summer Training 2016 Advance Embedded Systems Fast track of AVR and detailed working on STM32 ARM Processor with RTOS- Real Time Operating Systems Covering 1. Hands on Topics and Sessions Covered in Summer

More information

Physics 120B: Lecture 11. Timers and Scheduled Interrupts

Physics 120B: Lecture 11. Timers and Scheduled Interrupts Physics 120B: Lecture 11 Timers and Scheduled Interrupts Timer Basics The ATMega 328 has three @mers available to it (Arduino Mega has 6) max frequency of each is 16 MHz, on Arduino TIMER0 is an 8- bit

More information

SquareWear Programming Reference 1.0 Oct 10, 2012

SquareWear Programming Reference 1.0 Oct 10, 2012 Content: 1. Overview 2. Basic Data Types 3. Pin Functions 4. main() and initsquarewear() 5. Digital Input/Output 6. Analog Input/PWM Output 7. Timing, Delay, Reset, and Sleep 8. USB Serial Functions 9.

More information

Programmable Device Interface PDI-1 A Versatile Hardware Controller with USB interface

Programmable Device Interface PDI-1 A Versatile Hardware Controller with USB interface Programmable Device Interface PDI-1 A Versatile Hardware Controller with USB interface Features and Specifications Arduino compatible for simple USB Programming 126 x 64 Graphic LCD 12x Digital IO ports*

More information

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

Lab 02 Arduino 數位感測訊號處理, SPI I2C 介面實驗. More Arduino Digital Signal Process Lab 02 Arduino 數位感測訊號處理, SPI I2C 介面實驗 More Arduino Digital Signal Process Blink Without Delay Sometimes you need to do two things at once. For example you might want to blink an LED (or some other timesensitive

More information

Laboratory 4 Usage of timers

Laboratory 4 Usage of timers Laboratory 4 Usage of timers 1. Timer based interrupts Beside external interrupt, the MCU responds to internal ones which are triggered by external events (on the external pins). The source of the internal

More information

Quantum Phase Isochromatic Pluckeasy

Quantum Phase Isochromatic Pluckeasy Quantum Phase Isochromatic Pluckeasy Laser Harp for short Paul Holcomb Timothy Tribby Hardware Overview IR Sensors Arduino With ATmega 1280 Motor With Rotating Mirror Laser Module Laser Harp Goals Display

More information

Robotic Systems ECE 401RB Fall 2006

Robotic Systems ECE 401RB Fall 2006 The following notes are from: Robotic Systems ECE 401RB Fall 2006 Lecture 15: Processors Part 3 Chapter 14, G. McComb, and M. Predko, Robot Builder's Bonanza, Third Edition, Mc- Graw Hill, 2006. I. Peripherals

More information

Robotics/Electronics Review for the Final Exam

Robotics/Electronics Review for the Final Exam Robotics/Electronics Review for the Final Exam Unit 1 Review. 1. The battery is 12V, R1 is 400 ohms, and the current through R1 is 20 ma. How many ohms is R2? ohms What is the voltage drop across R1? V

More information

UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY

UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY USER GUIDE UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY Contents This user guide describes how to use the UMI-77, UMI-A, UMI-Flex, and UMI-Flex accessories. Introduction... What You Need to Get Started...

More information

arduino programming notebook brian w. evans revised by Paul Badger

arduino programming notebook brian w. evans revised by Paul Badger arduino programming notebook brian w. evans revised by Paul Badger Arduino Programming Notebook Written and compiled by Brian W. Evans With information or inspiration taken from: http://www.arduino.cc

More information

Experiment 3: Sonar Navigation, CAD and 3D Printing

Experiment 3: Sonar Navigation, CAD and 3D Printing Experiment 3: Sonar Navigation, CAD and 3D Printing V3 Robot scans area for obstacles to avoid hitting them and navigates using sonar sensor mounted on a 3D printed sensor bracket that goes on a micro

More information

Arduino: Serial Monitor Diagrams & Code Brown County Library

Arduino: Serial Monitor Diagrams & Code Brown County Library Arduino: Serial Monitor Diagrams & Code All projects require the use of the serial monitor in your Arduino IDE program (or whatever you are using to transfer code to the Arduino). Project 01: Monitor how

More information

EP486 Microcontroller Applications

EP486 Microcontroller Applications EP486 Microcontroller Applications Topic 6 Step & Servo Motors Joystick & Water Sensors Department of Engineering Physics University of Gaziantep Nov 2013 Sayfa 1 Step Motor http://en.wikipedia.org/wiki/stepper_motor

More information

Arduino Uno R3 INTRODUCTION

Arduino Uno R3 INTRODUCTION Arduino Uno R3 INTRODUCTION Arduino is used for building different types of electronic circuits easily using of both a physical programmable circuit board usually microcontroller and piece of code running

More information

Arduino: Piezo Diagrams & Code Brown County Library. Projects 01 & 02: Scale and Playing a Tune Components needed: Arduino Uno board piezo

Arduino: Piezo Diagrams & Code Brown County Library. Projects 01 & 02: Scale and Playing a Tune Components needed: Arduino Uno board piezo Arduino: Piezo Diagrams & Code Projects 01 & 02: Scale and Playing a Tune Components needed: Arduino Uno board piezo /* Piezo 01 : Play a scale Code adapted from Adafruit Arduino Lesson 10 (learn.adafruit.com/adafruit-arduino-lesson-

More information

Arduino. (Digital-to-Analog Converter D/A D2A) (Digital to Analog Conversion) 3. (Analog to Digital conversion)

Arduino. (Digital-to-Analog Converter D/A D2A) (Digital to Analog Conversion) 3. (Analog to Digital conversion) Arduino 1. 2. (Digital to Analog Conversion) 3. (Analog to Digital conversion) 1 2 Analog to Digital Converter (ADC) (Digital-to-Analog Converter D/A D2A) Digital to Analog Converter (DAC) 3 4 DAC Binary

More information

Arduino Programming. Arduino UNO & Innoesys Educational Shield

Arduino Programming. Arduino UNO & Innoesys Educational Shield Arduino Programming Arduino UNO & Innoesys Educational Shield www.devobox.com Electronic Components & Prototyping Tools 79 Leandrou, 10443, Athens +30 210 51 55 513, info@devobox.com ARDUINO UNO... 3 INNOESYS

More information

GUIDE TO SP STARTER SHIELD (V3.0)

GUIDE TO SP STARTER SHIELD (V3.0) OVERVIEW: The SP Starter shield provides a complete learning platform for beginners and newbies. The board is equipped with loads of sensors and components like relays, user button, LED, IR Remote and

More information

Arduino: What is it? What can it do?

Arduino: What is it? What can it do? Arduino: What can it do? tswsl1989@sucs.org May 20, 2013 What is an Arduino? According to Arduino: Arduino is a tool for making computers that can sense and control more of the physical world than your

More information

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi 1 P a g e ATmega Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming in Assembly

More information

Introduction to Microprocessors: Arduino

Introduction to Microprocessors: Arduino Introduction to Microprocessors: Arduino tswsl1989@sucs.org October 7, 2013 What is an Arduino? Open Source Reference designs for hardware Firmware tools + GUI Mostly based around 8-bit Atmel AVR chips

More information

Explorer V1.20. Features

Explorer V1.20. Features V1.20 Multi-function USB I/O Expander and Controller Features Dual h-bridge 1.3A motor drive with PWM speed control 4.6V to 10.8V input range USB communication 4x digital inputs 2x analogue inputs 7x 100mA

More information

Energia MSP-430!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1

Energia MSP-430!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1 Energia MSP-430 1 3 Energia 4 4 4 6 8 9 Energia 11 18 2 IIB Energia MSP-430 IIB C C++ 3 Energia Energia MSP-430 Windows Mac OS Linux MSP-430, http://www.energia.nu, Max OS X, windows Linux Mac OS X, energia-

More information

Microcontrollers and Interfacing week 8 exercises

Microcontrollers and Interfacing week 8 exercises 2 HARDWARE DEBOUNCING Microcontrollers and Interfacing week 8 exercises 1 More digital input When using a switch for digital input we always need a pull-up resistor. For convenience, the microcontroller

More information

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

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process Lab 01 Arduino 程式設計實驗 Essential Arduino Programming and Digital Signal Process Arduino Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's

More information

KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions

KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions 125 KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions Time: 1 HOUR Level: Builds on projects: 1, 2, 3,

More information

More Fun with Timer Interrupts

More Fun with Timer Interrupts More Fun with Timer Interrupts Chords Objective: Play a musical chord each time you press a button: Button RC0 RC1 RC2 Timer Timer0 Timer1 Timer3 RB0 A3 C4 E4 RB1 B3 D4 F4 RB2 C4 E4 G4 Calculations: Assume

More information

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

Arduino Workshop. Overview. What is an Arduino? Why Arduino? Setting up your Arduino Environment. Get an Arduino based board and usb cable Arduino Workshop Overview Arduino, The open source Microcontroller for easy prototyping and development What is an Arduino? Arduino is a tool for making computers that can sense and control more of the

More information

USER MANUAL ARDUINO I/O EXPANSION SHIELD

USER MANUAL ARDUINO I/O EXPANSION SHIELD USER MANUAL ARDUINO I/O EXPANSION SHIELD Description: Sometimes Arduino Uno users run short of pins because there s a lot of projects that requires more than 20 signal pins. The only option they are left

More information

Physics 124: Lecture 12. Timer Basics. Timers and Scheduled Interrupts

Physics 124: Lecture 12. Timer Basics. Timers and Scheduled Interrupts Physics 124: Lecture 12 Timers and Scheduled Interrupts Timer Basics The Arduino Uno/Nano (ATMega 328) has three Hmers available to it (Arduino Mega has 6) max frequency of each is 16 MHz, (as assembled)

More information

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

WEEK PRactice. Turning on LED with a Switch. Learning Objective. Materials to Prepare. Summary of Class. Project Goal. Hardware Expression WEEK 04 Have LED My Way PRactice Turning on LED with a Switch Do you remember the project we worked on in week 3? It was a program that had making board s LED blink every second through a simple program.

More information

EECS 373 Midterm 2 Fall 2018

EECS 373 Midterm 2 Fall 2018 EECS 373 Midterm 2 Fall 2018 Name: unique name: Sign the honor code: I have neither given nor received aid on this exam nor observed anyone else doing so. Nor did I discuss this exam with anyone after

More information

LAMPIRAN I (LISTING PROGRAM)

LAMPIRAN I (LISTING PROGRAM) LAMPIRAN I (LISTING PROGRAM) #include LiquidCrystal lcd(8, 9, 4, 5, 6, 7); const int numreadings = 10; int readings[numreadings]; // the readings from the analog input int readindex =

More information

Rotary Encoder Basics

Rotary Encoder Basics Rotary Encoder Basics A rotary encoder has a fixed number of positions per revolution. These positions are easily felt as small clicks you turn the encoder. The Keyes module that I have has thirty of these

More information

ArdOS The Arduino Operating System Quick Start Guide and Examples

ArdOS The Arduino Operating System Quick Start Guide and Examples ArdOS The Arduino Operating System Quick Start Guide and Examples Contents 1. Introduction... 1 2. Obtaining ArdOS... 2 3. Installing ArdOS... 2 a. Arduino IDE Versions 1.0.4 and Prior... 2 b. Arduino

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Stefan Kowalewski, 4. November 25 Introduction to Embedded Systems Part 2: Microcontrollers. Basics 2. Structure/elements 3. Digital I/O 4. Interrupts 5. Timers/Counters Introduction to Embedded Systems

More information

UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY

UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY USER GUIDE UNIVERSAL MOTION INTERFACE (UMI) ACCESSORY Introduction This user guide describes how to use the UMI-A, UMI-Flex, and UMI-Flex accessories. The UMI products are connectivity accessories you

More information

#define CE_PIN 12 //wireless module CE pin #define CSN_PIN 13 //wireless module CSN pin. #define angleaveragenum 1

#define CE_PIN 12 //wireless module CE pin #define CSN_PIN 13 //wireless module CSN pin. #define angleaveragenum 1 /***************************************************************************************************** define statements *****************************************************************************************************/

More information

Laboratory 3 Working with the LCD shield and the interrupt system

Laboratory 3 Working with the LCD shield and the interrupt system Laboratory 3 Working with the LCD shield and the interrupt system 1. Working with the LCD shield The shields are PCBs (Printed Circuit Boards) that can be placed over the Arduino boards, extending their

More information

USB-4303 Specifications

USB-4303 Specifications Specifications Document Revision 1.0, February, 2010 Copyright 2010, Measurement Computing Corporation Typical for 25 C unless otherwise specified. Specifications in italic text are guaranteed by design.

More information

NXShield Interface Specifications

NXShield Interface Specifications NXShield Advanced Development Guide v1.0 NXShield Interface Specifications Power Specs: NXShield can be powered from external power supply. Max Power Rating: 10.5 Volts DC Minimum 6.6 Volts DC needed to

More information

New APIs and Hacks. Servo API. Chapter 4. The Theory versus Practice

New APIs and Hacks. Servo API. Chapter 4. The Theory versus Practice Chapter 4 New APIs and Hacks The challenge when Intel Galileo was designed was to create a board that would be compatible with Arduino headers and reference language using only the Quark microprocessor,

More information

LGR-5327 Specifications

LGR-5327 Specifications s Revision 1.0, April, 2010 Copyright 2010, Measurement Computing Corporation All specifications are subject to change without notice. Typical for 25 C unless otherwise specified. s in italic text are

More information

PIC Microcontroller Introduction

PIC Microcontroller Introduction PIC Microcontroller Introduction The real name of this microcontroller is PICmicro (Peripheral Interface Controller), but it is better known as PIC. Its first ancestor was designed in 1975 by General Instruments.

More information

FEATURES DESCRIPTION FEATURES

FEATURES DESCRIPTION FEATURES FEATURES Two High Speed Counters Two Pulse Train Outputs Two Pulse Width Modulation Outputs 24 Sinking or Sourcing Inputs 16 Outputs 1 RS232 Port 2 RS485 Ports Supports Modbus RTU Protocol Communicate

More information

Connecting Arduino to Processing

Connecting Arduino to Processing Connecting Arduino to Processing Introduction to Processing So, you ve blinked some LEDs with Arduino, and maybe you ve even drawn some pretty pictures with Processing - what s next? At this point you

More information