EMS1EP Lecture 5 Digital Outputs Dr. Robert Ross.

Slides:



Advertisements
Similar presentations
Automation and Control of a limited size parking lot using PIC18 Microcontroller Alaa Sharif Ali Ghamlouch Zaher Khattab April 2011 Presented to: Dr. Youmin.
Advertisements

EMS1EP Lecture 6 Digital Inputs
EMS1EP Lecture 2 Electronic Circuits Dr. Robert Ross.
EMS1EP Lecture 7 Program Structure and Serial I/O Dr. Robert Ross.
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
EMS1EP Lecture 1 Intro to Arduino Dr. Robert Ross.
EMS1EP Lecture 9 Analog to Digital Conversion (ADC) Dr. Robert Ross.
Lab7: Introduction to Arduino
Prof. Kristofer S.J. Pister’s team Berkeley Sensor and Actuator Center University of California, Berkeley.
Bread Boarding and Operating The IFI Robotic Control System.
Dr. Andreas Kunz © 10/2004 inspire icvr BASICS OF ELECTRONICS.
Construction and Interfacing of a Solar Telescope Jon Turner University of Northern Colorado.
How to Build a Digital-Physical System-Lab Assegid Kidané Fall 2014.
ECE 265 – LECTURE 13 Interface to switches and LEDs 7/3/ ECE265.
Introduction.
Conference Room Laser Pointer System Anna Goncharova, Brent Hoover, Alex MendesSponsored by Dr. Jeffrey Black Overview The project concept was developed.
HARDWARE LIBRE PARA LINUX Y ANDROID. Arduino is a platform  A physical Input / Output board (I/O) with a programmable Integrated Circuit (IC).
Daniel Pickem and Rowland O’Flaherty 12/04/2012 Mechatronics (ME 6405) Student Lecture On Arduinos *Some slides courtesy of Eoin Brazil
Basic Stamp Free Pins These pins can be used by the operator for digital Inputs and Outputs Used Pins 0.
Programming Hexors on Arduino Uno. Arduino Uno Arduino is an open-source electronics platform based on easy- to-use hardware and software. It's intended.
Unleash Your Inner Inventor Using the Arduino Microcontroller For More Than You Would Expect.
ERGM 1413 Programming and Playing with Intelligent Robots Prof. K.H. Wong Robot building v4.7b1.
I am a….. Read the statements. Use the text book to help you figure out which input or output device it is…… Good luck.
Arnan Sipitakiat Dept. Compute Engineering, Chiang Mai University.
L ILY P AD T RAINING C ENTENNIAL E LEMENTARY 2012 Material by Linz Craig Revision by Sarah Bloms Additional images by Modkit & Adam Meyer.
Overview What is Arduino? What is it used for? How to get started Demonstration Questions are welcome at any time.
The 3 parts of an electronic system are :
An-Najah National University Faculty of Engineering Department of Mechatronics Engineering Whiteboard Notes Tracking-Erasing System.
EML 2023 – Motor Control Lecture 1 – Closed Loop Motor Control.
Interactive Control in Engineering Projects Electronics and Control.
MAKE: AN ELECTRONICS WORKSHOP
IN 1900 ICT Project Final Presentation. Group name : Code Squad.
IMDL Robot Presentation EEL5666 Robert Hartwell 31 Jan 2012.
 Today we will cover:  Voltage regulators  Sensors  motordrivers iBOT1.
Throttle Arduino RC Receiver Stock Golf Cart Motor Controller Motor 1 PWM signal: Voltage: 0 – 5V Period = 22ms Positive Pulse Width: 1ms – 2ms Digital.
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
Bdps 2 Lecture 2. Circuits and Ohm's Law For resistive circuits.
ISA CLICK CONTROL #38 – FALL 2014 ERIC BRUNNGRABER DRAKE ISABIRYE.
HW & SW Overview  What’s UNO  Hardware  Specification  Installing IDE  Programming  Compiling.
Output and Actuator Output: Any signal or information, digital or analog that has been decided in a system by a systematic processing way is known as.
1 Transistor. 2 Transistors are used to turn components on and off They come in all different shapes and sizes.
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
CSE 341 Project : Ultrasonic Radar PRESENTED BY: NAME : AKIFA TASNEEM ID : SECTION: 02 1.
What is programming? Make an algorithm to do something in a specific language programming. – Algorithm: a procedure or formula for solving a problem.
Arduino.
H-Bridge Motor Driver.
RASPBERRY PI WORKSHOP.
Obstacle avoiding robot { pixel }
connect a DC-Motor with an arduino
Standard Genie E18 Circuit
Automatic human detector garbage can.
‘SONAR’ using Arduino & ultrasonic distance sensor
Arduino and Grove LET’S START.
Introduction to Arduinos
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
Automatic Cloth Folding Machine
Welcome to Digital Electronics using the Arduino Board
Arduino Board.
Arduino : Introduction & Programming
I/O Programming with Arduino
TI LaunchPad I/O Programming with Energia
Arduino Uno circuit basics
Arduino Board.
Arduino म्हणजे काय?.
Introduction to Arduinos
Arduino程式範例.
Introduction to Arduino IDE and Software
Interrupts.
Presentation transcript:

