LEDs and Sensors Part 2: Analog to Digital

Similar documents
THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS.

Lab 06: Ohm s Law and Servo Motor Control

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

FABO ACADEMY X ELECTRONIC DESIGN

ILR #1: Sensors and Motor Control Lab. Zihao (Theo) Zhang- Team A October 14, 2016 Teammates: Amit Agarwal, Harry Golash, Yihao Qian, Menghan Zhang

02 Digital Input and Output

Monitoring Temperature using LM35 and Arduino UNO

Rodni What will yours be?

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

Voltage Dividers a learn.sparkfun.com tutorial

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

.:Twisting:..:Potentiometers:.

DC Motor and Servo motor Control with ARM and Arduino. Created by:

SCHOOL OF TECHNOLOGY AND PUBLIC MANAGEMENT ENGINEERING TECHNOLOGY DEPARTMENT

100UF CAPACITOR POTENTIOMETER SERVO MOTOR MOTOR ARM. MALE HEADER PIN (3 pins) INGREDIENTS

Lab Exercise 6: Digital/Analog conversion

EE283 Laboratory Exercise 1-Page 1

Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

PWM CONTROL USING ARDUINO. Learn to Control DC Motor Speed and LED Brightness

MAE106 Laboratory Exercises Lab # 3 Open-loop control of a DC motor

A very quick and dirty introduction to Sensors, Microcontrollers, and Electronics

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

Two-Tone Phototransistor Theremin Using a 556 Timer IC

1. Introduction to Analog I/O

Guide to LED and Hobby Lighting Projects Documentation

Figure 1: Basic Relationships for a Comparator. For example: Figure 2: Example of Basic Relationships for a Comparator

Arduino Workshop 01. AD32600 Physical Computing Prof. Fabian Winkler Fall 2014

MAKEVMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

Workshop 9: First steps in electronics

Intro to Electronics. Week 1

Series and parallel resistances

// Parts of a Multimeter

Pulse Width Modulation and

P a g e 1. Introduction

Exam Practice Problems (3 Point Questions)

Direct Current Waveforms

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

CMSC838. Tangible Interactive Assistant Professor Computer Science. Week 11 Lecture 20 April 9, 2015 Motors

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

LED + Servo 2 devices, 1 Arduino

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

Introduction to Electronics and Breadboarding Circuits

Demon Pumpkin APPROXIMATE TIME (EXCLUDING PREPARATION WORK): 1 HOUR PREREQUISITES: PART LIST:

Lab 2: Blinkie Lab. Objectives. Materials. Theory

Lesson 3: Arduino. Goals

Chapter #5: Measuring Rotation

Laboratory 2 More Resistor Networks and Potentiometers.

Basic Electronics Course Part 2

Electronic Components

Data Conversion and Lab Lab 4 Fall Digital to Analog Conversions

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

EEE3410 Microcontroller Applications Department of Electrical Engineering. Lecture 10. Analogue Interfacing. Vocational Training Council, Hong Kong.

University of Portland EE 271 Electrical Circuits Laboratory. Experiment: Op Amps

Basic Electronics Refresher

Module: Arduino as Signal Generator

Arduino Intermediate Projects

CMSC838. Tangible Interactive Assistant Professor Computer Science

University of North Carolina-Charlotte Department of Electrical and Computer Engineering ECGR 3157 Electrical Engineering Design II Fall 2013

Fading a RGB LED on BeagleBone Black

ARDUINO / GENUINO. start as professional

Theremino FlickerMeter

Physics 310 Lab 6 Op Amps

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

TV Remote. Discover Engineering. Youth Handouts

Assignments from last week

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

Arduino: Sensors for Fun and Non Profit

Lab 1 - Analogue and Digital Signals

Internet of Things Student STEM Project Jackson High School. Lesson 3: Arduino Solar Tracker

Experiment #3: Micro-controlled Movement

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Pulse Generation. Pulsout. 555 Timer. Software version of pulse generation Pulsout pin, Period

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

3.5 hour Drawing Machines Workshop

TWEAK THE ARDUINO LOGO

Precalculations Individual Portion Introductory Lab: Basic Operation of Common Laboratory Instruments

PCB & Circuit Designing (Summer Training Program) 6 Weeks/ 45 Days PRESENTED BY

Community College of Allegheny County Unit 7 Page #1. Analog to Digital

University of North Carolina, Charlotte Department of Electrical and Computer Engineering ECGR 3157 EE Design II Fall 2009

Data Conversion and Lab Lab 3 Spring Analog to Digital Converter

MARMARA UNIVERSITY CSE315 DIGITAL DESIGN LABORATORY MANUAL. EXPERIMENT 7: Analog-to-Digital Conversion. Research Assistant Müzeyyen KARAMANOĞLU

Understanding the Arduino to LabVIEW Interface

BME/ISE 3511 Bioelectronics I - Laboratory Exercise #4. Variable Resistors (Potentiometers and Rheostats)

Lecture 6. Interfacing Digital and Analog Devices to Arduino. Intro to Arduino

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Nano v3 pinout 19 AUG ver 3 rev 1.

Training Schedule. Robotic System Design using Arduino Platform

Module 13: Interfacing ADC. Introduction ADC Programming DAC Programming Sensor Interfacing

Pulse-Width-Modulation Motor Speed Control with a PIC (modified from lab text by Alciatore)

Chapter 5: Analog Input

Circuit LED 1 LED 2 A on or off on or off B on or off on or off C on or off on or off

