I have just lost my 3rd arduino (micro) and was hoping someone can help me stop wasting my money. I am a beginner but Im almost certain the error lies within the code. I lose the board as soon as i upload the code involving the pulse sensor. I am attempting to add a pulse sensor to my existing code which is for a 16x2 display and temp sensor..
THE 16x2 display and temp sensor code are working fine. I have provided the code here:
int sensorPin = A0;
// included the library code:
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(OLED_V2, 4, 5, 6, 7, 8, 9, 10);
void setup()
{
Serial.begin(9600);
// Print a message to the LCD.
lcd.begin(16, 2);
lcd.print("Temperature");
// lcd.setCursor(1, 1); //2nd line
// lcd.print("line 2");
}
void loop()
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(5000); //waiting a second
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(temperatureF); lcd.print(" deg. F");
}
I am attempting to add a pulse/BPM value to the display (which currently shows temp). I am attempting to modify the pulse code so that i can only show bpm on the 16x2. Below is the code that is giving me issues (and causing my micros to no longer work with my pc). [Please note: The pulse sensor code (which is giving me issues) is surrounded by stars "******"]
int sensorPin = A0;
//*****************************************************************************************************
// PULSE SENSOR CODE
int pulsePin = A1; // Pulse Sensor purple wire connected to analog pin A1
int blinkPin = 13; // pin to blink led at each beat
// these variables are volatile because they are used during the interrupt service routine!
volatile int BPM; // used to hold the pulse rate
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // holds the time between beats, must be seeded!
volatile boolean Pulse = false; // true when pulse wave is high, false when it's low
volatile boolean QS = false; // becomes true when Arduoino finds a beat.
//*****************************************************************************************************
// included in the library code:
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(OLED_V2, 4, 5, 6, 7, 8, 9, 10);
void setup() {
//*****************************************************************************************************
//PULSE CODE (to make pin led blink to heartbeat )
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
Serial.begin(115200);
interruptSetup();
//*****************************************************************************************************
// Print a message to the LCD.
lcd.begin(16, 2);
lcd.print("Jose Mendes");
// lcd.setCursor(1, 1); //2nd line
// lcd.print("line 2");
}
void loop()
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(5000); //waiting a second
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(temperatureF); lcd.print(" deg. F");
//*****************************************************************************************************
// MORE PULSE CODE FOR BPM
if (QS == true){ // Quantified Self flag is true when arduino finds a heartbeat
Serial.println(BPM); // only print BPM variable without the leading 'B'
QS = false; // reset the Quantified Self flag for next time
}
delay(20); // take a break
//*****************************************************************************************************
}
Thanks for taking time to read my post! ![]()