NEW here! ART that needs HELP

Hi there,

I was wondering if someone can help me to join a Pulse sensor to a led fade program.

I have dyslexia so when I gave up proper programming ages ago but I have to finish a personal project that started as an art installation 14 years ago as I can move on until I have done this. Its my personal goal, and I have promised myself to finish it this year.

I basically have work out 4 positions of the delay for the LED that I want to map to the data of the sensor of the pulse.

I have make the lamp with the working pulse sensor and now need to join it together.

The idea is that when the sensor finds the pulse is under 60 BPM has to go to delay 20 of the LED

and so on with the 4 positions.

Can someone help me to join this two bits of program in arduino?

For the Pulse Sensor I´m using this code that I download from the sensor supplier:

#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.

// Variables
const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; // Determine which Signal to “count as a beat” and which to ignore.
// Use the “Gettting Started Project” to fine-tune Threshold Value beyond default setting.
// Otherwise leave the default “550” value.
int brightness = 1;
int fadeAmount = 2;

PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called “pulseSensor”

void setup() {

Serial.begin(9600); // For Serial Monitor

// Configure the PulseSensor object, by assigning our variables to it.
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino’s LED with heartbeat.
pulseSensor.setThreshold(Threshold);

// Double-check the “pulseSensor” object was created and “began” seeing a signal.
if (pulseSensor.begin()) {
Serial.println(“We created a pulseSensor Object !”); //This prints one time at Arduino power-up, or on Arduino reset.
}
}

void loop() {

analogWrite(LED13, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
// for the LED to fade out

int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an “int”.
// “myBPM” hold this BPM value now.

if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if “a beat happened”.
Serial.println("your heart beat is… "); // If test is “true”, print a message “a heartbeat happened”.
Serial.print("BPM: "); // Print phrase "BPM: "
Serial.println(myBPM); // Print the value inside of myBPM.
}

delay(20); // considered best practice in a simple sketch.

}

and the Fade LED is the basic cone in arduino examples.

If someone can help me please, I will send you one lamp when fisished in translucent porcelain

Thanks.

Abalon

What are the delays values and the associated BPM ranges?
You can do this by using a set of if tests, but if the delays are linearly related to the BPM ranges then the map function may do the trick.