DIY Heated Earmuffs

Pages
Contributors: Feldi
Favorited Favorite 5

Software Installation

Arduino IDE

The Pro Micro 5V is programmable via the Arduino IDE. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing Arduino IDE

March 26, 2013

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Pro Micro Drivers and Board Add-On

If this is your first time working with the Pro Micro, you may need to add drivers and the board add-on through the boards manager. Please visit the Pro Micro hookup guide for detailed instructions on installing drivers and programming a Pro Micro via the Arduino IDE.

Example Code

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

In this program, we will also be utilizing the Adafruit Neopixel Library. You can download the library below.

We have provided the code for this project below. Copy and paste it into your Arduino IDE and then upload it to your board. Make sure you have the correct board selected in the boards manager as well as the port under the port drop down.

language:c
    /******************************************************************************
  earmuffs.ino
  Melissa Felderman @ SparkFun Electronics
  creation date: January 22, 2018


  Resources:
  Adafruit_NeoPixel.h - Adafruit Neopixel library and example functions

*****************************************************************************/

#include <Adafruit_NeoPixel.h>

int heatPin = 3;
int ring = 4;


Adafruit_NeoPixel strip = Adafruit_NeoPixel(80, ring, NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(heatPin, OUTPUT);
  digitalWrite(heatPin, HIGH);
  strip.begin();
  strip.setBrightness(45);
  strip.show();

}

void loop() {
  // put your main code here, to run repeatedly:
  rainbowCycle(20);

}


// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;
strip.setBrightness(45);
  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}