Microcontrollers and Interfacing week 8 exercises

Size: px
Start display at page:

Download "Microcontrollers and Interfacing week 8 exercises"

Transcription

1 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 can provide the pull-up resistance for us internally. For any digital pin configured as INPUT we can use digitalwrite(pin, HIGH) to enable the internal pull-up resistor, and digitalwrite(pin, LOW) to disable the internal pull-up resistor. Alternatively, the pin s mode can be set to INPUT PULLUP to configure it for input and turn on the pull-up resistor at the same time. For example, pinmode (11, INPUT_PULLUP ); and pinmode (11, INPUT ); digitalwrite (11, HIGH ); are equivalent. Modify your circuit to work with internal pull-up resistors. (We will be using pins 4 through 10 for the seven LED segments, and using pins 2 and 3 for the switch inputs so that the circuit is suitable for the interrupt experiment at the end of today s class.) An example of a suitable circuit is shown on the right. Modify your sketch to use internal pull-up resistors on pins 2 and 3 for switch inputs, and pins 4 through 10 as outputs driving the seven-segment LED display. (An example of a suitable sketch for this experiment is given on page 4. Please feel free to copy it to save time.) Operate the circuit for a while. If you cannot observe bouncing behaviour on the buttons, try using different switches (ask the instructor for some). Hardware debouncing Arduino Try to cure the switch bounce by attaching a small capacitor across the internal pull-ups D12 debouncing capacitor Make a note of the smallest value that actually cures the bounce. Smallest capacitor value that cures switch bounce: 1 of 8 INPUT_PULLUP F. The value of the internal pull-up resistor is approximately 20k Ω. Calculate the 50% time constant of the RC circuit formed by the internal pull-up resistor and the capacitor. RC circuit 50% time constant: τ50 = R C 0.7 = D11 s. external switches GND 20k 5V switch contacts. Begin with the largest value you have. Then try successively smaller values until the switch starts to bounce again. 20k 2

2 3 SOFTWARE DEBOUNCING 3 Software debouncing One reason microcontrollers are useful is that they let us move hardware into software. Let s try to debounce the switch in software instead of in hardware. 3.1 Debouncing with a fixed delay A simple approach to debouncing is to introduce a short delay, to allow the switch to finish bouncing, before letting the sketch proceed. Remove the debouncing capacitor(s) from your circuit. Modify your sketch to implement the following debouncing strategy: if the input pin is LOW then do nothing (the switch is not pressed); otherwise perform the associated action (increment or decrement the counter) wait for a short time (using the delay() function) to let the switch settle use a while loop to wait for the input pin to return to HIGH (If you cannot easily write this yourself, an example sketch can be found on page 5.) Observe the behaviour of the sketch. Is the debouncing reliable? Can you press the switch rapidly, and have the counter accurately record each press? Can you press both switches at the same time, and obtain the expected result? 3.2 Debouncing with a timer: simulating the hardware debounce in software A slightly better solution is to simulate the capacitor circuit in software, using a timer. To implement a timer we can use the millis() function that returns the number of milliseconds for which the sketch has been running. By remembering the millisecond time at which the timer is started, and then comparing the current value of millis() with the starting value, we can use a simple loop to wait until the the timer expires (when the difference between the current millis() and the start time exceeds the number of milliseconds we are trying to time). event capacitor circuit timer simulation switch pressed capacitor discharges instantly timer is reset to 0 perform action (modify counter) perform action (modify counter) switch bounces open: capacitor begins to charge open: timer runs closed: capacitor discharged closed: timer is reset switch closed capacitor remains discharged timer repeatedly reset to zero switch opened capacitor begins to charge timer begins to run after τ, input goes HIGH when timer completes, sketch proceeds Modify your sketch to debounce using a timer. An outline of a possible implementation of this strategy might be as follows: if (switch is closed, i.e., button is pressed ) perform button pressed action unsigned long start= millis(); // initialise timer while ( millis() - start < timer duration) // timer has not expired if (button is pressed ) // bouncing, or settled in closed state start= millis(); // reset timer to zero // we now know input has remained HIGH ( switch open) for the timer duration: // switch cycle is complete, so continue with rest of sketch... You can experiment with different timer values. A good value to start with would be the 50% time constant that you calculated in section 2. (If you cannot complete the sketch by yourself, an example solution is shown on page 6.) 2 of 8

