simple code for heart rate monitor
Here's my code:
#include <Time.h>
int sensorPin = A0; // select the input pin for the
potentiometer
float sensorValue = 0; // variable to store the value coming from
the sensor
int count=9;
int starttime = 0;
int heartrate = 0;
boolean counted = false;
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
starttime = millis();
while (millis()<starttime+10000) // so i'm reading the pulse for
10 seconds
{
sensorValue = analogRead(sensorPin);
if (sensorValue >550 && counted == false) // counting
the pulse, and making sure I dont count
{ // each peak more than once
count++;
counted = true;
}
else if (sensorValue < 500)
{
counted = false;
}
}
heartrate = count*6; // multiplying by six to get pulse per
minute
Serial.println(heartrate); // printing to serial screen
heartrate=0;
count =0;
}
This doesnt output anything to the serial screen and I can't figure
out why.
Arduino Programming for Accelerometer
Abstract : This application notes describes the Arduino programming process for accelerometer.
The procedure describes the coding and connection process to show how to make the
accelerometer sense vibration and tilt shifting.
Key Words: vibration, accelerometer, Arduino, monitoring, imbalance, pins
Introduction: The Arduino UNO Rev 3 is a microcontroller based on the ATmega32P with 14
digital input and output pins. Out of these 14 pins, 6 are capable of PWM outputs, 6 analog
inputs, a USB connection, a power jack, an ICSP header, 16 MHz quartz crystal, and a reset
button. The convenient part of Arduino is that it is already pre built with every microcontroller
support hence simply plugging in with an USB cable will suffice. Also an advantage of using the
UNO is that the chip used in it can be replaced for relatively cheap cost. UNO board is the very
first of the Arduino boards and even though there are more advanced boards available, for this
project, the UNO board will be enough. The figure 1 on the next page shows the technical
specifications of this Arduino board.
The accelerometer used in this project would be ADXL335 small, thin, low power, 3axis
accelerometer that contains signal conditioned voltage outputs. It is designed to measure the
acceleration with a full scale range of ±3 g. It measures two kinds of motion. First kind of motion
that it measures is the static acceleration of gravity when the accelerometer is tilted. So during
the diamond polishing phase if the arm tilts it will send a signal. The second kind of acceleration
it measures is the dynamic acceleration which will help to detect the change is vibration that
may occur when the diamond polishing machine is at work.
ADXL335 is powered by a 3.3v power source that causes it to generate 3.3v peak outputs. It
has three analog outputs for X, Y, and Z axis which require an ADC microcontroller that is
provided by the analog functions of Arduino board.
Technical Specifications for Arduino Board
Technical Specifications of Arduino shows that the board is relatively light and small
weighing only 25g with length of 68.6 mm and width of 53.4 mm. It gives the Flash memory and
clock speed are respectively 32 KB and 16 MHz which indicates it is enough for small
accelerometer programming.
Process: The process will describe how to connect the Arduino and the accelerometer and then
download the arduino software to program and run the codes. Figure 2 and 3 will be referenced
in order to describe the connection.
Arduino UNO Rev 3 pins and ports
shows the Arduino UNO Rev 3 ports and pins and where the accelerometer will be
connected.
ADXL335 Accelerometer
shows the X, Y, Z and GND pins for the accelerometer and it will be used to reference
the power pin connection.
The parts required for this process are the Arduino board, ADXL335 accelerometer, connecting
wires, and USB cable to connect Arduino board to computer.
Process for Circuit building:
Accelerometer has 5 pins and all of these are connected to Arduino. First connect the GND to
Arduino’s GND. Then connect the VCC to Arduino’s 5V, X to Arduino's Analog Pin A5, Y to
Arduino’s Analog Pin A4, and Z to Arduino’s Analog Pin A3. Finally the AREF is connected to
3.3v on Arduino to set the reference voltage of ADXL355 to 3.3v.
The final product should look something like the following figure 4.
Final connection of Arduino to Accelerometer
Process of coding the Accelerometer:
Before beginning the coding, the Arduino 1.6.6 software needs to be downloaded for compatible
operating system. Opening it up would show something like the following figure.
Window for Arduino Software
shows the Arduino window it provides a space for writing codes. It has a → button that
is used to upload the codes to machine. The black bar under the window shows the error
messages.
Next the following code is put in the Arduino software.
const int ap1 = A5;
const int ap2 = A4;
const int ap3 = A3;
int sv1 = 0;
int ov1 = 0;
int sv2 = 0;
int ov2= 0;
int sv3 = 0;
int ov3= 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
analogReference(EXTERNAL); //connect 3.3v to AREF
// read the analog in value:
sv1 = analogRead(ap1);
// map it to the range of the analog out:
ov1 = map(sv1, 0, 1023, 0, 255);
// change the analog out value:
delay(2);
//
sv2 = analogRead(ap2);
ov2 = map(sv2, 0, 1023, 0, 255);
//
delay(2);
//
sv3 = analogRead(ap3);
ov3 = map(sv3, 0, 1023, 0, 255);
// print the results to the serial monitor:
Serial.print("Xsensor1 = " );
Serial.print(sv1);
Serial.print("\t output1 = ");
Serial.println(ov1);
Serial.print("Ysensor2 = " );
Serial.print(sv2);
Serial.print("\t output2 = ");
Serial.println(ov2);
Serial.print("Zsensor3 = " );
Serial.print(sv3);
Serial.print("\t output3 = ");
Serial.println(ov3);
delay(3000);
}
Next use the search glass icon to do serial monitoring.
Results : After the serial monitoring is pressured the result should give something like the
following in figure 6.
Results of Accelerometer Vibration
shows that there are two different analog values that are output. The first one is the
ADC value in 10 bit resolution ranging from 0 to 1023 and the second is the mapped PWM
value that is in 8 bit resolution ranging from 0 to 255. Then three values of X, Y. and Z are
displayed at the same time and repeated after a specified interval in the code. The outputs are
varied because during this measuring process, vibration was produced. It is not constant which
shows that the accelerometer is detecting the vibration.
Conclusion: All in all the Arduino board is a quite inexpensive and reliable way to program the
accelerometer to show imbalances in the diamond polishing arm. The hardware parts are
relatively easy to build. Figure 6 shows that the accelerometer is sensitive enough to
differentiate between output of 195, 190, and 189 which means the user can set up an external
alarm so it can go off when an undesired vibration is produced.
i need an arduino code that combines heart rate sensor, pressure sensor and accelerometer in order...
I need help with creating a arduino code using a GSR sensor that measures when a person is sweating or not.
I need help with creating a arduino code using a GSR sensor that measures when a person is sweating or not.
Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond...
Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond 10 yards....
hello guys, please help me solve this question, please guys I need your help. this is one questions with 2 parts as shown, thank you part1 You are planning on installing a new above-ground swimming pool in your backyard. The pool will be rectangular with dimensions 29.0 m x 10.0 m. It will be filled with fresh water to a depth of 2.20 m. In order to provide the appropriate structural support, you wish to determine the following. (a) Determine...
I need Questions 12, 13, 14, 15 American Heart Association. life is why 11. You are the quality CPR geam leader during a pediatric resuscitation attempt. Which action is an element of high- a compression depth of one fourth the depth of the chest a compression rate of 80 to 100/min с. chest wall recoil after each compression s every minute Use this scenario to answer the next 3 questions aleeping much more. His heart rate is 190/min, temperature is...
Hi I am working on the group work I need help with and a little explanation with it that will help a lot. Tools View GW1 Ch 16 (Protected View)-Word (P OTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected V Group Work: Ch. 16 1. A pressure of 10 mm Hg is measured using a constant-volume gas thermometer at a temperature of 50°C. What is the pressure...
I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...
I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks. Documentation: Explain the purpose of the program as detail as possible - 8%. Develop a solution for the problem and mention algorithms to be used -12% List data structures to be used in solution. - 5%. Give a description of how to use the program and expected input/output - 5% Explain the purpose of each class you develop in the program. - 5%. Programming:...