Hi all,
So i’ve got a project thats working on a Mega but not an Uno. Its a heartbeat sensor that countsdown then displays the number on an Adafruit 7 segment display with backpack. i’ve got the sensor going into A0 then the SDA and SCL coming out of the dedicated lines on the Uno. Whereas on the Mega i had pins 20 and 21 doing the SDA and SCL, the sensor was also in A0. Code is attached, is there something i’m doing wrong with the step down to the Uno?
/*
Heartrate Monitor Countdown Clock Timer
*/
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_7segment matrix = Adafruit_7segment();
// Variables
int PulseSensor = A0;
int beatCounter = 5025; //Start number of count
int LED13 = 13; //On-board LED
int Signal; // holds the incoming raw data. Signal value can range from 0-1024
int Threshold = 600; // Determine which Signal to "count as a beat"
void setup() {
matrix.print(10000, DEC); //used to dispay ---- on LED
matrix.writeDisplay();
delay(2000);
pinMode(LED13,OUTPUT); // pin that will blink to your heartbeat
Serial.begin(9600); // Set's up Serial Communication at certain speed.
matrix.begin(0x70);
}
void loop() {
Signal = analogRead(PulseSensor); // Read the PulseSensor's value. Then assign value to "Signal" variable
if(Signal > Threshold) {
beatCounter--; //beatcounter counts down
Serial.print("Number Of Heartbeats: ");
Serial.println(beatCounter);
matrix.print(beatCounter); //LED Segment print
matrix.writeDisplay(); //LED Segment Display
delay(200);
}
if(Signal > Threshold){ // If the signal is above "600", then "turn-on" Arduino's on-Board LED.
digitalWrite(LED13,HIGH);
} else {
digitalWrite(LED13,LOW); // Else, the signal must be below "600", so "turn-off" this LED.
}
delay(100);
}