Code and List of Components
Sophia Perez and Madena Kusi
List:
- White Leather Jacket- already had
- 3V Lithium Battery
- Adafruit DotStar Digital LED Strip- Black 60 LED- Per Meter- Black: $29.95 https://www.adafruit.com/products/2239
- Temperature Sensor- Already in kit
- Solder and Soldering Iron- Already in class
- Adafruit Trinket-Mini Microcontroller- 3.3V Logic: $9.91 https://www.amazon.com/Adafruit-Trinket-Mini-Microcontroller-Logic/dp/B00KBXTFSO/ref=sr_1_4?ie=UTF8&qid=1478026363&sr=8-4&keywords=adafruit+trinket
Code:
http://www.letsstartcoding.com/temperature-sensor-led-color-changer/
/*
*An LED strip that changes color depending on the temperature
*/
#include “LEDStrip.h”
const byte numPixels = 15; //number of pixels on a strip
/*
*Make the LED strip object LEDStrip strip
* = LEDStrip(numPixels, dataPin, clockPin);
*/
LEDStrip strip = LEDStrip(numPixels, 13, 12);
void setup() {
pinMode(A4,INPUT); //Temperature sensor pin
}
void loop() {
const int minTemp= 60; //set the minimum expected temp as a variable
const int maxTemp= 80;
//Use an equation to convert the analogRead of the temp sensor to a
//value in degrees Fahrenheit
float tempF = int(0.88*float(analogRead(A4)) – 58.0);
//limit the possible values of tempF to minTemp and maxTemp
tempF = constrain(tempF,minTemp,maxTemp);
//Set the pixels to the color corresponding to temperature
strip.setPixel(strip.ALL,map(tempF,minTemp,maxTemp,0,100));
strip.draw(); //Draw the pixels that you set in .setPixel
delay(250);
}
//Change the color range in the map (0,100) for a different range based on temp
//Need help? http://www.letsstartcoding.com/help
//(c) 2015 Let’s Start Coding. License: www.letsstartcoding.com/bsdlicense