Skip to content

Commit

Permalink
initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulbot committed Oct 24, 2021
0 parents commit f4a3a2c
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 0 deletions.
Empty file added .gitignore
Empty file.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Battery Operated Warming Blanket
================================

A prototype portable warming blanket operated from a battery. Built to allow a wheelchair-bound
quadriplegic to control the temperature of his lower extremities while out in the New England
chilly seasons! I adapted this from a half-functioning design created by MIT undergraduates as
part of a assistive technologies hackathon.

Circuit Diagram
---------------

![drawing of connections from TinkerCAD](circuit-diagram.jpg)

[See the full drawing on TinkerCAD](https://www.tinkercad.com/things/05tBPTAC0bf-warming-blanket).

Parts List
----------

* RFD22102 RFduino DIP - Arduino controller (I found it in my drawer of random Arduino stuff)
([datasheet on Sparkfun](https://cdn.sparkfun.com/datasheets/Dev/RFduino/rfduino.datasheet.pdf))
* RFD22122 RGB LED / Button Shield - LED output ([datasheet on Sparkfun](https://cdn.sparkfun.com/datasheets/Dev/RFduino/rfduino.datasheet.pdf))
* RFD22121 USB Shield - adapter for programming ([datasheet on Sparkfun](https://cdn.sparkfun.com/datasheets/Dev/RFduino/rfduino.datasheet.pdf))
* LM2937ET-3.3 - voltage regulator to get from the 12V battery down to the 3.3 needed by the Arduino
([datasheet from TI]((https://www.ti.com/lit/ds/symlink/lm2937.pdf?HQS=dis-dk-null-digikeymode-dsf-pf-null-wwe&ts=1635103661151)))
* MOSFET - transistor used as a switch to control the voltage level going from the battery to
the blanket
* 10k resistor - wired from the Gate to the Source on the MOSFET (as recommended by the spec sheet)
* 10uF capacitor - wired from the voltage regulator output to ground (as recommended by the spec sheet)
* 0.1uF capacitor - wired from the voltage regulator input to ground (as recommended by the spec sheet)
* push-button switch switch - a random one I found in my drawer that he could activate despite his limited
hand mobility
* electric heating pad - 8 of these are inside the blanket; they create heat correspondin to the input voltage ([on Adafruit](https://www.adafruit.com/product/1481))

Credits
-------

Created by Rahul Bhargava and Alex Rosenberg.
156 changes: 156 additions & 0 deletions blanket-controller.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// constants for the RGB shield
#define RGB_RED 2
#define RGB_GREEN 3
#define RGB_BLUE 4
#define RGB_BUTTON_A 5
#define RGB_BUTTON_B 6

// output on GPIO pin 1 - this controls the MOSFET via PWM
#define MOSFET_GATE 1

// track the output voltage
#define HEAT_OFF 0
#define HEAT_LOW 1
#define HEAT_MEDIUM 2
#define HEAT_HIGH 3
int heatLevel = HEAT_OFF;

// used to track control button state (standard debouncing approach
// Button A is used for on-board debugging (momentary)
// Button B works as the deployment toggler switch
int buttonAState;
int lastButtonAState = LOW;
int buttonBState;
int lastButtonBState = LOW;
unsigned long lastDebounceATime = 0;
unsigned long lastDebounceBTime = 0;
unsigned long debounceDelay = 50;

// setup the pins and make sure the blanket is off
void setup() {
pinMode(RGB_RED, OUTPUT);
pinMode(RGB_GREEN, OUTPUT);
pinMode(RGB_BLUE, OUTPUT);
pinMode(RGB_BUTTON_A, INPUT);
pinMode(RGB_BUTTON_B, INPUT);
lastButtonBState = digitalRead(RGB_BUTTON_B);
pinMode(MOSFET_GATE, OUTPUT);
// setup serial comms for debugging
//Serial.begin(9600);
// intiailize it all as off
updateFeedbackLed();
updateOutputLevel();
}

// main functioning
void loop() {
int changed = 0;
changed = buttonWasPressed();
if (changed == 1) {
updateFeedbackLed();
updateOutputLevel();
}
}

int buttonWasPressed() {
int changed = 0;
int reading;

// check button A first
// A standard debounced button check
// see: https://www.arduino.cc/en/Tutorial/BuiltInExamples/Debounce
reading = digitalRead(RGB_BUTTON_A);
if (reading != lastButtonAState) {
lastDebounceATime = millis();
}
if ((millis() - lastDebounceATime) > debounceDelay) {
if (reading != buttonAState) {
buttonAState = reading;
if (buttonAState == HIGH) {
handleButtonPress();
changed = 1;
Serial.println("Button A Pressed");
}
}
}
lastButtonAState = reading;

// now check for toggle on button B
reading = digitalRead(RGB_BUTTON_B);
if (reading != lastButtonBState) {
lastDebounceBTime = millis();
}
if ((millis() - lastDebounceBTime) > debounceDelay) {
if (reading != buttonBState) {
buttonBState = reading;
handleButtonPress();
changed = 1;
Serial.println("Button B Pressed");
}
}
lastButtonBState = reading;

return changed; // return 1 if the button was pressed, 0 if not
}

void updateOutputLevel() {
int outputLevel = 0;
switch(heatLevel) {
case HEAT_OFF:
outputLevel = 0;
break;
case HEAT_LOW:
outputLevel = 70;
break;
case HEAT_MEDIUM:
outputLevel = 150;
break;
case HEAT_HIGH:
outputLevel = 255;
break;
}
//Serial.print(" -> ouput level ");
//Serial.println(outputLevel);
analogWrite(MOSFET_GATE, outputLevel);
}

void updateFeedbackLed() {
// I found that I needed to zero it before resetting in order to make the HEAT_LOW
// value show up correctly. No idea why. WTF.
analogWrite(RGB_RED, 0);
analogWrite(RGB_GREEN, 0);
analogWrite(RGB_BLUE, 0);
delay(10);
// now that we're reset the LEDs go ahead and set the right display level
switch(heatLevel) {
case HEAT_OFF:
analogWrite(RGB_RED, 0);
analogWrite(RGB_GREEN, 0);
analogWrite(RGB_BLUE, 100);
break;
case HEAT_LOW:
analogWrite(RGB_RED, 20);
analogWrite(RGB_GREEN, 0);
analogWrite(RGB_BLUE, 0);
break;
case HEAT_MEDIUM:
analogWrite(RGB_RED, 120);
analogWrite(RGB_GREEN, 0);
analogWrite(RGB_BLUE, 0);
break;
case HEAT_HIGH:
analogWrite(RGB_RED, 255);
analogWrite(RGB_GREEN, 0);
analogWrite(RGB_BLUE, 0);
break;
}
}

void handleButtonPress() {
heatLevel = heatLevel + 1;
if (heatLevel == 4) {
heatLevel = 0;
}
//Serial.print("Set heatLevel to ");
//Serial.println(heatLevel);
}
Binary file added circuit-diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4a3a2c

Please sign in to comment.