1 introduction. 2 microcontrollers programmers work in the virtual world. machinery works in the...

27
1 Introduction

Upload: denis-conley

Post on 22-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

1

Introduction

2

Microcontrollers• Programmers work in the virtual world.• Machinery works in the physical world.• The microcontroller connects the virtual world

to the physical world• A microcontroller is a small-scale computer

with generalized (and programmable) inputs and outputs.

• The inputs and outputs can be manipulated by, and can manipulate, the physical world.

3

Arduino is hardware

4

Arduino is software• Including an Integrated

Development Environment (IDE) for programming.

• It’s used to edit code as if editing a word document

• The platform is used to create the “process”, compile it, and then upload it to the microcontroller.

• The language itself is based in C and is called ‘wiring’

5

Arduino is a platform• A physical Input / Output

board (I/O) with a programmable Integrated Circuit (IC).

6

Why Arduino?

• It is Open Source, both in terms of Hardware and Software. Anyone who wants can copy it for free

• It is cheap, the hardware can be built from components or a prefab board can be purchased for as little as $15

• It can communicate with a computer via serial connection over USB (common interfaces)

• It can be powered from USB or standalone DC power.• It can run standalone from a computer (chip is

programmable) and it has memory (a small amount).

7

What can it do?• Sensors ( to sense stuff ) [ INPUTS ]

– Push buttons, touch pads, tilt switches.– Variable resistors (eg. volume knob / sliders)– Photoresistors (sensing light levels)– Thermistors (temperature)– Ultrasound (proximity range finder)

• Actuators ( to do stuff ) [ OUTPUTS ]

– Lights, LED’s– Motors– Speakers– Displays (LCD)

CURRENT LIMITS!!!

8

Autonomous Vehicle

9

Laser Harp

10

Clock

11

Sign Language Glove

12

Interfacing

13

Interfacing

• Plugs into pins like a breadboard

14

15

16

17

Inputs and Outputs

18

Concepts: INPUT vs. OUTPUT•Referenced from the perspective of the

microcontroller (electrical board).Inputs is a signal / information going

into the board.Output is any signal exiting the

board.

19

Concepts: INPUT vs. OUTPUT•Referenced from the perspective of the

microcontroller (electrical board).

Inputs is a signal / information going into the board.

Output is any signal exiting the board.

Examples: Buttons Switches, Light Sensors, Flex Sensors,

Humidity Sensors, Temperature Sensors…

Examples: LEDs, DC motor,

servo motor, piezo buzzer, relay, RGB LED

20

Analog vs. Digital

21

Analog vs. Digital• Computers “naturally” talk in a digital language. Things

are either “ON” or “OFF”, “HIGH” or “LOW”, “1” or “0”, “5V or 0V”

• Our physical world is analog. Things can be “medium”, “warm”, “37 mph”, “92 degrees”

• So how do we create 2.75 volts if all we have is 0 and 5?• With a technique called Pulse width Modulation (PWM)• Imagine turning a fan off and on every second. It would

operate at a “medium” speed.• The longer the pulses (ON’s), the higher the average

voltage and the actual voltage output.

22

Analog vs. Digital

23

Analog vs. Digital

Fixed cycle length:constant number of cycles/sec

24

BIG

4 C

ON

CEPT

S digitalWrite()

analogWrite()

digitalRead()

analogRead()

25

ComponentsPush Button Digital Input Switch - Closes or

opens circuit

Potentiometer Analog Input Variable resistor

Photoresistor Analog Input Light Dependent Resistor (LDR)

Relay Digital Output Switch driven by a small signal

Temp Sensor Analog Input Temp Dependent Resistor

Flex Sensor Analog Input Variable resistor

Soft Trimpot Analog Input Variable resistor

RGB LED Dig & Analog Output

16,777,216 different colors

Name Image Type Function

26

Scales

27

ScalesPhysical 0V 5V

Digital Write LOW (0) HIGH (1)

Digital Read LOW (0) HIGH (1)

Analog Read 0 1023

Analog Write 0 255