/*
Michael Kontopoulos
2009
Sigh Collector - Sender Code
*/
#include <NewSoftSerial.h>
NewSoftSerial mySerial = NewSoftSerial(4, 5); //instead of 1,2 (rx,tx)
//PINS
int stretcher = 1;
int threshPin = 0;
int threshLed=3;
int val = 0; // variable to store the value coming from the sensor
int pot = 0;
int sighPin = 13;
//VARIABLES
int const numVals = 40;
int breathVals[numVals];
//int diffVals[numVals/4];
int total=0, diffTotal=0, avg=0, rate=0;
int state = 0;
int threshold=0;
int normBreath;
int prevMillis=0;
boolean possibleSigh;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(sighPin, OUTPUT);
pinMode(stretcher, INPUT);
possibleSigh = false;
}
void loop() {
serialHandler();
val = analogRead(stretcher);
threshold = analogRead(threshPin);
// Serial.println(val);
checkSigh(avg);
//Array of the last 30 breath values
for(int i=1; i<numVals; i++)
{
//Shift the values down
breathVals[i-1] = breathVals[i];
//Add the most recent value to the last element
breathVals[numVals-1] = val;
//Obtaining the sliding scale average
//First add up all the values in the array
total += abs(breathVals[i-1]);
//Average them
avg = total/numVals;
}
total=0;
diffTotal=0;
//PRINT TESTS
Serial.print("Average Value: ");
Serial.print(avg);
Serial.print("tThreshold: ");
Serial.println(threshold);
if((avg >= threshold) && (avg < 400))
{
// digitalWrite(threshLed, HIGH);
possibleSigh = true;
}
else {
//digitalWrite(threshLed, LOW);
}
}
long int prevMillz = 0;
void checkSigh(int average)
{
if(possibleSigh)
{ prevMillis = millis();
//when avg drops back down, register the sigh
if(average <= 15) {
mySerial.println(8, DEC);
Serial.println("sigh detected. mobile unit");
digitalWrite(sighPin, HIGH);
delay(1000);
digitalWrite(sighPin, LOW);
possibleSigh=false;
}
}
else
possibleSigh=false;
}
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
void serialHandler()
{
if (mySerial.available()) {
Serial.print((char)mySerial.read());
}
if (Serial.available()) {
mySerial.print((char)Serial.read());
}
delay(100);
}

More Related Content

TXT
Arduino code
PDF
Rust LDN 24 7 19 Oxidising the Command Line
PDF
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
PPTX
Reverse Engineering: C++ "for" operator
PDF
Exploring the x64
PDF
One definition rule - что это такое, и как с этим жить
PDF
プログラム実行の話と
OSとメモリの挙動の話
Arduino code
Rust LDN 24 7 19 Oxidising the Command Line
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
Reverse Engineering: C++ "for" operator
Exploring the x64
One definition rule - что это такое, и как с этим жить
プログラム実行の話と
OSとメモリの挙動の話

What's hot (20)

PAGES
Unix open
ODP
Отладка в GDB
PDF
Javascript basics
PPTX
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
PDF
Hachiojipm11
KEY
20110424 action scriptを使わないflash勉強会
PPTX
PHP in 2018 - Q4 - AFUP Limoges
TXT
Ir remote kit_blink.pde
PPTX
Потоки в перле изнутри
PPT
W8_2: Inside the UoS Educational Processor
PPT
Lecture16
DOCX
PDF
Javascript: The Important Bits
TXT
Conversor
PDF
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
TXT
Programação completa e perfeira
PPTX
Embedded JavaScript
PDF
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
PPTX
Os Practical Assignment 1
PDF
Python Programming in Entertainment Industry: Coding Style
Unix open
Отладка в GDB
Javascript basics
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
Hachiojipm11
20110424 action scriptを使わないflash勉強会
PHP in 2018 - Q4 - AFUP Limoges
Ir remote kit_blink.pde
Потоки в перле изнутри
W8_2: Inside the UoS Educational Processor
Lecture16
Javascript: The Important Bits
Conversor
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
Programação completa e perfeira
Embedded JavaScript
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
Os Practical Assignment 1
Python Programming in Entertainment Industry: Coding Style
Ad

Similar to Michael kontopoulo1s (20)

DOCX
Michael kontopoulos
PDF
Mitsubachi Arduino code
DOCX
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
DOCX
7segment scetch
PDF
What will be quantization step size in numbers and in voltage for th.pdf
PDF
selected input/output - sensors and actuators
DOCX
coding and wiring dht11 and ultrasonic hcsr04 arduino
PDF
Open bot
PPTX
R tist
PDF
OpenBot-Code
DOCX
code-nodemcu.docx
PPTX
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
DOCX
Microcontroladores: programas de CCS Compiler.docx
DOCX
Lampiran 1.programdocx
DOCX
CODING IN ARDUINO
DOCX
Codigo fuente
DOCX
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
DOCX
VERILOG CODE
PDF
Mdp plus 2.1
DOCX
Arduino light tracking code with 4 stepper motors
Michael kontopoulos
Mitsubachi Arduino code
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
7segment scetch
What will be quantization step size in numbers and in voltage for th.pdf
selected input/output - sensors and actuators
coding and wiring dht11 and ultrasonic hcsr04 arduino
Open bot
R tist
OpenBot-Code
code-nodemcu.docx
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Microcontroladores: programas de CCS Compiler.docx
Lampiran 1.programdocx
CODING IN ARDUINO
Codigo fuente
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
VERILOG CODE
Mdp plus 2.1
Arduino light tracking code with 4 stepper motors
Ad

