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.

Slides:



Advertisements
Similar presentations
Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
Advertisements

EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Lab7: Introduction to Arduino
Intermediate Electronics and Lilypad Where Electronics Meet Textiles Workshop with Lynne Bruning and Troy Robert Nachtigall Sponsored by Spark Fun and.
Servo Background Servos provide control of rotary position Servos are used extensively in the remote control hobby world for: Aircraft (flaps, ailerons,
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Embedded Sumo 1T4 – 1T5 UTRA.
temperature system wiring
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
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.
Embedded Programming and Robotics Lesson 8 Light Sensors and Temperature/Humidity Light Sensors1.
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.
Working with Arduino: Lesson #2: Variable, Photo, and Force Sensitive Resistors EGN1007.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2011 LWTL faculty team.
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.
Operational Amplifiers
Week 10 Today 1.Homework presentations and critique. 2.Review digital and analog inputs. 3.DIY - jumpers, soldering etc.
chipKit Sense Switch & Control LED
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
Microprocessors Tutorial 1: Arduino Basics
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.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium.
FIRST GADGETEER PROJECT. Where are you? Making a VS project Parts of a C# program Basics of C# syntax Debugging in VS Questions? 2.
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.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Beath High School - Int 1 Physics1 Intermediate 1 Physics Electronics Glossary AND gate to device digital signals to inverter LDR to logic circuit logic.
Microprocessors Tutorial 1: Arduino Basics
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Servo Demonstration In MPIDE, select File > Examples > Servo > Sweep.
Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.
Microcontrollers, Microcomputers, and Microprocessors
18240 Element two - Components INPUTS OUTPUTS PURPOSE TYPICAL USE.
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.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
:Blink Blink: Er. Sahil Khanna
Starter: use Pg to complete the table
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Assist. Prof. Rassim Suliyev - SDU 2017
Microcontroller basics
More on LED’s with Arduino
Val Manes Department of Math & Computer Science
Microcontroller basics
Microprocessors Tutorial 1: Arduino Basics
Microcontroller basics
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Arduino.
Arduino - Introduction
Control the color and brightness of an RGB LED with a Potentiometer
Analog Input through POT
IoT Programming the Particle Photon.
Chapter 2 Push button and Potentiometer
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Chapter 1 Introduction of Arduino
Introduction to Wiring Logic Gates
Arduino : Introduction & Programming
Sensors and actuators Sensors Resistive sensors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Arduino Uno circuit basics
Introduction to Arduinos
Arduino程式範例.
Presentation transcript:

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 pin – How to read the value of an analog pin – IF statements Today we’ll put these skills together to build a medical device - a breathing monitor.

New Component Thermistor Variable resistor Resistance depends on temperature

Set Up Your Device Remember: The middle leg of the potentiometer goes to analog in; one outer pin goes to ground and the other to power. Hook up thermistor and potentiometer: Hook up LED: to digital output pin to ground

What will the program do? Turn an LED ON when we breathe out Turn the LED OFF when we breathe in.

Your Turn Initialize variables: – Define digital pin for the LED – Define analog pin from the potentiometer – Define variable you will store analog value! Set up: – pinMode(digitalPin, OUTPUT); Loop: – Use analogRead – Use a conditional IF-Statement HINT: This is VERY similar to the analogRead program you wrote last time!

Add an Alarm Now we want a SECOND LED to turn on if there is no breathing for 10 s. – We need to add another variable for a 2 nd LED – We need a way to measure the time that has passed in the program. Function: millis(); – Returns the time since the program began in milliseconds – NOT an integer! New data type..

Unsigned long millis() returns a number of type “unsigned long” When you initialize the variable that will store the value from millis(), it will look like: – unsigned long start_time = 0; Now the variable start_time can be added/subtracted/multiplied to other variables ONLY if they are also unsigned long

Example Program: unsigned long time = 0; // variable to store the time. Note // the different data type unsigned long alarm_time = 10000; // value in ms. Amount of time // that needs to pass before // the alarm will go void setup() { time = millis(); // initialize time } void loop(){ if ((millis() – time) > alarm_time) { //do something! } KEY POINT: ((millis() – time) > alarm_time) What does this statement say in English? * All of the values are of type unsigned long KEY POINT: ((millis() – time) > alarm_time) What does this statement say in English? * All of the values are of type unsigned long

TRANSLATE to build your final projects! There are 6 variables: an analog pin, a variable to store the analog value, a pin to make the monitor LED turn on/off, a pin to make the alarm LED turn on/off, a variable to store the time, and a variable to store the amount of time to wait until the alarm goes off! In the setup function, you’ll need to declare that the two LED pins are outputs. You’ll also need to store the initial time. In the loop, first you need to read the value from the sensor and store it in one of your variables. Next, check to see if 10 s have passed. If they have, turn on the alarm LED. If they have not, turn off the alarm LED. Then, check to see if the breathing sensor is above the threshold. If it is, turn on the monitor LED. ** At this point you’ll also have to reset the time. This way, you’ll always be measuring the time since the last time the a breath occurred **. Lastly, if the breathing sensor is below the threshold, turn the monitor LED off.

Finally … Breathing Monitors!