Introduction: Moon With the Bat Silhouette

Picture of Moon With the Bat Silhouette

Everybody knows that full Moon attracts all supernatural forces. This project about the Bat flying in front of Moon, while Moon changes its phases. Eyes of the Bat accrue red accent when Moon is full.

Step 1: Components

Picture of Components

Some of the project components you can see on the photo:

  • Twelve Backlight White LED modules (Adafruit Industrries)
  • Two RED super bright LEDs (SparkFun electronics)
  • Atmega328 micro controller (Mouser Electronics)
  • Fourteen resistors 270 Ohm, 1/4 Watt (Fry's)
  • Six pins header (Fry's)

In addition to this components project utilizes:

  • Two Plexiglas sheets 6*6*1/16" (I cut it out of old picture frame glass).
  • RadioShack Multipurpose PC Board Catalog #: 2760150.
  • Two fourteen pin sockets (not to solder micro controller directly, Fry's).
  • Some wires.
  • Heat shrinks.
  • A lot of Velcro self adhesive strips.

Step 2: Making the Moon Screen

Picture of Making the Moon Screen
  • Peel out reflective covers from the LED modules: it may loose some brightness, but becomes half transparent and obtains gloomy lights which suites Halloween decor well.
  • Cut Velcro strip, peel out adhesive protection form the hook part, put it alone the edge of Plexiglass sheet. Put six LED modules as shown on the photo.
  • Repeat the same for the bottom line of modules.
  • Attach loop strips to hook strips securing LED modules.
  • Put two more Velcro strips on the sides.

Step 3: Making the Moon Screen (2)

Picture of Making the Moon Screen (2)
  • Peel out adhesive protection from the loop part of strips.
  • Put second Plexiglass sheet on top making the sandwich with LED modules inside.

Now there is sturdy LED screen. It is time to start wiring. Solder together all white LED cathodes.

Step 4: Circuit Diagram

Picture of Circuit  Diagram

Here is circuit diagram of the project. It is fairly simple.

Step 5: Assembling

Picture of Assembling

Picture above shows assembled circuit.

Now is time to program it. Comment for the next step contains custom part of C source code of the project. In addition to custom code there are three header files included. Files io.h and interrupt.h comes with Atmel studio. File pt.h is protothread implementation taken form this source:http://dunkels.com/adam/pt/ It makes real time programming easy. Complied program written into the micro controller memory with the help of AVRISP unit (Atmel).

Step 6: Programming

Picture of Programming

/* moon.c */

#include <avr/io.h>
#include <avr/interrupt.h>
#include "./pt-1.4/pt.h" // http://dunkels.com/adam/pt/


typedef enum {OUT_LOW, OUT_HIGH} OutputLevel;
volatile uint16_t pulses;


#define pinOut(port, bit, outLevel) \
(DDR##port |= (1 << ( DD##port##bit)));\
switch(outLevel) \
{\
	case OUT_LOW: (PORT##port &= ~(1 << (PORT##port##bit))); break;\
	case OUT_HIGH: (PORT##port |= (1 << (PORT##port##bit))); break;\
}
void clearAll()
{	// set all outputs low
	DDRB = 0xFF;	PORTB = 0;
	DDRC = 0xFF;	PORTC = 0;
	DDRD = 0xFF;	PORTD = 0;
}
void activateTimer0()
{
	cli();
	pulses = 0;
	TCCR0A=0;	// Normal operation
	TCCR0B=2;	// f divider 64  : about 2 ms for interrupt ...
	TIMSK0 = 1;	// for system clock f= 1Mhz (CKDIV8 set)
	sei();
}
struct pt wpt; // protothread descriptor


int moonlight(struct pt* mlpt)
{
	PT_BEGIN(mlpt); 	// New Moon 
		PT_YIELD(mlpt); 
			pinOut(C,5,OUT_HIGH);	pinOut(B,1,OUT_HIGH);
		PT_YIELD(mlpt);
			pinOut(D,0,OUT_HIGH);	pinOut(B,2,OUT_HIGH);
		PT_YIELD(mlpt);
			pinOut(D,1,OUT_HIGH);	pinOut(B,0,OUT_HIGH);
		PT_YIELD(mlpt);	// First Quarter 		
			pinOut(D,2,OUT_HIGH);	pinOut(D,7,OUT_HIGH);
		PT_YIELD(mlpt);
			pinOut(D,3,OUT_HIGH);	pinOut(D,6,OUT_HIGH);
		PT_YIELD(mlpt);
			pinOut(D,4,OUT_HIGH);	pinOut(D,5,OUT_HIGH);
			pinOut(C,0,OUT_HIGH);	pinOut(C,1,OUT_HIGH);
		PT_YIELD(mlpt); 	// Full Moon + Red Eyes
		PT_YIELD(mlpt); 
			pinOut(C,0,OUT_LOW);	pinOut(C,1,OUT_LOW);
			pinOut(C,5,OUT_LOW);	pinOut(B,1,OUT_LOW);
		PT_YIELD(mlpt);
			pinOut(D,0,OUT_LOW);	pinOut(B,2,OUT_LOW);
		PT_YIELD(mlpt);
			pinOut(D,1,OUT_LOW);	pinOut(B,0,OUT_LOW);
		PT_YIELD(mlpt);		// Third Quarter
			pinOut(D,2,OUT_LOW);	pinOut(D,7,OUT_LOW);
		PT_YIELD(mlpt);
			pinOut(D,3,OUT_LOW);	pinOut(D,6,OUT_LOW);
		PT_YIELD(mlpt);
			pinOut(D,4,OUT_LOW);	pinOut(D,5,OUT_LOW);
		PT_RESTART(mlpt);	// New Moon
	PT_END(mlpt);
}
ISR(TIMER0_OVF_vect)
{
	pulses++;
	uint16_t mod =pulses%750;
	if (mod == 0){
		moonlight(&wpt);		
	}
}
int main(void)
{
	PT_INIT(&wpt); // initiate protothread structure...
	clearAll();
	activateTimer0();
    while(1) { }
}

Step 7: Making the Front and Back Panels

Picture of Making the Front and Back Panels

I cut front and back cardboard panels with round opening and attached it to LED screen (again with Velcro). Cardboard strip on the back panel keeps red LEDs on the places where Bat eyes will be.

Step 8: Cutting the Bat Silhouette

Picture of Cutting the Bat Silhouette

There are a lot of tips online how to draw the Bat. In particular I found this link really useful: https://www.youtube.com/watch?v=Y3697cBJzfc

Step 9: Done

Picture of Done

Here the Bat (painted in black color) attached to the front of the Moon (with Velcro, of course). It is done now. Hang the Moon in your window to greet your Halloween guests.

Comments

About This Instructable

494views

1favorite

License:

Bio: I got my education and initial job experience in Ukraine, but in 1998 moved to California. I work as software engineer in one of Bay ... More »
More by jumbleview:Supercapacitor Useless Machine or Dialog With Smart GuyTea Cans As Paint Brush HoldersRedwood Stakes As Bender Boards
Add instructable to: