Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
EMS1EP Lecture 9 Analog to Digital Conversion (ADC) Dr. Robert Ross.
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Lab7: Introduction to Arduino
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Embedded Sumo 1T4 – 1T5 UTRA.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
ELCT 201 week 13 Analog ON/OFF control system conversion to Digital ON/OFF control system.
Intro to Programming and Microcontrollers. Activity Group into pairs and sit back-to-back. Pick one person who is going to draw. The other person will.
IR Object Detection living with the lab IR light from LED IR light reflected off object IR LED IR receiver Infrared (IR) light leaving an LED reflects.
Finish your programs from last week STOPLIGHT CIRCUIT! You may need … – int – void setup() – void loop() – pinMode – digitalWrite – delay.
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.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2011 LWTL faculty team.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Image of Arduino. Arduino discussion Address issues with circuit walk-through – Electricity, Programming, Arduino Concepts Work on BeatTable (next week)
chipKit Sense Switch & Control LED
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED.
Introduction to the Arduino
Cascade switching of an LED EAS 199B Winter 2013.
Pulse Width Modulation (PWM). 100% Pulse Width Modulation (PWM) 0% On the chipKIT there are 490 periods per second. Use analogWrite(pin, value) to control.
Good LED Circuit 5V0 GND. What Voltage Does Meter See? Answer: 5 V.
LECTURE 2 – INPUTS THIS LECTURE WILL INTRODUCE HOW TO INPUT SIGNALS INTO AN ARDUINO.
Introduction 2 Smart Design. What is smart design? 2 Everything is designed except nature The packaging of a Band-Aid The curve of a bike frame The shape.
Arduino Circuits and Code. int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, LOW); delay(1000); digitalWrite(ledPin,
Servo Demonstration In MPIDE, select File > Examples > Servo > Sweep.
Arduino libraries Datatekniker Udvidet hardware/software.
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.
Microcontroller basics Embedded systems for mortals.
Week 5: Microcontrollers & Flow Control Bryan Burlingame 2 March 2016.
Microcontroller basics Embedded systems for mortals.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
INTERNET OF EVERYTHING SDU 2016 Week 12. Remotely Controlling Devices  interact with almost any device that uses some form of remote control  TVs, audio.
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
:Blink Blink: Er. Sahil Khanna
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.
Hacking on Arduino George Patterson
physical computing .2 – Day 3
Assist. Prof. Rassim Suliyev - SDU 2017
Microcontroller basics
Microcontroller basics
Microprocessors Tutorial 1: Arduino Basics
Microcontroller basics
Cascade switching of an LED
Get Your Project Started with Arduino
European Robotic LABoratory
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Arduino.
Въведение в Arduino.
Analog Input through POT
Introduction to Arduinos
IoT Programming the Particle Photon.
Chapter 2 Push button and Potentiometer
CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno
analog and digital measurements
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Setting up a basic program with Arduino
SAURABH GINGADE.
Arduino程式範例.
Presentation transcript:

Digital & Analog Inputs

Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital signal (0/1) to a pin using digitalWrite. Can read a digital signal (0/1) from a pin using digitalRead. – Must have a variable to store the value

IF, IF-ELSE, and IF-ELSE-IF if (someCondition) { // do stuff if the condition is true } if (someCondition) { // do stuff if the condition is true } else { // do stuff if the condition is false } if (someCondition) { // do stuff if the condition is true } else if (anotherCondition) { // do stuff only if the first condition is false // and the second condition is true }

Your turn Challenges: Complete in order 1.Push the button and have it display an LED pattern Fireworks! 2.Push the button and have it turn on alternate LEDs Button HIGH – Yellow Button LOW – Red 3. Push the button twice to turn on LED Need a COUNTER -- if you get to this stage, ask one of us for help

ANALOG INPUTS

Analog Signals What is an analog signal and how does it differ from a digital signal?

Analog Signals & Arduinos The Arduino can read an analog signal on one of the analog input pins. – analogRead The signal that can be read must be between 0 and 5 V. The Arduino converts the signal to a number between 0 and How many values are there for a digital signal? How many values are there for an analog signal on the Arduino?

Analog Input Program Time! We’re going to write a program that will turn on the Arduino’s LED when “threshold” value is reached. How: Potentiometer Use a Voltage Divider to change the voltage on the analog input pin. Use the Arduino to detect when the voltage has reached a certain level. Turn on the LED!

Analog Signal Detector Step 1 – Declare Variables: int inputPin = 0; // select the input pin for the potentiometer // ( can be 0 through 5). int ledPin = 13; // select the pin for the Arduino’s LED int inputValue = 0;// variable to store the value coming from // the voltage divider. Step 2 – Setup: void setup() { pinMode(ledPin, OUTPUT); //Declare the LED pin as an //output. } We do NOT have to declare the analog pin as an input. Why?

Analog Signal Detector Step 3 – The Loop: void loop() { inputValue = analogRead(inputPin); // Read the analog //input, what are // the possible values. if(inputValue > 511)// Check our threshold. { digitalWrite(ledPin, HIGH);// Turn on the LED. } else { digitalWrite(ledPin, LOW);// Turn off the LED. } }

Your turn Challenges: Complete in order 1.Design a program to make the LED flash at a speed dependent on the value on the analog input pin. 2.Turn on a number of LEDs that is proportional to the analog input value.