Introduction: Making an Interactive Twinkling Winter Cap

About: Happiness is invisible? Then you cannot sell it? You cannot copy it nor like it:-) You have to arrive there yourself??? But i am just a consumer! See Baudrillard, La societe de consommation, p60....
Winter in Holland! No snow, no ice, but endless rain. They say the people around the arctic have 29 words for snow, Dutch people have about the same number of words for rain.

Nonetheless we have a feeling of winter as it should be.
For this winter we made an interactive cap with two colors of white fabric.

The cap gives an idea if warmth and cosiness in the cold.

When daylight diminishes it starts to twinkle. There are led's inside of a third kind of white.
The bright led's diffuse their light in a subtle way in the white materials and reinforce the idea
of warmth within a cold environment.
(The pictures actually do not show the effect in the right way, to get the led's visible on the images the effect is exaggerated.)

Step 1: Needed: Tools and Materials

tools:
soldering device (suited for soldering small parts, like led's)
pincher (for the wiring and removal of led legs.)
needle and thread
knitting gear

materials:
wool of two kinds and colors (in this case two whites)
Some fabric for making the inner hat with the led's
an atmega328 or other comparable microcontroller chip, with sufficient digital PINS and one (or more) analog PINS.
led's and wire (used here is the kind of wire with a very small diameter, very flexible and good to use in clothing).
2 AAA batteries in a battery holder, the cap is running on 2.8 Volts.

assistance:
a mum or an aunt to knit the cap :-)

programming:
for programming the microcontroller I have used a programmer like avrisp mkii
the chip is a atmega328 running on its internal clock 8MHz (set the fuses carefully!)
here is the file for the project, if you do not want to make it yourself:
http://www.contrechoc.com/instructables/twinkle_winter_cap_project.zip

Step 2: Materials of the Cap

This cap is knitted with two colors white wool and two kinds of wool.

The first white is blueish and is used around the rim and on top, the second white is 'warm white' relative to the blueish.

Also the two (artificial without doubt) materials have fancy structures, difficult to describe in words, but for that we have the pictures.

Step 3: Making the Parts and Fitting

After having knitted the cap (round knitting), the rim and the top, these are sewed together by hand using some of
the same wool. Of course the shape and size can be varied according to your fancy and the head of the wearer.

The led's are fitted to a separated cap of, in my case light grey fabric.
The led's are connected using the flexible strip principle, which saves a lot of wiring and PINS on the microcontroller.
(Essentially the matrix connection also used in led matrix block's.)
Making the flexible led strip has been described in one of my former instructables:
https://www.instructables.com/id/Making-a-flexible-ring-of-LEDs/

For this cap bright white led's were used.
Programming the led strip and using a LDR for interactivity is not too difficult using the program file and AVR studio:


The chip is on a small PCB and can be fitted inside the space under the top part of the cap.
The batteries can be either also hidden here of inside your coat.

Advisable for using the cap is making a third inner cap protecting the led connections from your beautiful and abundant hair!

When everything is tested and you are satisfied with the interactivity and the light pattern you can sew the parts together.

Step 4: More Code, for Use With a Mechanical Tils Sensor

The first code was just a running pattern around the available LED's.

This links provides another interactive pattern of the LED's, using a metal ball in a square casing.
See the grey box next to the atmega328. It was salvaged from a deceased Sony dog!

Using this tilt sensor, I had to make a tiltcheck function. This seemed easy, but it was not!
The principle was right, but a delay had to be inserted switching the PIN pattern.

See the function in the script:
uint8_t checkTilt(){

uint8_t tiltPin = 0;
PORTC |=(1<<PC1);
PORTC |=(1<<PC5);
uint8_t delayTime = 50;//--------------------------> delay
PORTC &= ~_BV(PC1);
_delay_ms(delayTime);//--------------------------> delay
if ( (PINC & ( 1<<PC4)) == 0 ) tiltPin = 2;//left
if ( (PINC & ( 1<<PC2)) == 0 ) tiltPin = 1;// front
PORTC |=(1<<PC1);
_delay_ms(2*delayTime);//here a delay is necessary, otherwise readings are strange ???
PORTC &= ~_BV(PC5);
_delay_ms(delayTime);//--------------------------> delay
if ( (PINC & ( 1<<PC4)) == 0 ) tiltPin = 5;//back
if ( (PINC & ( 1<<PC2)) == 0 ) tiltPin = 3;// right
if ( (PINC & ( 1<<PC3)) == 0 ) tiltPin = 4;//mid -> top

PORTC |=(1<<PC5);
return tiltPin;
}

http://www.contrechoc.com/instructables/twinkle_winter_cap_project_2.zip

Now when you move your head, the LED's will change pattern to left, right, fron or back. And when not inclined the top LED's are on.