3 4 INTERRUPTS 4 Interrupts If our loop() has a repetitive task to perform then trying to handle switches and other asynchronous input within loop() can be inconvenient. Just like all CPUs, the microcontroller provides interrupts for handling asynchronous events (such as an input pin changing state) outside the normal cycle of repetitive tasks. We will use interupt 0 (associated with input pin 2) and interupt 1 (associated with input pin 3) to process our switch inputs asynchronously. Make your counter variable global. Declare it to be volatile. Write an interrupt service routine (handler) called buttondownisr() that decrements the counter and calls display() to display the new value. Then modify your setup() function so that it uses attachinterrupt(0, buttondownisr, FALLING) to associate your handler with interrupt 0 (pin 2), triggering the handler whenever the input changes from HIGH to LOW. Write a similar handler called buttonupisr() that increments the counter, and then in setup() use attachinterrupt() to associate it with interrupt 1 (pin 3). Test your sketch with an empty loop() function; the buttons should modify the counter as expected when whe loop() is empty. Add a repetitive task to loop(), such as blinking the LED attached to pin 13, to demonstrate that the button handling does not interfere with synchronous tasks. (If you have trouble completing this part on your own, you can find an example solution on page 7.) 4.1 Challenge (easy) If you have time left over, try to implement the repetitive task (blinking the pin 13 LED) in the earlier sketch that used delay() or a timer to debounce the buttons. Which sketch is conceptually simpler and easier to understand? 4.2 Challenge (difficult!) Debounce the switches in the interrupt-based sketch. 3 of 8

4 5 SKETCHES 5 Sketches 5.1 Seven-segment up/down counter const int BUTTONDOWN = 2; const int BUTTONUP = 3; const int SEGMENTS = 4; void display( int digit) static unsigned char digits []= 0b , // 0 0b , // 1 0b , // 2 0b , // 3 0b , // 4 0b , // 5 0b , // 6 0b , // 7 0b , // 8 0b , // 9 ; int bits= ( digit < 0)? 0 : digits[ digit % 10]; for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i, bits >>= 1) digitalwrite(i, ( bits & 1)? HIGH : LOW); void setup() for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i) pinmode(i, OUTPUT); display (0); pinmode( BUTTONDOWN, INPUT_PULLUP); pinmode( BUTTONUP, INPUT_PULLUP); void loop() static unsigned int i= 0; while (1) if ( digitalread( BUTTONUP) == LOW) display (++i % 10); while ( digitalread( BUTTONUP) == LOW); if ( digitalread( BUTTONDOWN) == LOW) display(--i % 10); while ( digitalread( BUTTONDOWN) == LOW); 4 of 8

5 5.2 Seven-segment up/down counter with delay debounce 5 SKETCHES 5.2 Seven-segment up/down counter with delay debounce const int BUTTONDOWN = 2; const int BUTTONUP = 3; const int SEGMENTS = 4; void display( int digit) static unsigned char digits []= 0b , // 0 0b , // 1 0b , // 2 0b , // 3 0b , // 4 0b , // 5 0b , // 6 0b , // 7 0b , // 8 0b , // 9 ; int bits= ( digit < 0)? 0 : digits[ digit % 10]; for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i, bits >>= 1) digitalwrite(i, ( bits & 1)? HIGH : LOW); void setup() for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i) pinmode(i, OUTPUT); display (0); pinmode( BUTTONDOWN, INPUT_PULLUP); pinmode( BUTTONUP, INPUT_PULLUP); void loop() static unsigned int i= 0; while (1) if ( digitalread( BUTTONUP) == LOW) display (++i % 10); delay (100); while ( digitalread( BUTTONUP) == LOW); if ( digitalread( BUTTONDOWN) == LOW) display(--i % 10); delay (100); while ( digitalread( BUTTONDOWN) == LOW); 5 of 8

