Working with Arduino: Lesson #2: Variable, Photo, and Force Sensitive Resistors EGN1007.

Slides:



Advertisements
Similar presentations
Sensing and Control.
Advertisements

Intermediate Electronics and Lilypad Where Electronics Meet Textiles Workshop with Lynne Bruning and Troy Robert Nachtigall Sponsored by Spark Fun and.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.
Pulse Detector Ramiro Duarte, Clayton Greenbaum Prof. Betty Lise Anderson.
Potentiometer Electric circuit Cell or Battery Resistor Switch Bulb Earth/Ground LED.
Lesson 4: Breathing Monitors. Breathing Monitors In the past 3 classes, we’ve learned – How to write to a digital pin – How to read the value of a digital.
New Human Computer Interfaces Amnon Dekel HUJI – CSE, Spring 2007 Class 3 March
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Introduction.
Embedded Programming and Robotics Lesson 1 Basic Electricity and Electronics Transistor Basics Lesson 1 -- Basic Electricity1.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Embedded Programming and Robotics
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Basic Circuits – Lab 2 Arduino and Sensors
Image of Arduino. Arduino discussion Address issues with circuit walk-through – Electricity, Programming, Arduino Concepts Work on BeatTable (next week)
Write a program that will automatically control the brightness of a light based on the surrounding light level. Automatic Night Light.
Working with Arduino: Lesson #3: Force Sensitive Resistors EGN1007.
Week 10 Today 1.Homework presentations and critique. 2.Review digital and analog inputs. 3.DIY - jumpers, soldering etc.
Electricity Unit 1 Physics.
Module 4: Analog programming blocks. Module Objectives Analyze a control task that uses analog inputs. Connect a potentiometer to LOGO! controller and.
ENGR 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program Solar Energy Meter.
Project: Pulse meter Idea: Use noninvasive infrared light to probe blood pressure and pulse rate in a finger tip. Uses: A variant of this device is used.
Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED.
Working with Arduino: Lesson #4: Servos EGN1007. Learning Goals Learning Goals: The student will be able to: 1.Build a complete circuit using the Arduino.
Potentiometer Foundations of Technology Potentiometer © 2013 International Technology and Engineering Educators Association, STEM  Center for Teaching.
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi. Objectives 1. Control the rotation of standard servo motor  A standard servo motor is limited in its rotation.
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
PHY 235 Robotics Workshop Day 4 Robotic Behaviors, Light Sensing, Voltage Dividers, LCD-MOD.
How a Photocell Works.
Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.
Detection Circuit ENGR Pre Lab.
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Voltage Divider Circuits Input transducers Input transducers are devices that convert a change in physical conditions (for example, temperature) into a.
Show-me board revision quiz 1.Draw the symbol for an LED 2.What happens to the resistance of a thermistor as it is heated up? 3.What happens to the resistance.
Electronics for Physical Computing Materials: capacitor, diode, LED, transistor, switch,resistor, relay, proto board, multimeter.
Bdps 2 Lecture 2. Circuits and Ohm's Law For resistive circuits.
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
IAT 267 Introduction to Technological Systems 1 Week 2 Workshop Basics of Electronic Circuits.
Prototyping with Microcontrollers and Sensors. Overview Objective Background Information Problem Statement Materials Procedure Assignment Closing.
Microcontrollers & Electronics Basics OR…
Control Devices/Electrical Conditioners
Arduino Setup & Flexing the ExBow
Assist. Prof. Rassim Suliyev - SDU 2017
Purpose of This Minilab
Prototyping with Microcontrollers and Sensors
Microcontroller basics
Microprocessors Tutorial 1: Arduino Basics
Introduction to Handshaking Communication with SSC-32U
UCD ElecSoc Robotics Club 2017/2018
Arduino - Introduction
Potential Divider Aims What is a potential divider
Arduino Uno and sensors
Introduction to Handshaking Communication with SSC-32
Analog Input through POT
More Resistors Activity 6.2.3a
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Resistance AIM: Understand resistance, calculate resistor values and know the characteristics of different types of resistors PRIOR KNOWLEDGE: Understand.
Comparator Circuits AIM:
Basic circuits Electrical circuits Electrical properties Ohm’s law
Arduino Part 4 Let there be more light.
Sensors and actuators Sensors Resistive sensors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
UNIT 5 Analog signals.
Intro to Arduino Part 2 The Breadboard
Introduction to arduino
Transistors Magic of Electrons © 2011 Project Lead The Way, Inc.
Presentation transcript:

Working with Arduino: Lesson #2: Variable, Photo, and Force Sensitive Resistors EGN1007

Learning Goals Learning Goals: The student will be able to: 1.Build a complete circuit using the Arduino microprocessor 2.Identify important electrical components in a circuit and explain their use 3.Identify and apply specific elements in “C” code used to run a program in conjunction with how a circuit is built