More from josnihmurni2907 (20)

DOCX
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
DOCX
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
DOCX
Twin wheeler modified for arduino simplified serial protocol to sabertooth v2
DOCX
Simple timer code for arduino
DOCX
How to write timings and delays
DOCX
Define ba1
DOCX
Define ba
DOCX
Call and message using arduino and gsm module
DOCX
DOCX
Arduino 101
PDF
140813560 nota-kimia-tingkatan-4
DOC
1.funtions (1)
PDF
132944997 rancangan-tahunan-mm-t5-2013
DOCX
Agihan kertas 1 dan kertas 2
DOCX
Ciri pemimpin
DOCX
Cara menghilangkan rasa ngantuk di kelas
DOCX
Bercakap mengenai nikmat allah s
DOCX
Bandar purba dalam tasik di china
DOCX
12 kaum yang telah allah swt binasakan
PPTX
Smkts 2015 p1
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v2
Simple timer code for arduino
How to write timings and delays
Define ba1
Define ba
Call and message using arduino and gsm module
Arduino 101
140813560 nota-kimia-tingkatan-4
1.funtions (1)
132944997 rancangan-tahunan-mm-t5-2013
Agihan kertas 1 dan kertas 2
Ciri pemimpin
Cara menghilangkan rasa ngantuk di kelas
Bercakap mengenai nikmat allah s
Bandar purba dalam tasik di china
12 kaum yang telah allah swt binasakan
Smkts 2015 p1

Recently uploaded (20)

PDF
PUBH1000 - Module 6: Global Health Tute Slides
PPTX
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
PPTX
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
PPTX
PLASMA AND ITS CONSTITUENTS 123.pptx
PDF
Nurlina - Urban Planner Portfolio (english ver)
PDF
Everyday Spelling and Grammar by Kathi Wyldeck
PPTX
Case Study on mbsa education to learn ok
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
FYJC - Chemistry textbook - standard 11.
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
PDF
The TKT Course. Modules 1, 2, 3.for self study
PPTX
Macbeth play - analysis .pptx english lit
PDF
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
PPTX
Climate Change and Its Global Impact.pptx
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
Physical education and sports and CWSN notes
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PPTX
Cite It Right: A Compact Illustration of APA 7th Edition.pptx
PDF
Journal of Dental Science - UDMY (2022).pdf
PUBH1000 - Module 6: Global Health Tute Slides
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
PLASMA AND ITS CONSTITUENTS 123.pptx
Nurlina - Urban Planner Portfolio (english ver)
Everyday Spelling and Grammar by Kathi Wyldeck
Case Study on mbsa education to learn ok
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
FYJC - Chemistry textbook - standard 11.
ACFE CERTIFICATION TRAINING ON LAW.pptx
The TKT Course. Modules 1, 2, 3.for self study
Macbeth play - analysis .pptx english lit
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
Climate Change and Its Global Impact.pptx
faiz-khans about Radiotherapy Physics-02.pdf
Physical education and sports and CWSN notes
Journal of Dental Science - UDMY (2021).pdf
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
Cite It Right: A Compact Illustration of APA 7th Edition.pptx
Journal of Dental Science - UDMY (2022).pdf

Michael kontopoulo1s

  • 1. /* Michael Kontopoulos 2009 Sigh Collector - Sender Code */ #include <NewSoftSerial.h> NewSoftSerial mySerial = NewSoftSerial(4, 5); //instead of 1,2 (rx,tx) //PINS int stretcher = 1; int threshPin = 0; int threshLed=3; int val = 0; // variable to store the value coming from the sensor int pot = 0; int sighPin = 13; //VARIABLES int const numVals = 40; int breathVals[numVals]; //int diffVals[numVals/4]; int total=0, diffTotal=0, avg=0, rate=0; int state = 0; int threshold=0; int normBreath; int prevMillis=0; boolean possibleSigh; void setup() { Serial.begin(9600); mySerial.begin(9600); pinMode(sighPin, OUTPUT); pinMode(stretcher, INPUT); possibleSigh = false; } void loop() { serialHandler(); val = analogRead(stretcher); threshold = analogRead(threshPin); // Serial.println(val); checkSigh(avg); //Array of the last 30 breath values for(int i=1; i<numVals; i++) { //Shift the values down breathVals[i-1] = breathVals[i]; //Add the most recent value to the last element breathVals[numVals-1] = val; //Obtaining the sliding scale average //First add up all the values in the array total += abs(breathVals[i-1]); //Average them avg = total/numVals;
  • 2. } total=0; diffTotal=0; //PRINT TESTS Serial.print("Average Value: "); Serial.print(avg); Serial.print("tThreshold: "); Serial.println(threshold); if((avg >= threshold) && (avg < 400)) { // digitalWrite(threshLed, HIGH); possibleSigh = true; } else { //digitalWrite(threshLed, LOW); } } long int prevMillz = 0; void checkSigh(int average) { if(possibleSigh) { prevMillis = millis(); //when avg drops back down, register the sigh if(average <= 15) { mySerial.println(8, DEC); Serial.println("sigh detected. mobile unit"); digitalWrite(sighPin, HIGH); delay(1000); digitalWrite(sighPin, LOW); possibleSigh=false; } } else possibleSigh=false; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// void serialHandler() { if (mySerial.available()) { Serial.print((char)mySerial.read()); } if (Serial.available()) { mySerial.print((char)Serial.read()); } delay(100); }