6 5.3 Seven-segment up/down counter with timer debounce 5 SKETCHES 5.3 Seven-segment up/down counter with timer debounce const int BUTTONDOWN = 2; const int BUTTONUP = 3; const int SEGMENTS = 4; void display( int digit) static unsigned char digits []= 0b , // 0 0b , // 1 0b , // 2 0b , // 3 0b , // 4 0b , // 5 0b , // 6 0b , // 7 0b , // 8 0b , // 9 ; int bits= ( digit < 0)? 0 : digits[ digit % 10]; for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i, bits >>= 1) digitalwrite(i, ( bits & 1)? HIGH : LOW); void setup() for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i) pinmode(i, OUTPUT); display (0); pinmode( BUTTONDOWN, INPUT_PULLUP); pinmode( BUTTONUP, INPUT_PULLUP); const int DEBOUNCE = 5; // milliseconds void loop() static int i= 0; while (1) if ( digitalread( BUTTONUP) == LOW) ++i; display(i); unsigned long start = millis(); while ( millis() - start < DEBOUNCE) if ( digitalread( BUTTONUP) == LOW) start= millis(); if ( digitalread( BUTTONDOWN) == LOW) --i; while (i < 0) i+= 10; display(i); unsigned long start = millis(); while ( millis() - start < DEBOUNCE) if ( digitalread( BUTTONDOWN) == LOW) start= millis(); 6 of 8

7 5.4 Seven-segment up/down counter using interrupts 5 SKETCHES 5.4 Seven-segment up/down counter using interrupts const int BUTTONDOWN = 2; const int BUTTONUP = 3; const int SEGMENTS = 4; void display( int digit) static unsigned char digits []= 0b , // 0 0b , // 1 0b , // 2 0b , // 3 0b , // 4 0b , // 5 0b , // 6 0b , // 7 0b , // 8 0b , // 9 ; int bits= ( digit < 0)? 0 : digits[ digit % 10]; for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i, bits >>= 1) digitalwrite(i, ( bits & 1)? HIGH : LOW); void setup() for ( int i= SEGMENTS; i < SEGMENTS + 7; ++i) pinmode(i, OUTPUT); display (0); pinmode( BUTTONDOWN, INPUT_PULLUP); pinmode( BUTTONUP, INPUT_PULLUP); attachinterrupt( BUTTONDOWN - 2, buttondownisr, FALLING); attachinterrupt( BUTTONUP - 2, buttonupisr, FALLING); pinmode(13, OUTPUT); // for demonstration of concurrent activity volatile static int counter = 0; void buttondownisr () if (-- counter < 0) counter += 10; display( counter); void buttonupisr() ++ counter; display( counter); void loop() for (;;) digitalwrite (13, HIGH); delay (500); digitalwrite (13, LOW ); delay (500); 7 of 8

8 A CAPACITORS A Capacitors A capacitor is a two-terminal device that stores electrical charge. When it is empty it has a very low resistance to current, and allows a large current to flow into it. As it fills up the resistance increases, and the current decreases. Eventually the capacitor is full and the current flowing into it decreases to zero, effectively giving it an infinitely large resistance. When placed in a circuit with a resistor, the capacitor behaves like a low-value resistor that gradually increases in resistance as charge flows into it. Considering the two components as a voltage divider, this means the voltage across the capacitor begins at zero (R R C ) and rises until it equals the supply voltage (R R C ). The current flowing into the capacitor, and hence the rate at which it accumulates charge and increases its voltage, is proportional to the voltage across its terminals. Therefore the rate of charging decreases as the amount of charge increases. This leads to an initial rapid increase in voltage that gradually slows as more and more charge is accumulated (and the voltage in the device increases, and the current flowing into it decreases). The time constant of a resistor-capacitor series circuit, τ (Greek letter tau ), is equal to the product of the resistor and capacitor values. The time constant indicates how long it will take for the capacitor to charge to 63% of its capacity (and hence to 63% of the supply voltage). Multiplying τ by various values tells us useful information about the time taken to reach various conditions: R C... τ 0.7 τ 1.0 τ 4.0 condition reached 50% of final voltage 63% of final voltage 98% of final voltage Reference 5V R I C V C C GND Examples of capacitor applications include timing (for oscillators, timers, switch debouncing circuits), blocking DC voltage while allowing AC signals to pass (in series connection), and stabilising voltage against short-term fluctuations (in parallel connection). A.1 Capacitor values and markings Capacitance is measured in Farads (after the physicist Michael Faraday). Typical capacitor values fall in the picofarad (1 pf = F), nanofarad (1 nf = 10 9 F) and microfarad (1 µf = 10 6 F) ranges. Capacitors are either marked with their value directly, or (similarly to resistors) are marked with three digits indicating a two-digit value and an exponent giving the value in pf. Larger values (more than a few µf) are often polarised, and will have the positive and negative terminals marked (and possibly have a positive lead that is longer than the negative, like LEDs). Unlike LEDs, connecting a polarised capacitor the wrong way round is very damgerous and can lead to explosive failure of the device µf polarised 100 nf ( pf) marking value pf 100 pf pf 2.2 nf pf 10 nf pf 100 nf + 8 of 8

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