introduction to Digital Electronics Install the Arduino IDE on your laptop if you haven t already!

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

Motors and Servos Part 2: DC Motors

o Semiconductor Diode Symbol: The cathode contains the N-type material and the anode contains the P-type material.

digitalread() EE 285 Arduino 1

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

Schematics for Breakout Examples

Transcription:

LEDs and Sensors Part 2: Analog to Digital In the last lesson, we used switches to create input for the Arduino, and, via the microcontroller, the inputs controlled our LEDs when playing Simon. In this lesson, we will again use input to control output, but this time we will use analog input and analog output. Analog Input The real world is not digital. Consider temperature fluctuation as an example, it generally moves within some range of values without making large abrupt changes. We can measure aspects of our world like temperature, light intensity, forces, or whatever using analog sensors. In a digital device, the resulting signals are stored as sequential digital data. Consider the analog signal depicted below. In a digital device, we discretize the input signal range (i.e., 0 to 5 Volts for the Arduino) into different voltage levels or intervals called states. The number of states is the resolution. Common resolution values range from 256 states (i.e., stored in 8 bits) to 4,294,967,296 states (i.e., stored in 32 bits); the Arduino uses 1024 states stored in 10 bits. This means that 5V/1024 or 4.8 mv is the smallest voltage change that you can measure. The translation of analog voltage values into different states is called Analog to Digital Conversion. One small part of the micro-controller on the Arduino board is dedicated to translating analog voltages into digital states; it is the Analog to Digital Converter (ADC).

On the Arduino, the analogread() command applied to an analog input pin is used to invoke the ADC process. Analog Output As you know, the digital pins on the Arduino board can output either high (5V) or low (0V) on or off. But what if we want an output voltage in between 0V and 5V--- something simulating an analog signal? Well, we can do this using a process called Pulse Width Modulation (PWM). As you know, we can t use the Arduino s digital pins to directly supply say 2.5V, but we can pulse the output on and off really fast to produce the same effect. If you were to watch the output signal on an oscilloscope, you would see the output pulsing between high and low at regular intervals. Since this on-off pulsing is happening so quickly, the connected output device sees the result as a 50% reduction in the normal voltage (in this example). We can vary the output voltage (the effective voltage ) by regulating or modulating the width of the high pulse. For example, if we make the high pulse 25% as wide (in time) as the low pulse, the effective voltage will 25% of full voltage.

On the Arduino, the analogwrite() command applied to an analog output pin is used to invoke the PWM process. In the next exercises, we will use a potentiometer and several sensors to generate analog input. We ll then use that input to control both digital and analog (i.e., PWM) output. Analog I/O Exercise 1: LED Fader In this exercise, we will use a potentiometer to generate analog input. We ve used them before; a potentiometer, or, pot for short, is just a variable resistor. Connect the middle leg of the pot (the one marked measure in the image above) to analog pin 2 of the Arduino. Connect the other 2 legs of the pot to 5V and ground as shown above. Turning the knob of the pot changes the voltage experienced at pin 2 as shown below. Now add an LED to your breadboard and connect it to pin 9 of the Arduino as shown below. Note that pin 9 is an analog output, or PWM, pin.

Now run the program PotDimmer by Tod Kurt to control the brightness of the LED using the pot. Observe how the LED light fades and intensifies depending on the position of the pot. Can you identify the line of code used to read the analog input? How about send the analog output? Why is the value read from input divided by 4 before it is used as output? Analog I/O Exercise 2: Theremin DO NOT BREAKDOWN THE CIRCUIT you created in exercise 1, but rather add a speaker to pin 7. Now run the Theremin program by Tod Kurt. Once you understand the program, modify it so that the input from the potentiometer not only controls the output of the speaker but also drives the LED. Create a seasonally spooky sound and light device. Be prepared to demonstrate your device and explain the changes you made to the class. Analog I/O Exercise 3: A Distance-Sensitive Theremin DO NOT BREAKDOWN THE CIRCUIT you created in exercise 2, instead replace the pot with the SHARP distance sensor. The SHARP distance sensor bounces Infra-Red (IR) light off objects to determine how far away they are. It returns an analog voltage

that varies with the distance of the nearest object. These sensors are good for short-range detection, i.e., under 1m of distance. The leads of the distance sensor will have to be trimmed and twirled before they can be inserted in your breadboard. Connect the black wire of the distance sensor to ground, the red wire to 5V, and the white wire to analog input pin 2. Run the program that you developed for exercise 2 again. Vary the distance of an object in front of the eyes of the distance sensor and enjoy the effects. Analog I/O Exercise 4: A Light-Sensitive Theremin This time replace the SHARP distance sensor with a photoresistor as shown in the schematic below. Use a large resistor such as a 10k Ohm (brown-black-orange) resistor for R1 in the schematic below. A photoresistor is a light-dependent resistor---brighter light means less resistance. Again, run the program that you developed for exercise 2 and enjoy the effect that varying the light on the photoresistor has on the sound and the LED. Analog I/O Exercise 5: A Force-Sensitive Theremin This time replace the photoresistor in the schematic above with a Force-Sensitive Resistor (FSR). A FSR is a sensor that allows you to detect physical pressure, squeezing and weight. It is basically a resistor that changes its resistance depending on how much it s pressed. These sensors are fairly low cost, and easy to use but they're rarely accurate. This sensor is a Interlink model 402 FSR with 1/2 diameter sensing region. Again, run the program that you developed for exercise 2 and enjoy the effect that squeezing the FSR has on the sound and the LED.