Variable resistors Along with the digital pins on the Arduino, the board also has 6 analog pins which can be used. These inputs take a voltage between 0 and 5 volts and convert it to a digital number 0 to A device which uses these inputs is called a POTENTIOMETER or variable resistor. When a voltage is applied to the outer pins, the middle pin will read some value between 0-5 volts depending on the angle of the position. The schematic symbol is that of a regular resistor with an arrow either through it or perpendicular to it.

Let’s Begin 1.Place the potentiometer on D5-D7. 2.Run a red wire from the 5V on the Arduino to E5. This will supply the Pot with 5V. 3.Run a wire from Analog 0 to E6. 4.Place the LED on J5 and J6 with the longer lead(+) of the LED in J5. 5.Place a resistor on I6and I16. Notice that both the resistor and LED share row 5 6.Run a red wire from Digital 13 port on Arduino to I5. 7.Run a black wire from H16 to the ground(GND). 8.Run a black wire from E7 to G16.

Programming our sketch Let’s define 3 variables as integers. These will tell us which ports our LED and POT are in This is a variable that we will use which can store a value coming from the POT.

Programming our sketch Just like before we need to set our LED as an output.

Programming our sketch The sensorValue is determined by the actual READING on the POT The only difference this time is that the delay is caused by the READING on the POT which is referenced by the sensor’s value.

Your turn! Using what you have learned in this lesson AND the last lesson. Write a short program that uses the POT to control the brightness of the LED. HINT: Do not allow it to blink! Write your code on the lesson worksheet and explain your code.

PhotoResistors This type of resistor produces a variable resistance based on the amount of incident light. The schematic symbol shows light in the form of arrows coming down and striking the resistor symbol. To be used correctly is MUST be in a VOLTAGE DIVIDER.

Voltage Divider A voltage divider is a simple circuit consisting of two resistors that has the useful property of changing a higher voltage (Vin) into a lower one (Vout). It does this by dividing the input voltage by a ratio determined by the values of two resistors (R1 and R2): So lets say that R1 is the photocell and R2 was a regular resistor. Ss the resistance of the photocell changes as a function of light intensity, the current flowing would increase and decrease. This will cause a voltage that CHANGES and changes in voltage is what Arduino can sense and understand.

Let’s Begin 1.Place the photoresistor on J20 & Run a red wire from the 5V on the Arduino to J20. This will supply the PR with 5V. 3.Place the 10K resistor (brown- black-orange) on I21 and I30. 4.Run a wire from Analog 0 to H21 5.Place the LED on J5 and J6 with the longer lead(+) of the LED in J5. 6.Place a 560  resistor on I6 and I16. Notice that both the.resistor and LED share row 5 7.Run a red wire from Digital port 9 on Arduino to I5. 8.Run a black wire from J16 to the ground(GND). 9.Run a black wire from H30 to H16.

Programming the sketch These will tell us which ports our LED and PR are in.

Programming our sketch Just like before we need to set our LED as an output.

Programming the sketch - map map(value, fromLow, fromHigh, toLow, toHigh) Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc. Why do we have to do this? The LED understands the range 0 to 255 and the photoresistor will export values between 0 and 900

Programming the sketch - constrain constrain(x, a, b) Constrains a number to be within a range. Example sensVal = constrain(sensVal, 10, 150); // limits range of sensor values to between 10 and 150

Why are we doing this? (I told I was going to explain this later) Remember that the Arduino is a digital machine. It can only deal with analog via special tricks. analogWrite (pin, value) - turns the pin ON and OFF very quickly which makes it act like an analog signal. This value is between 0 (0 volts) and 255(5 volts)

Why are we doing this? (I told I was going to explain this later) Remember that the Arduino is a digital machine. It can only deal with analog via special tricks. analogREAD (pin, value) - This allows you to read the their voltage which outputs a value between 0 (0 volts) and 1024 (5 volts)

The bottom line When you READ a range from you must MAP and CONSTRAIN that range if you want to WRITE (0-255)it to a different device. Therefore we READ the value from the PR. We then map and constrain it so that we can WRITE that value to the LED. The written value is then outputted as brightness in the LED.

Programming our sketch We first create a variable to READ the value of the PR We then RE-MAP the ranges that the PR can produce to those same values we used to control the brightness of the LED. We also constrain these values to this range. Lastly, we send the value (voltage) to the LED based on the LIGHTLEVEL of the PR. Place your hand or finger on the PR to dim the LED.

Challenge – Night Light Instead of lowering the LED brightness when the light level on the PR is LOW, can you figure out a way to turn the LED ON when the value across the PR is LOW and OFF? Hint: Use an “IF-ELSE” statement and other ideas from lesson 1 like math functions (+,-,*,/, ). Write out what you WANT to do in WORDS first (psuedo-code) as this may help you determine how this is to be done. YOU CAN DO THIS! And, YES……turn off the lights to test.