Robotics and Electronics Unit 5

Robotics and Electronics Unit 5 Robotics and Electronics Unit 5 Objectives. Students will work with mechanical push buttons understand the shortcomings of the delay function and how to use the millis function. In this unit we will use

More information

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

Button Input: On/off state change

Button Input: On/off state change Button Input: On/off state change Living with the Lab Gerald Recktenwald Portland State University gerry@pdx.edu User input features of the fan Potentiometer for speed control Continually variable input

More information

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

1 Overview. 2 Basic Program Structure. 2.1 Required and Optional Parts of Sketch Living with the Lab Winter 2015 What s this void loop thing? Gerald Recktenwald v: February 7, 2015 gerry@me.pdx.edu 1 Overview This document aims to explain two kinds of loops: the loop function that

More information

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

Specification. 1.Power Supply direct from Microcontroller Board. 2.The circuit can be used with Microcontroller Board such as Arduino UNO R3. Part Number : Product Name : FK-FA1410 12-LED AND 3-BOTTON SHIELD This is the experimental board for receiving and transmitting data from the port of microcontroller. The function of FK-FA1401 is fundamental

More information

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

Review of the syntax and use of Arduino functions, with special attention to the setup and loop functions. Living with the Lab Fall 2011 What s this void loop thing? Gerald Recktenwald v: October 31, 2011 gerry@me.pdx.edu 1 Overview This document aims to explain two kinds of loops: the loop function that is

More information

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

Procedure: Determine the polarity of the LED. Use the following image to help: Section 2: Lab Activity Section 2.1 Getting started: LED Blink Purpose: To understand how to upload a program to the Arduino and to understand the function of each line of code in a simple program. This

More information

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

Note. The above image and many others are courtesy of   - this is a wonderful resource for designing circuits. Robotics and Electronics Unit 2. Arduino Objectives. Students will understand the basic characteristics of an Arduino Uno microcontroller. understand the basic structure of an Arduino program. know how

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

Coding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic.

Coding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic. Coding Workshop Learning to Program with an Arduino Lecture Notes Table of Contents Programming ntroduction Values Assignment Arithmetic Control Tests f Blocks For Blocks Functions Arduino Main Functions

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

Laboratory 10. Programming a PIC Microcontroller - Part II

Laboratory 10. Programming a PIC Microcontroller - Part II Laboratory 10 Programming a PIC Microcontroller - Part II Required Components: 1 PIC16F88 18P-DIP microcontroller 1 0.1 F capacitor 3 SPST microswitches or NO buttons 4 1k resistors 1 MAN 6910 or LTD-482EC

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

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

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

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

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

The DTMF generator comprises 3 main components.

The DTMF generator comprises 3 main components. Make a DTMF generator with an Arduino board This article is for absolute beginners, and describes the design and construction of a DTMF generator. DTMF generators are often used to signal with equipment

More information

Building your own special-purpose embedded system gadget.

Building your own special-purpose embedded system gadget. Bare-duino Building your own special-purpose embedded system gadget. Saves a little money. You can configure the hardware exactly the way that you want. Plus, it s fun! bare-duino 1 Arduino Uno reset I/O

More information

ENGR 40M Project 3c: Switch debouncing

ENGR 40M Project 3c: Switch debouncing ENGR 40M Project 3c: Switch debouncing For due dates, see the overview handout 1 Introduction This week, you will build on the previous two labs and program the Arduino to respond to an input from the

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

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

8051 Microcontroller Interrupts

8051 Microcontroller Interrupts 8051 Microcontroller Interrupts There are five interrupt sources for the 8051, which means that they can recognize 5 different events that can interrupt regular program execution. Each interrupt can be

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

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

Digital Design through. Arduino

Digital Design through. Arduino Digital Design through 1 Arduino G V V Sharma Contents 1 Display Control through Hardware 2 1.1 Powering the Display.................................. 2 1.2 Controlling the Display.................................

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

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

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE, 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.