EMS1EP Lecture 5 Digital Outputs Dr. Robert Ross

Overview (what you should learn today) Hardware Connections What the pins on the LArduino board do Setting pin directions digitalWrite()

Hardware Microcontrollers need to interact with the real world (sensing, computing and outputting) Today we look at how the microcontroller can control or output data There are lots of things we might want to control: – LED – Motor – Servo – Linear Actuator – Relay – Speaker

Connecting hardware to the microcontroller The pins on the microcontroller can only supply a small amount of current (<20mA) Indicator LEDs are relatively low current (~5- 15mA) and so they can be driven directly – larger current devices need another way to drive them

Driving LEDs from an Arduino Datasheet gives current and voltage for LED For example: V f = 1.9V I f = 10mA Use KVL and ohms law to find the value of R

Driving LEDs from an Arduino V f = 1.9V I f = 10mA If Vcc = 5V R = 310Ω

Class Quiz As Vcc, V f and I f may change depending on the circuit, what current limiting resistor is needed for the following: Vcc = 3.3V V f = 2.1V I f = 15mA

Driving higher currents Use a transistor as a switch Transistor has small base current but much larger collector current – so it can switch a higher load For even higher loads use FETs as they have a lower on-resistance

Pins on the LArduino Select between USB supplied power and power on V+ pin Reset switch Analog input pins for ADC GND, 5V and V+ Digital I/O Pins Pins with a ‘P’ can be used for pulse width modulation

Driving a LED with the LArduino Use 5V pin as Vcc Use R = 330Ω Resistors Set power to USB

Driving a LED with the LArduino // PIN ASSIGNMENTS int ledPin = 10; // LED connected to digital pin10 // The setup() method runs once on startup void setup() { // initialize pin as output: pinMode(ledPin, OUTPUT); } // Infinite loop void loop() { digitalWrite(ledPin, HIGH);// LED OFF delay(1000); // Wait 1S digitalWrite(ledPin, LOW); // LED ON delay(1000); // Wait 1S }

Digital Inputs and Outputs The next two lectures will focus on the digital pins – the analog pins will come later Before using the digital pins we need to set them up as either inputs or outputs This is called setting the direction of the pins (input direction or output direction) To do this we use the pinMode() function Use pin assignments to refer to pins by name rather than number

pinMode() function Syntax: pinMode(, ) Normally some pins will be assigned at the top of your code e.g. – int LED1Pin = 10; – int switchPin = 11; These assignments are used for the pin number Direction should be OUTPUT or INPUT e.g. – pinMode(LED1Pin, OUTPUT); – pinMode(switchPin, INPUT);

Class Quiz Pins 5 and 9 have LEDs connected to them Pin 7 has a speaker connected to it Pins 6 and 12 have switches connected to them Write code to assign names to these pins and then code to set the direction of these pins inside the setup() function

digitalWrite() After the direction of the pins has been setup the pins can either be set to high (5V) or low (0V) digitalWrite() is used to set the value of each pin Syntax: – digitalWrite(, ); e.g. //Sets pin to 5V – LED off digitalWrite(LED1Pin, HIGH); //Sets pin to 0V – LED on digitalWrite(LED1Pin, LOW); (0 and 1 can also be used to assign low and high respectively)

Class Quiz Use the digitalWrite() function to do the following: – Set the pin LED1Pin to 5V – Set the pin Buzzer1Pin to a logical low – Set the pin LED3Pin to High – Turn on the LED at LED2Pin (the LED is in a sinking arrangement as shown earlier)

Class Challenge Write a full sketch to alternately flash two LEDs (like a railway crossing) LED flash period should be 1.5 seconds LEDs on pins 10 and 12 Write: – Pin assignments – Setup Function – Loop function

Summary (What you learnt in this session) How to interface an LED with an Arduino What the different pins on the LArduino do Setting up pins and inputs and outputs Setting pins high and low