I love combining electronics and embroidery! These two examples are simple night light circuits. To make one of these, you’ll need a photocell sensor, a few LEDs, a few resistors, an ATtiny85, a battery holder (the best kind have switches!), and a USB programmer. I like to use 2032 coin cell batteries, as they’re the smallest and provide enough power to the microcontroller. Initially I was going to use a sewable photocell I had milled, but the conductive thread wasn’t sensitive enough to get any readings. So for this project I went with wires and soldering. I’ve milled a small PCB and soldered a header to the ATtiny, so I can reprogram the the microcontroller if I need to. I use Arduino software for the programming.
I found an ATtiny dark detector instructable online, and went from there. Instead of having a green LED light up when there was light hitting the photocell, and a red LED turn on when it was dark, I omitted the red LEDs and used 5 white ones to turn on when the photocell wasn’t sensing light. The original author used 2 330 ohm resistors for his LEDs, and I found that the 10k resistor works great for 5 white LEDs. As far as programming the ATtiny, I prefer to use Sparkfun’s USB ATtiny programmer, as it is very reliable and straight forward. You can also program with your attiny with an Arduino Uno, but this requires some set up and hasn’t always worked for me!
Before building my circuit into the embroidery hoop, I first tested it out. This was handy to test the code, adjust the threshold, and try out different resistors so the white LEDs wouldn’t be blinding to the eyes! I recommend bread boarding any circuit you plan on incorporating into fabric first. Not only are you familiarizing yourself with where everything should go, but you can experiment with it to get the correct effects you want.
Drawing out a schematic and planning where the components will go is an important step! After poking my LEDs and photocell through the embroidery, I played around with where to place the ATtiny and battery holder. I love soldering so wiring everything up went smoothly and quickly!
As far as programming goes, I didn’t change much to the original code. I took out the green LEDs (D0) and put my white LEDs in place of the red (D1). The code has a handy little hook up guide and pinout already in it, I edited it slightly to go with my project:
This is the simple Arduino code:
//pins
int photo = 1;
int green = 1;
//variables
int threshold = 600; //This is the light level that determins wheather it is bright or dark
void setup() {
pinMode(green, OUTPUT);
}
void loop() {
int light = analogRead(photo);
digitalWrite(green, LOW);
delay(10);
if(light <= threshold) {
digitalWrite(green, HIGH);
}
else{
digitalWrite(green, LOW);
}
delay(10);
}
That’s pretty much all there is to it! In the future I will make a tutorial on how to stitch your own images with digitizing software. Currently, I’m attempting a fabric dice roller, so stay tuned for more silly circuit projects!