More information

Counter & LED (LED Blink)

Counter & LED (LED Blink) 1 T.R.E. Meeting #1 Counter & LED (LED Blink) September 17, 2017 Contact Info for Today s Lesson: President Ryan Muller mullerr@vt.edu 610-573-1890 Learning Objectives: Learn how to use the basics of Arduino

More information

genie.attacheventhandler(mygenieeventhandler); // Attach the user function Event Handler for processing events

genie.attacheventhandler(mygenieeventhandler); // Attach the user function Event Handler for processing events #include #include #include //#include Genie genie; #define RESETLINE 4 Timer t1,t4,t2; int needsave = 1; int timesince = 0; int pulses, A_SIG = 0, B_SIG

More information

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

University of Hull Department of Computer Science C4DI Interfacing with Arduinos Introduction Welcome to our Arduino hardware sessions. University of Hull Department of Computer Science C4DI Interfacing with Arduinos Vsn. 1.0 Rob Miles 2014 Please follow the instructions carefully.

More information

Pro Trinket Tachometer

Pro Trinket Tachometer Pro Trinket Tachometer Created by Bill Earl Last updated on 2017-07-19 08:02:09 PM UTC Guide Contents Guide Contents Overview Materials Required: Recommended or Optional Materials Circuit Design Components:

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Lecture 12 Some Hardware Considerations Hardware Considerations Slide 1 Logic States Digital signals may be in one of three states State 1: High, or 1. Using positive logic

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

Functions (API) Setup Functions

Functions (API) Setup Functions Functions (API) Some of the functions in the WiringPi library are designed to mimic those in the Arduino Wiring system. There are relatively easy to use and should present no problems for anyone used to

More information

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O ELEC 3040/3050 Lab 5 Matrix Keypad Interface Using Parallel I/O Goals of this lab exercise Control a real device with the microcontroller Coordinate parallel I/O ports to control and access a device Implement

More information

Lecture (03) PIC16F84 (2)

Lecture (03) PIC16F84 (2) Lecture (03) PIC16F84 (2) By: Dr. Ahmed ElShafee ١ PIC16F84 has a RISC architecture, or Harvard architecture in another word ٢ PIC16F84 belongs to a class of 8 bit microcontrollers of RISC architecture.

More information

IME-100 Interdisciplinary Design and Manufacturing

IME-100 Interdisciplinary Design and Manufacturing IME-100 Interdisciplinary Design and Manufacturing Introduction Arduino and Programming Topics: 1. Introduction to Microprocessors/Microcontrollers 2. Introduction to Arduino 3. Arduino Programming Basics

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

Laboratory 1 Introduction to the Arduino boards

Laboratory 1 Introduction to the Arduino boards Laboratory 1 Introduction to the Arduino boards The set of Arduino development tools include µc (microcontroller) boards, accessories (peripheral modules, components etc.) and open source software tools

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

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

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

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller The 8051, Motorola and PIC families are the 3 leading sellers in the microcontroller market. The 8051 microcontroller was originally developed by Intel in the late 1970 s. Today many

More information

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

Smart Objects. SAPIENZA Università di Roma, M.Sc. in Product Design Fabio Patrizi Smart Objects SAPIENZA Università di Roma, M.Sc. in Product Design Fabio Patrizi 1 What is a Smart Object? Essentially, an object that: Senses Thinks Acts 2 Example 1 https://www.youtube.com/watch?v=6bncjd8eke0

More information

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

Serial.begin ( ); Serial.println( ); analogread ( ); map ( ); Control and Serial.begin ( ); Serial.println( ); analogread ( ); map ( ); A system output can be changed through the use of knobs, motion, or environmental conditions. Many electronic systems in our world

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

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

3. The circuit is composed of 1 set of Relay circuit. Part Number : Product Name : FK-FA1420 ONE CHANNEL 12V RELAY MODULE This is the experimental module for a relay controller as the fundamental controlling programming. It is adaptable or is able to upgrade

More information

SX1509 I/O Expander Breakout Hookup Guide

SX1509 I/O Expander Breakout Hookup Guide Page 1 of 16 SX1509 I/O Expander Breakout Hookup Guide Introduction Is your Arduino running low on GPIO? Looking to control the brightness of 16 LEDs individually? Maybe blink or breathe a few autonomously?

