Question [Heating Pad]

I am trying to get my heating pad from adafruit to work properly. I want it to turn on when the heart rate sensor reads the highest number and turn off when its low. I want it to happen automatically, without a switch.

Here is my current code. I currently am using a NeoPixels to light up blue, purple, and red depending on the level of heart rate.

I have the pad plugged in and can make it turn on, my problem is that is just connects to ground and power, so how to I set it to turn on and off without a set pin?

Thank you!

#include <Adafruit_NeoPixel.h>

// Variables
int PulseSensor = 0; // Pulse Sensor WIRE connected to ANALOG PIN 0
int LED13 = 13; // The on-board Arduion LED

int Signal; // holds the incoming raw data. Signal value can range from 0-1024
int Threshold = 517; // Determine which Signal to “count as a beat”, and which to ingore.

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6 // data pin is 6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 60 // Popular NeoPixel ring size

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// The SetUp Function:
void setup() {
pinMode(LED13,OUTPUT); // pin that will blink to your heartbeat!
Serial.begin(9600); // Set’s up Serial Communication at certain speed.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
pixels.show(); // Turn OFF all pixels ASAP
pixels.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

}

// The Main Loop Function
void loop() {

Signal = analogRead(PulseSensor); // Read the PulseSensor’s value.
// Assign this value to the “Signal” variable.

Serial.println(Signal); // Send the Signal value to Serial Plotter.

if(Signal > Threshold){ // If the signal is above “550”, then “turn-on” Arduino’s on-Board LED.
digitalWrite(LED13,HIGH);
} else {
digitalWrite(LED13,LOW); // Else, the sigal must be below “550”, so “turn-off” this LED.
}

Signal = map(Signal,500,545, 0, 255);
colorWipe(pixels.Color(Signal, 0, 255 -Signal), 50);

delay(10);

}

void colorWipe(uint32_t color, int wait) {
for(int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip…
pixels.setPixelColor(i, color); // Set pixel’s color (in RAM)
pixels.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}

Read the forum guidelines. to see how to properly post code.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Post a schematic of your wiring. Include all parts, their values and all power supplies.

What’s the voltage & current?

You can use a relay (for AC or DC) or if it’s DC you can use a MOSFET driver circuit.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.