More information

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6 Mechatronics and Measurement Lecturer:Dung-An Wang Lecture 6 Lecture outline Reading:Ch7 of text Today s lecture: Microcontroller 2 7.1 MICROPROCESSORS Hardware solution: consists of a selection of specific

More information

Microcontrollers and Interfacing week 10 exercises

Microcontrollers and Interfacing week 10 exercises 1 SERIAL PERIPHERAL INTERFACE (SPI) HARDWARE Microcontrollers and Interfacing week 10 exercises 1 Serial Peripheral Interface (SPI) hardware Complex devices (persistent memory and flash memory cards, D/A

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

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

Workshop on Microcontroller Based Project Development

Workshop on Microcontroller Based Project Development Organized by: EEE Club Workshop on Microcontroller Based Project Development Presented By Mohammed Abdul Kader Assistant Professor, Dept. of EEE, IIUC Email:kader05cuet@gmail.com Website: kader05cuet.wordpress.com

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

Arduino Part 3. Introductory Medical Device Prototyping

Arduino Part 3. Introductory Medical Device Prototyping Introductory Medical Device Prototyping Arduino Part 3, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Functions More functions: Math functions Trigonometry

More information

Interrupts and Timers

Interrupts and Timers Indian Institute of Technology Bombay CS684/CS308 Embedded Systems Interrupts and Timers E.R.T.S. Lab 1 Lab Objective This lab will introduce you to the use of Timers and Interrupts on the TM4C123GH6PM.

More information

Halloween Pumpkinusing. Wednesday, October 17, 12

Halloween Pumpkinusing. Wednesday, October 17, 12 Halloween Pumpkinusing Blink LED 1 What you will need: 1 MSP-EXP430G2 1 3 x 2 Breadboard 3 560 Ohm Resistors 3 LED s (in Red Color Range) 3 Male to female jumper wires 1 Double AA BatteryPack 2 AA Batteries

More information

EK307 Lab: Microcontrollers

EK307 Lab: Microcontrollers EK307 Lab: Microcontrollers Laboratory Goal: Program a microcontroller to perform a variety of digital tasks. Learning Objectives: Learn how to program and use the Atmega 323 microcontroller Suggested

More information

DS1821 Programmable Digital Thermostat and Thermometer

DS1821 Programmable Digital Thermostat and Thermometer ma www.maxim-ic.com FEATURES Requires no external components Unique 1-Wire interface requires only one port pin for communication Operates over a -55 C to +125 C (-67 F to +257 F) temperature range Functions

More information

DS1676 Total Elapsed Time Recorder, Erasable

DS1676 Total Elapsed Time Recorder, Erasable www.dalsemi.com Preliminary DS1676 Total Elapsed Time Recorder, Erasable FEATURES Records the total time that the Event Input has been active and the number of events that have occurred. Volatile Elapsed

More information

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O ELEC 3040/3050 Lab 5 Matrix Keypad Interface Using Parallel I/O Goals of this lab exercise Control a real device with the microcontroller Coordinate parallel I/O ports to control and access a device Implement

More information

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation Embedded systems Exercise session 3 Microcontroller Programming Lab Preparation Communications Contact Mail : michael.fonder@ulg.ac.be Office : 1.82a, Montefiore Website for the exercise sessions and the

More information

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I. University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 03 Low Power Mode and Port Interrupts Goals: Bonus: Pre Lab Questions:

More information

IAS0430 MICROPROCESSOR SYSTEMS

IAS0430 MICROPROCESSOR SYSTEMS IAS0430 MICROPROCESSOR SYSTEMS Fall 2018 Arduino and assembly language Martin Jaanus U02-308 martin.jaanus@ttu.ee 620 2110, 56 91 31 93 Learning environment : http://isc.ttu.ee Materials : http://isc.ttu.ee/martin

More information

Arduino notes 3: Digital input via buttons

Arduino notes 3: Digital input via buttons 1 Arduino notes 3: Digital input via buttons This is not a tutorial, but a collection of personal notes to remember the essentials of Arduino programming. The program fragments are snippets that represent

More information

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application... Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 19, 2011 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F684A processor,

More information

Digital I/O Operations

Digital I/O Operations Digital I/O Operations CSE0420 Embedded Systems By Z. Cihan TAYŞİ Outline Digital I/O Ports, Pins Direction Pull-up & pull-down Arduino programming Digital I/O examples on Arduino 1 Digital I/O Unlike

More information

Module Introduction. PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events.

Module Introduction. PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events. Module Introduction PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events. OBJECTIVES: - Describe the difference between resets and interrupts. - Identify

More information

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics This report is the first of a three part series that discusses the features of the PIC 16F94A processor. The reports will refer

More information

Course materials and schedule are at. This file:

Course materials and schedule are at.  This file: Physics 364, Fall 2014, Lab #22 Name: (Arduino 3: Serial data and digital feedback written by Zoey!) Monday, November 17 (section 401); Tuesday, November 18 (section 402) Course materials and schedule

More information

Using programmed I/O on the M16C; and Writing an Interrupt Service Routine (ISR)

Using programmed I/O on the M16C; and Writing an Interrupt Service Routine (ISR) Tutorial 2 Basic M16C Programming 1 Introduction The goal for Tutorial 2 is to take a more in-depth look at the sample program from the previous tutorial, and make use of it as a foundation for writing

More information

High Speed USB Controllers for serial and FIFO applications. Debug Information for FT8U232/245 devices

High Speed USB Controllers for serial and FIFO applications. Debug Information for FT8U232/245 devices Debug Information for FT8U232/245 devices This information is provided to help debug a design using the FT8U232 / FT8U245 devices. 1.(A) Clock circuit (48 MHz crytsal) Here is what the clock output (pin

More information

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

3.The circuit board is composed of 4 sets which are 16x2 LCD Shield, 3 pieces of Switch, 2 Part Number : Product Name : FK-FA1416 MULTI-FUNCTION 16x2 LCD SHIELD This is the experimental board of Multi-Function 16x2 LCD Shield as the fundamental programming about the digits, alphabets and symbols.

More information

Chapter 11: Interrupt On Change

Chapter 11: Interrupt On Change Chapter 11: Interrupt On Change The last two chapters included examples that used the external interrupt on Port C, pin 1 to determine when a button had been pressed. This approach works very well on most

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

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 { 0x25, 0x66 }, // "4" { 0x2E, 0x6D }, // "5" { 0x36, 0x7D }, // "6" { 0x3D, 0x07 }, // "7" { 0x3E, 0x7F }, // "8" { 0x46,

More information

Interrupts, timers and counters

Interrupts, timers and counters Interrupts, timers and counters Posted on May 10, 2008, by Ibrahim KAMAL, in Micro-controllers, tagged Most microcontrollers come with a set of ADD-ONs called peripherals, to enhance the functioning of

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

UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2013

UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2013 Introduction Reading Concepts UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2013 Lab 2 Bouncing LEDs In this lab, you will

More information

// Software Version 1 = 6 settings, 2 = 18 settings // Defining Time Toggle Switch Address as (A3) // Anolog A1 for Frequency Potentiometer output

// Software Version 1 = 6 settings, 2 = 18 settings // Defining Time Toggle Switch Address as (A3) // Anolog A1 for Frequency Potentiometer output ` #include #define SoftVer 2 // Software Version 1 = 6 settings, 2 = 18 settings #define SpeedToggle A4 // Defining Speed Toggle Switch Address as (A4) #define TimeToggle A3 // Defining Time

More information

WALT: definition and decomposition of complex problems in terms of functional and non-functional requirements

WALT: definition and decomposition of complex problems in terms of functional and non-functional requirements Item 5: It's Totally Random Monday, 5 October 08 :5 PM IT'S TOTALLY RANDOM EXPLORE WALT: definition and decomposition of complex problems in terms of functional and non-functional requirements WILF - Defined

More information

Arduino Programming Part 4: Flow Control

Arduino Programming Part 4: Flow Control Arduino Programming Part 4: Flow Control EAS 199B, Winter 2010 Gerald Recktenwald Portland State University gerry@me.pdx.edu Goal Make choices based on conditions in the environment Logical expressions:

More information

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

Lab 2 - Powering the Fubarino. Fubarino,, Intro to Serial, Functions and Variables Lab 2 - Powering the Fubarino Fubarino,, Intro to Serial, Functions and Variables Part 1 - Powering the Fubarino SD The Fubarino SD is a 56 pin device. Each pin on a chipkit device falls broadly into one

More information

DS1233A 3.3V EconoReset

DS1233A 3.3V EconoReset 3.3V EconoReset www.maxim-ic.com FEATURES Automatically restarts microprocessor after power failure Monitors pushbutton for external override Internal circuitry debounces pushbutton switch Maintains reset

More information

DS2401 Silicon Serial Number

DS2401 Silicon Serial Number Silicon Serial Number www.maxim-ic.com FEATURES Upgrade and drop-in replacement for DS2400 Extended 2.8 to 6.0 voltage range Multiple s can reside on a common 1-Wire Net Unique, factory-lasered and tested

More information

LED1 LED2. Capacitive Touch Sense Controller LED3 LED4

LED1 LED2. Capacitive Touch Sense Controller LED3 LED4 October 2012 Introduction Reference Design RD1136 Capacitive sensing is a technology based on capacitive coupling which takes human body capacitance as input. Capacitive touch sensors are used in many

More information

CTEC 1802 Embedded Programming Labs

CTEC 1802 Embedded Programming Labs CTEC 1802 Embedded Programming Labs This document is intended to get you started using the Arduino and our I/O board in the laboratory - and at home! Many of the lab sessions this year will involve 'embedded

More information

Arduino - DigitalReadSerial

Arduino - DigitalReadSerial arduino.cc Arduino - DigitalReadSerial 5-6 minutes Digital Read Serial This example shows you how to monitor the state of a switch by establishing serial communication between your Arduino or Genuino and

More information

S12VR Hardware Design. Guidelines. 1 Introduction. 2 Hardware Design. Guidelines. 2.1 Voltage regulator. Freescale Semiconductor

S12VR Hardware Design. Guidelines. 1 Introduction. 2 Hardware Design. Guidelines. 2.1 Voltage regulator. Freescale Semiconductor Freescale Semiconductor Document Number: AN4643 Application Note Rev 1, 10/2013 S12VR Hardware Design Guidelines by: Carlos Aceff 1 Introduction This document lists the required external components and

More information

Arduino ADK Rev.3 Board A000069

Arduino ADK Rev.3 Board A000069 Arduino ADK Rev.3 Board A000069 Overview The Arduino ADK is a microcontroller board based on the ATmega2560 (datasheet). It has a USB host interface to connect with Android based phones, based on the MAX3421e

More information

APPLICATION NOTE 655 Supervisor ICs Monitor Battery-Powered Equipment

APPLICATION NOTE 655 Supervisor ICs Monitor Battery-Powered Equipment Maxim > Design Support > Technical Documents > Application Notes > Automotive > APP 655 Maxim > Design Support > Technical Documents > Application Notes > Microprocessor Supervisor Circuits > APP 655 Keywords:

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

Overvoltage-Protection Controllers with a Low RON Internal FET MAX4970/MAX4971/MAX4972

Overvoltage-Protection Controllers with a Low RON Internal FET MAX4970/MAX4971/MAX4972 19-4139; Rev 1; 8/08 Overvoltage-Protection Controllers General Description The family of overvoltage protection devices features a low 40mΩ (typ) R ON internal FET and protect low-voltage systems against

More information

ARDUINO LEONARDO ETH Code: A000022

ARDUINO LEONARDO ETH Code: A000022 ARDUINO LEONARDO ETH Code: A000022 All the fun of a Leonardo, plus an Ethernet port to extend your project to the IoT world. You can control sensors and actuators via the internet as a client or server.

More information

ARDUINO UNO REV3 Code: A000066

ARDUINO UNO REV3 Code: A000066 ARDUINO UNO REV3 Code: A000066 The UNO is the best board to get started with electronics and coding. If this is your first experience tinkering with the platform, the UNO is the most robust board you can

More information

The short program to blink the red LED used the delay() function. This is very handy function for introducing a short time delays into programs.

The short program to blink the red LED used the delay() function. This is very handy function for introducing a short time delays into programs. Timing The short program to blink the red LED used the delay() function. This is very handy function for introducing a short time delays into programs. It helps buffer the differing time scales of humans

More information

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

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 cs28: Introduction to Computer Systems Lab3 K-Map Simplification for an LED-based Circuit Overview In this lab, we will build a more complex combinational circuit than the mux or sum bit of a full adder

More information