Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Christmas Lights Controller + Music Player
#define F_CPU 1000000UL /* Clock Frequency = 1Mhz */
#include <avr/io.h>
#include <util/delay.h>
#define C1 (32)
#define Cs1 (34)
#define D1 (36)
#define Ds1 (39)
#define E1 (41)
#define F1 (43)
#define Fs1 (46)
#define G1 (49)
#define Gs1 (52)
#define A1 (55)
#define As1 (59)
#define B1 (62)
#define C2 (65)
#define Cs2 (69)
#define D2 (73)
#define Ds2 (78)
#define E2 (82)
#define F2 (87)
#define Fs2 (93)
#define G2 (98)
#define Gs2 (104)
#define A2 (110)
#define As2 (117)
#define B2 (124)
#define C3 (131)
#define Cs3 (139)
#define D3 (147)
#define Ds3 (156)
#define E3 (165)
#define F3 (175)
#define Fs3 (185)
#define G3 (196)
#define Gs3 (208)
#define A3 (220)
#define As3 (233)
#define B3 (247)
#define C4 (262)
#define Cs4 (277)
#define D4 (294)
#define Ds4 (311)
#define E4 (330)
#define F4 (349)
#define Fs4 (370)
#define G4 (392)
#define Gs4 (415)
#define A4 (440)
#define As4 (466)
#define B4 (494)
#define C5 (523)
#define Cs5 (554)
#define D5 (587)
#define Ds5 (622)
#define E5 (659)
#define F5 (698)
#define Fs5 (740)
#define G5 (784)
#define Gs5 (831)
#define A5 (880)
#define As5 (932)
#define B5 (988)
#define C6 (1047)
#define Cs6 (1109)
#define D6 (1175)
#define Ds6 (1245)
#define E6 (1318)
#define F6 (1397)
#define Fs6 (1480)
#define G6 (1568)
#define Gs6 (1661)
#define A6 (1760)
#define As6 (1865)
#define B6 (1976)
#define C7 (2093)
#define Cs7 (2218)
#define D7 (2350)
#define Ds7 (2489)
#define E7 (2637)
#define F7 (2794)
#define Fs7 (2960)
#define G7 (3136)
#define Gs7 (3323)
#define A7 (3520)
#define As7 (3729)
#define B7 (3951)
#define C8 (4186)
#define R (0)
#define REPEAT (1001)
#define SLUR (1 << 10)
int musicLen = 47;
float speed = 3;
float separation = 5;
float songDefSpeed[3];
float songDefSeparation[3];
int songDefLength[3];
const uint16_t *songDefMusic[3];
const uint16_t weWishYouMerry[] = { 200, 0b0001, C4, 200, 0b0100, F4, 100,
0b0100, F4, 100, 0b1000, G4, 100, 0b0100, F4, 100, 0b0010, E4, 200,
0b0100, D4, 200, 0b1000, As3, 200, 0b0100, D4, 200, 0b0010, G4, 100,
0b0010, G4, 100, 0b0001, A4, 100, 0b0010, G4, 100, 0b1000, F4, 200,
0b0100, E4, 200, 0b0001, C4, 200, 0b0001, C4, 200, 0b0010, A4, 100,
0b0010, A4, 100, 0b0001, As4, 100, 0b0010, A4, 100, 0b0100, G4, 200,
0b1000, F4, 200, 0b0010, D4, 100, 0b0001, C4, 100, 0b0001, C4, 200,
0b0010, D4, 200, 0b1000, G4, 200, 0b0100, E4, 400, 0b1000, F4, 200,
0b0001, C4, 200, 0b1000, F4, 200, 0b1000, F4, 200, 0b1000, F4, 400,
0b0100, E4, 200, 0b0100, E4, 200, 0b1000, F4, 200, 0b0100, E4, 200,
0b0010, D4, 400, 0b0001, C4, 200, 0b0001, C4, 200, 0b1000, A4, 200,
0b0100, G4, 200, 0b0010, F4, 200, 0b1000, C5, 200, 0b0001, C4, REPEAT,
25, 30 };
const uint16_t jingleBells[] = { 100, 0b0100, B4, 100, 0b0100, B4, 200, 0b0100,
B4, 100, 0b0100, B4, 100, 0b0100, B4, 200, 0b0100, B4, 100, 0b0100, B4,
100, 0b1000, D5, 100, 0b0001, G4, 100, 0b0010, A4, 400, 0b0100, B4, 100,
0b1000, C5, 100, 0b1000, C5, 100, 0b1000, C5, 100, 0b1000, C5, 100,
0b1000, C5, 100, 0b0100, B4, 100, 0b0100, B4, 100, 0b0100, B4, 100,
0b0100, B4, 100, 0b0010, A4, 100, 0b0010, A4, 100, 0b0100, B4, 200,
0b0010, A4, 200, 0b1000, D5, REPEAT, 0, 19, 100, 0b1000, D5, 100,
0b1000, D5, 100, 0b0100, C5, 100, 0b0010, A4, 400, 0b0001, G4 };
const uint16_t whiteChristmas[] = { 400, 0b0010, G4, 100, 0b0100, Gs4, 100,
0b0010, G4, 100, 0b0001, Fs4, 100, 0b0010, G4, 400, 0b0100, Gs4, 100,
0b1000, A4, 300, 0b0001, As4, 200, 0b0010, C5, 100, 0b0100, D5, 100,
0b1000, Ds5, 100, 0b0001, F5, 100, 0b1000, Ds5, 100, 0b0100, D5, 100,
0b0010, C5, 400, 0b0001, As4, 200, 0b0000, R, 100, 0b0001, Ds4, 100,
0b0010, F4, 200, 0b0100, G4, 200, 0b0100, G4, 100, 0b0100, G4, 200,
0b1000, C5, 100, 0b0001, As4, 200, 0b1000, Ds4, 200, 0b1000, Ds4, 100,
0b1000, Ds4, 200, 0b0001, As4, 100, 0b0100, Gs4, 400, 0b0010, G4, 100,
0b1000, Gs4, 100, 0b0100, G4, 100, 0b0010, F4, 100, 0b0001, Ds4, SLUR
| 700, 0b0010, F4, 100, 0b0110, Fs4, REPEAT, 0, 24, 600, 0b1000,
Ds5, REPEAT, 17, 21, 100, 0b1000, C5, 100, 0b1000, C5, 100, 0b0001, D4,
100, 0b0001, D4, 1200, 0b1111, Ds4 };
void sleep(uint32_t millisecO) {
uint32_t millisec = millisecO;
while (millisec > 0) {
void usleep(uint32_t microsec) {
while (microsec > 0) {
_delay_us(45); // Cause the if statement takes time
if (microsec <= 50) {
microsec -= 50;
void sleepMusic(uint32_t hz, uint32_t len) {
uint32_t speed;
if (hz == 0) {
speed = 1000;
} else {
speed = (500000 / hz);
uint32_t lenz = len * 1000;
while (1) {
if (hz == 0) {
PORTC &= ~1;
} else {
PORTC ^= 1;
if (lenz <= speed) {
lenz -= speed;
void playMusic(uint32_t idx, const uint16_t *music) {
if (music[(idx * 3)] == REPEAT) {
uint32_t ridx;
for (ridx = music[1 + (idx * 3)]; ridx < music[2 + (idx * 3)]; ridx++) {
playMusic(ridx, music);
} else {
PORTC = (music[1 + (idx * 3)] << 2) | (PORTC & 0b11);
uint32_t time = music[idx * 3];
if ((time & SLUR)== SLUR) {
time += (uint32_t) (separation * speed);
sleepMusic(music[2 + (idx * 3)], (uint32_t) ((time & ~SLUR)* speed));
if ((time & SLUR)!= SLUR) {
PORTC = 0;
usleep((uint32_t) (1000.0 * separation * speed));
int main() {
DDRD = 0xff;
PORTC = 0b11111111;
DDRC = 0b11111111;
int32_t idx = 0;
int32_t songIdx = 0;
songDefMusic[0] = jingleBells;
songDefMusic[1] = weWishYouMerry;
songDefMusic[2] = whiteChristmas;
songDefSpeed[0] = 1.5f;
songDefSpeed[1] = 1.5f;
songDefSpeed[2] = 2.5f;
songDefSeparation[0] = 5.0f;
songDefSeparation[1] = 5.0f;
songDefSeparation[2] = 5.0f;
songDefLength[0] = 31;
songDefLength[1] = 47;
songDefLength[2] = 44;
musicLen = songDefLength[songIdx];
speed = songDefSpeed[songIdx];
separation = songDefSeparation[songIdx];
idx = 0;
while (1) {
playMusic(idx, songDefMusic[songIdx]);
if (idx >= musicLen) {
int8_t lightNum = 0;
for (idx = 0; idx < 5; idx++) {
for (lightNum = 0; lightNum < 4; lightNum++) {
PORTC = (1 << (lightNum + 2)) & (~1);
for (lightNum = 3; lightNum >= 0; lightNum--) {
PORTC = (1 << (lightNum + 2)) & (~1);
if (songIdx >= 3) {
songIdx = 0;
musicLen = songDefLength[songIdx];
speed = songDefSpeed[songIdx];
separation = songDefSeparation[songIdx];
idx = 0;
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
<eagle version="6.4">
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="no"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="no"/>
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="no"/>
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="no"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="no"/>
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="no"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="no"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="no"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="no"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="no"/>
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="no"/>
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="no"/>
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="no"/>
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="no"/>
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="no"/>
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="no"/>
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="no"/>
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="no"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="no"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="no"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="no"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="no"/>
<layer number="37" name="tTest" color="7" fill="1" visible="yes" active="no"/>
<layer number="38" name="bTest" color="7" fill="1" visible="yes" active="no"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="no" active="no"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="no" active="no"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="no" active="no"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="no" active="no"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="no"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="no"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="no"/>
<layer number="46" name="Milling" color="3" fill="1" visible="yes" active="no"/>
<layer number="47" name="Measures" color="7" fill="1" visible="yes" active="no"/>
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="no"/>
<layer number="49" name="Reference" color="7" fill="1" visible="yes" active="no"/>
<layer number="51" name="tDocu" color="6" fill="9" visible="yes" active="no"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="no"/>
<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>
<layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"/>
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="yes"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>
<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>
<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>
<layer number="97" name="Info" color="7" fill="1" visible="no" active="yes"/>
<layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"/>
<schematic xreflabel="%F%N/%S.%C%R" xrefpart="/%S.%C%R">
<library name="atmel">
<description>&lt;b&gt;AVR Devices&lt;/b&gt;&lt;p&gt;
Configurable logic, microcontrollers, nonvolatile memories&lt;p&gt;
Based on the following sources:&lt;p&gt;
&lt;li&gt;CD-ROM : Configurable Logic Microcontroller Nonvolatile Memory
&lt;li&gt;CadSoft download site, or , file
&lt;author&gt;Revised by;/author&gt;</description>
<package name="DIL28-3">
<description>&lt;B&gt;Dual In Line&lt;/B&gt; 0.3 inch</description>
<wire x1="-18.542" y1="-0.635" x2="-18.542" y2="-2.794" width="0.1524" layer="21"/>
<wire x1="-18.542" y1="0.635" x2="-18.542" y2="-0.635" width="0.1524" layer="21" curve="-180"/>
<wire x1="-18.542" y1="-2.794" x2="18.542" y2="-2.794" width="0.1524" layer="21"/>
<wire x1="-18.542" y1="2.794" x2="-18.542" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-18.542" y1="2.794" x2="18.542" y2="2.794" width="0.1524" layer="21"/>
<wire x1="18.542" y1="2.794" x2="18.542" y2="-2.794" width="0.1524" layer="21"/>
<pad name="1" x="-16.51" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="2" x="-13.97" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="3" x="-11.43" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="4" x="-8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="5" x="-6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="6" x="-3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="7" x="-1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="8" x="1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="9" x="3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="10" x="6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="11" x="8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="12" x="11.43" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="13" x="13.97" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="14" x="16.51" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="15" x="16.51" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="16" x="13.97" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="17" x="11.43" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="18" x="8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="19" x="6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="20" x="3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="21" x="1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="22" x="-1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="23" x="-3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="24" x="-6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="25" x="-8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="26" x="-11.43" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="27" x="-13.97" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<pad name="28" x="-16.51" y="3.81" drill="0.8128" shape="long" rot="R90"/>
<text x="-19.2024" y="-2.54" size="1.778" layer="25" ratio="10" rot="R90">&gt;NAME</text>
<text x="-15.875" y="-0.635" size="1.778" layer="27" ratio="10">&gt;VALUE</text>
<symbol name="23-I/O-2">
<wire x1="-17.78" y1="30.48" x2="20.32" y2="30.48" width="0.254" layer="94"/>
<wire x1="20.32" y1="30.48" x2="20.32" y2="-33.02" width="0.254" layer="94"/>
<wire x1="20.32" y1="-33.02" x2="-17.78" y2="-33.02" width="0.254" layer="94"/>
<wire x1="-17.78" y1="-33.02" x2="-17.78" y2="30.48" width="0.254" layer="94"/>
<text x="-17.78" y="-35.56" size="1.778" layer="95">&gt;NAME</text>
<text x="-17.78" y="31.75" size="1.778" layer="96">&gt;VALUE</text>
<pin name="PB5(SCK)" x="25.4" y="-30.48" length="middle" rot="R180"/>
<pin name="PB7(XTAL2/TOSC2)" x="-22.86" y="5.08" length="middle"/>
<pin name="PB6(XTAL1/TOSC1)" x="-22.86" y="10.16" length="middle"/>
<pin name="GND@1" x="-22.86" y="-2.54" length="middle" direction="pwr"/>
<pin name="VCC@1" x="-22.86" y="-7.62" length="middle" direction="pwr"/>
<pin name="GND" x="-22.86" y="22.86" length="middle" direction="pwr"/>
<pin name="AREF" x="-22.86" y="20.32" length="middle" direction="pas"/>
<pin name="AVCC" x="-22.86" y="17.78" length="middle" direction="pwr"/>
<pin name="PB4(MISO)" x="25.4" y="-27.94" length="middle" rot="R180"/>
<pin name="PB3(MOSI/OC2)" x="25.4" y="-25.4" length="middle" rot="R180"/>
<pin name="PB2(SS/OC1B)" x="25.4" y="-22.86" length="middle" rot="R180"/>
<pin name="PB1(OC1A)" x="25.4" y="-20.32" length="middle" rot="R180"/>
<pin name="PB0(ICP)" x="25.4" y="-17.78" length="middle" rot="R180"/>
<pin name="PD7(AIN1)" x="25.4" y="-12.7" length="middle" rot="R180"/>
<pin name="PD6(AIN0)" x="25.4" y="-10.16" length="middle" rot="R180"/>
<pin name="PD5(T1)" x="25.4" y="-7.62" length="middle" rot="R180"/>
<pin name="PD4(XCK/T0)" x="25.4" y="-5.08" length="middle" rot="R180"/>
<pin name="PD3(INT1)" x="25.4" y="-2.54" length="middle" rot="R180"/>
<pin name="PD2(INT0)" x="25.4" y="0" length="middle" rot="R180"/>
<pin name="PD1(TXD)" x="25.4" y="2.54" length="middle" rot="R180"/>
<pin name="PD0(RXD)" x="25.4" y="5.08" length="middle" rot="R180"/>
<pin name="PC5(ADC5/SCL)" x="25.4" y="15.24" length="middle" rot="R180"/>
<pin name="PC4(ADC4/SDA)" x="25.4" y="17.78" length="middle" rot="R180"/>
<pin name="PC3(ADC3)" x="25.4" y="20.32" length="middle" rot="R180"/>
<pin name="PC2(ADC2)" x="25.4" y="22.86" length="middle" rot="R180"/>
<pin name="PC1(ADC1)" x="25.4" y="25.4" length="middle" rot="R180"/>
<pin name="PC0(ADC0)" x="25.4" y="27.94" length="middle" rot="R180"/>
<pin name="PC6(/RESET)" x="-22.86" y="27.94" length="middle" function="dot"/>
<deviceset name="MEGA8-P" prefix="IC">
8 Kbytes FLASH, 1 kbytes SRAM, 512 bytes EEPROM, USART, 4-channel 10 bit ADC, 2-channel 8 bit ADC&lt;br&gt;
Pin compatible with Atmega48, ATMega88, ATMega168&lt;br&gt;
Source: avr.lbr</description>
<gate name="G$1" symbol="23-I/O-2" x="0" y="0"/>
<device name="" package="DIL28-3">
<connect gate="G$1" pin="AREF" pad="21"/>
<connect gate="G$1" pin="AVCC" pad="20"/>
<connect gate="G$1" pin="GND" pad="22"/>
<connect gate="G$1" pin="GND@1" pad="8"/>
<connect gate="G$1" pin="PB0(ICP)" pad="14"/>
<connect gate="G$1" pin="PB1(OC1A)" pad="15"/>
<connect gate="G$1" pin="PB2(SS/OC1B)" pad="16"/>
<connect gate="G$1" pin="PB3(MOSI/OC2)" pad="17"/>
<connect gate="G$1" pin="PB4(MISO)" pad="18"/>
<connect gate="G$1" pin="PB5(SCK)" pad="19"/>
<connect gate="G$1" pin="PB6(XTAL1/TOSC1)" pad="9"/>
<connect gate="G$1" pin="PB7(XTAL2/TOSC2)" pad="10"/>
<connect gate="G$1" pin="PC0(ADC0)" pad="23"/>
<connect gate="G$1" pin="PC1(ADC1)" pad="24"/>
<connect gate="G$1" pin="PC2(ADC2)" pad="25"/>
<connect gate="G$1" pin="PC3(ADC3)" pad="26"/>
<connect gate="G$1" pin="PC4(ADC4/SDA)" pad="27"/>
<connect gate="G$1" pin="PC5(ADC5/SCL)" pad="28"/>
<connect gate="G$1" pin="PC6(/RESET)" pad="1"/>
<connect gate="G$1" pin="PD0(RXD)" pad="2"/>
<connect gate="G$1" pin="PD1(TXD)" pad="3"/>
<connect gate="G$1" pin="PD2(INT0)" pad="4"/>
<connect gate="G$1" pin="PD3(INT1)" pad="5"/>
<connect gate="G$1" pin="PD4(XCK/T0)" pad="6"/>
<connect gate="G$1" pin="PD5(T1)" pad="11"/>
<connect gate="G$1" pin="PD6(AIN0)" pad="12"/>
<connect gate="G$1" pin="PD7(AIN1)" pad="13"/>
<connect gate="G$1" pin="VCC@1" pad="7"/>
<technology name="">
<attribute name="MF" value="" constant="no"/>
<attribute name="MPN" value="" constant="no"/>
<attribute name="OC_FARNELL" value="unknown" constant="no"/>
<attribute name="OC_NEWARK" value="unknown" constant="no"/>
<library name="buzzer">
<description>&lt;b&gt;Speakers and Buzzers&lt;/b&gt;&lt;p&gt;
&lt;author&gt;Created by;/author&gt;</description>
<package name="KSS1201">
<wire x1="2.794" y1="2.54" x2="3.81" y2="2.54" width="0.1524" layer="21"/>
<wire x1="3.302" y1="3.048" x2="3.302" y2="2.032" width="0.1524" layer="21"/>
<circle x="0" y="0" radius="1.27" width="0.1524" layer="21"/>
<circle x="0" y="0" radius="6.096" width="0.1524" layer="21"/>
<circle x="3.302" y="2.54" radius="0.762" width="0.1524" layer="21"/>
<pad name="+" x="3.2512" y="0" drill="0.9144" diameter="2.159" shape="octagon"/>
<pad name="-" x="-3.2512" y="0" drill="0.9144" diameter="2.159" shape="octagon"/>
<text x="3.937" y="5.08" size="1.27" layer="25" ratio="10">&gt;NAME</text>
<text x="-3.556" y="-3.81" size="1.27" layer="27" ratio="10">&gt;VALUE</text>
<symbol name="SP">
<wire x1="-1.905" y1="-0.635" x2="1.905" y2="-0.635" width="0.254" layer="94"/>
<wire x1="1.905" y1="-0.635" x2="1.905" y2="0" width="0.254" layer="94"/>
<wire x1="1.905" y1="2.54" x2="-1.905" y2="2.54" width="0.254" layer="94"/>
<wire x1="-1.905" y1="-0.635" x2="-1.905" y2="0" width="0.254" layer="94"/>
<wire x1="1.905" y1="2.54" x2="5.08" y2="5.08" width="0.254" layer="94"/>
<wire x1="5.08" y1="5.08" x2="-5.08" y2="5.08" width="0.254" layer="94"/>
<wire x1="-1.905" y1="2.54" x2="-5.08" y2="5.08" width="0.254" layer="94"/>
<wire x1="2.54" y1="0" x2="1.905" y2="0" width="0.1524" layer="94"/>
<wire x1="1.905" y1="0" x2="1.905" y2="2.54" width="0.254" layer="94"/>
<wire x1="-2.54" y1="0" x2="-1.905" y2="0" width="0.1524" layer="94"/>
<wire x1="-1.905" y1="0" x2="-1.905" y2="2.54" width="0.254" layer="94"/>
<text x="-3.81" y="6.35" size="1.778" layer="95">&gt;NAME</text>
<text x="-3.81" y="-3.175" size="1.778" layer="96">&gt;VALUE</text>
<pin name="2" x="5.08" y="0" visible="pad" length="short" direction="pas" rot="R180"/>
<pin name="1" x="-5.08" y="0" visible="pad" length="short" direction="pas"/>
<deviceset name="KSS1201" prefix="SP">
Source: Schukat</description>
<gate name="1" symbol="SP" x="0" y="0"/>
<device name="" package="KSS1201">
<connect gate="1" pin="1" pad="+"/>
<connect gate="1" pin="2" pad="-"/>
<technology name="">
<attribute name="MF" value="" constant="no"/>
<attribute name="MPN" value="" constant="no"/>
<attribute name="OC_FARNELL" value="unknown" constant="no"/>
<attribute name="OC_NEWARK" value="unknown" constant="no"/>
<library name="supply1">
<description>&lt;b&gt;Supply Symbols&lt;/b&gt;&lt;p&gt;
GND, VCC, 0V, +5V, -5V, etc.&lt;p&gt;
Please keep in mind, that these devices are necessary for the
automatic wiring of the supply signals.&lt;p&gt;
The pin name defined in the symbol is identical to the net which is to be wired automatically.&lt;p&gt;
In this library the device names are the same as the pin names of the symbols, therefore the correct signal names appear next to the supply symbols in the schematic.&lt;p&gt;
&lt;author&gt;Created by;/author&gt;</description>
<symbol name="PE">
<wire x1="-1.905" y1="0" x2="1.905" y2="0" width="0.254" layer="94"/>
<wire x1="-1.0922" y1="-0.508" x2="1.0922" y2="-0.508" width="0.254" layer="94"/>
<wire x1="-0.6223" y1="-1.016" x2="0.6223" y2="-1.016" width="0.254" layer="94"/>
<wire x1="-0.3048" y1="-1.524" x2="0.3302" y2="-1.524" width="0.254" layer="94"/>
<text x="-2.54" y="-2.54" size="1.778" layer="96" rot="R90">&gt;VALUE</text>
<pin name="PE" x="0" y="2.54" visible="off" length="short" direction="sup" rot="R270"/>
<symbol name="+5V">
<wire x1="1.27" y1="-1.905" x2="0" y2="0" width="0.254" layer="94"/>
<wire x1="0" y1="0" x2="-1.27" y2="-1.905" width="0.254" layer="94"/>
<text x="-2.54" y="-5.08" size="1.778" layer="96" rot="R90">&gt;VALUE</text>
<pin name="+5V" x="0" y="-2.54" visible="off" length="short" direction="sup" rot="R90"/>
<symbol name="VCC">
<wire x1="1.27" y1="-1.905" x2="0" y2="0" width="0.254" layer="94"/>
<wire x1="0" y1="0" x2="-1.27" y2="-1.905" width="0.254" layer="94"/>
<text x="-2.54" y="-2.54" size="1.778" layer="96" rot="R90">&gt;VALUE</text>
<pin name="VCC" x="0" y="-2.54" visible="off" length="short" direction="sup" rot="R90"/>
<deviceset name="PE" prefix="PE">
<description>&lt;b&gt;SUPPLY SYMBOL&lt;/b&gt;</description>
<gate name="M" symbol="PE" x="0" y="0"/>
<device name="">
<technology name=""/>
<deviceset name="+5V" prefix="P+">
<description>&lt;b&gt;SUPPLY SYMBOL&lt;/b&gt;</description>
<gate name="1" symbol="+5V" x="0" y="0"/>
<device name="">
<technology name=""/>
<deviceset name="VCC" prefix="P+">
<description>&lt;b&gt;SUPPLY SYMBOL&lt;/b&gt;</description>
<gate name="VCC" symbol="VCC" x="0" y="0"/>
<device name="">
<technology name=""/>
<library name="transistor">
&lt;author&gt;Created by;/author&gt;</description>
<package name="TO18">
<description>&lt;b&gt;TO 18&lt;/b&gt;</description>
<wire x1="0.9289" y1="2.227" x2="2.227" y2="0.9289" width="0.0508" layer="51" curve="-44.7172"/>
<wire x1="0.9289" y1="-2.227" x2="2.227" y2="-0.9289" width="0.0508" layer="51" curve="44.7172"/>
<wire x1="-3.937" y1="-0.508" x2="-3.937" y2="0.508" width="0.127" layer="21"/>
<wire x1="-2.227" y1="-0.9289" x2="0.929" y2="2.2271" width="0.0508" layer="21" curve="-135.281"/>
<wire x1="-2.227" y1="-0.9289" x2="-0.9289" y2="-2.227" width="0.0508" layer="51" curve="44.7172"/>
<wire x1="-3.937" y1="-0.508" x2="-2.8765" y2="-0.508" width="0.127" layer="21"/>
<wire x1="-0.9289" y1="-2.227" x2="0.9289" y2="-2.227" width="0.0508" layer="21" curve="45.2828"/>
<wire x1="-3.937" y1="0.508" x2="-2.8765" y2="0.508" width="0.127" layer="21"/>
<wire x1="2.227" y1="-0.9289" x2="2.227" y2="0.9289" width="0.0508" layer="21" curve="45.2828"/>
<circle x="0" y="0" radius="2.921" width="0.127" layer="21"/>
<pad name="1" x="-1.27" y="-1.27" drill="0.8128" shape="octagon"/>
<pad name="2" x="1.27" y="-1.27" drill="0.8128" shape="octagon"/>
<pad name="3" x="1.27" y="1.27" drill="0.8128" shape="octagon"/>
<text x="3.175" y="0" size="1.27" layer="25" ratio="10">&gt;NAME</text>
<text x="3.175" y="-1.905" size="1.27" layer="27" ratio="10">&gt;VALUE</text>
<text x="-1.905" y="-1.27" size="1.27" layer="51" ratio="10">1</text>
<text x="0.635" y="-1.27" size="1.27" layer="51" ratio="10">2</text>
<text x="0" y="0.635" size="1.27" layer="51" ratio="10">3</text>
<symbol name="NPN">
<wire x1="2.54" y1="2.54" x2="0.508" y2="1.524" width="0.1524" layer="94"/>
<wire x1="1.778" y1="-1.524" x2="2.54" y2="-2.54" width="0.1524" layer="94"/>
<wire x1="2.54" y1="-2.54" x2="1.27" y2="-2.54" width="0.1524" layer="94"/>
<wire x1="1.27" y1="-2.54" x2="1.778" y2="-1.524" width="0.1524" layer="94"/>
<wire x1="1.54" y1="-2.04" x2="0.308" y2="-1.424" width="0.1524" layer="94"/>
<wire x1="1.524" y1="-2.413" x2="2.286" y2="-2.413" width="0.254" layer="94"/>
<wire x1="2.286" y1="-2.413" x2="1.778" y2="-1.778" width="0.254" layer="94"/>
<wire x1="1.778" y1="-1.778" x2="1.524" y2="-2.286" width="0.254" layer="94"/>
<wire x1="1.524" y1="-2.286" x2="1.905" y2="-2.286" width="0.254" layer="94"/>
<wire x1="1.905" y1="-2.286" x2="1.778" y2="-2.032" width="0.254" layer="94"/>
<text x="-10.16" y="7.62" size="1.778" layer="95">&gt;NAME</text>
<text x="-10.16" y="5.08" size="1.778" layer="96">&gt;VALUE</text>
<rectangle x1="-0.254" y1="-2.54" x2="0.508" y2="2.54" layer="94"/>
<pin name="B" x="-2.54" y="0" visible="off" length="short" direction="pas" swaplevel="1"/>
<pin name="E" x="2.54" y="-5.08" visible="off" length="short" direction="pas" swaplevel="3" rot="R90"/>
<pin name="C" x="2.54" y="5.08" visible="off" length="short" direction="pas" swaplevel="2" rot="R270"/>
<deviceset name="2N706" prefix="T">
<description>&lt;b&gt;NPN TRANSISTOR&lt;/b&gt;</description>
<gate name="G$1" symbol="NPN" x="0" y="0"/>
<device name="" package="TO18">
<connect gate="G$1" pin="B" pad="2"/>
<connect gate="G$1" pin="C" pad="3"/>
<connect gate="G$1" pin="E" pad="1"/>
<technology name=""/>
<library name="relay">
&lt;author&gt;Created by;/author&gt;</description>
<package name="JW1A">
<description>&lt;b&gt;Power relay&lt;/b&gt;&lt;p&gt;
Source: Panasonic Electric Works Co., Ltd. / jw.catalog.pdf</description>
<wire x1="-12.759" y1="-6.604" x2="15.9" y2="-6.604" width="0.1524" layer="21"/>
<wire x1="15.9" y1="6.477" x2="15.9" y2="-6.604" width="0.1524" layer="21"/>
<wire x1="15.9" y1="6.477" x2="-12.759" y2="6.477" width="0.1524" layer="21"/>
<wire x1="-12.759" y1="-6.604" x2="-12.759" y2="6.477" width="0.1524" layer="21"/>
<wire x1="-10" y1="2.0574" x2="-10" y2="1.1938" width="0.1524" layer="21"/>
<wire x1="-8.1204" y1="1.1938" x2="-8.1204" y2="-1.3208" width="0.254" layer="21"/>
<wire x1="-11.8796" y1="-1.3208" x2="-11.8796" y2="1.1938" width="0.254" layer="21"/>
<wire x1="-11.8796" y1="1.1938" x2="-10" y2="1.1938" width="0.254" layer="21"/>
<wire x1="-10" y1="1.1938" x2="-8.7554" y2="1.1938" width="0.254" layer="21"/>
<wire x1="-11.2446" y1="-1.3208" x2="-11.8796" y2="-1.3208" width="0.254" layer="21"/>
<wire x1="-8.7554" y1="1.1938" x2="-11.2446" y2="-1.3208" width="0.1524" layer="21"/>
<wire x1="-8.7554" y1="1.1938" x2="-8.1204" y2="1.1938" width="0.254" layer="21"/>
<wire x1="-8.1204" y1="-1.3208" x2="-10" y2="-1.3208" width="0.254" layer="21"/>
<wire x1="-10" y1="-1.3208" x2="-10" y2="-1.9304" width="0.1524" layer="21"/>
<wire x1="-10" y1="-1.3208" x2="-11.2446" y2="-1.3208" width="0.254" layer="21"/>
<pad name="8" x="-10" y="3.81" drill="1.3208" diameter="1.9"/>
<pad name="1" x="-10" y="-3.683" drill="1.3208" diameter="1.9"/>
<pad name="6" x="10" y="3.81" drill="1.3208" diameter="1.9"/>
<pad name="4" x="13.5" y="-3.683" drill="1.3208" diameter="1.9"/>
<text x="-13.0175" y="-6.35" size="1.778" layer="25" ratio="10" rot="R90">&gt;NAME</text>
<text x="-6.0325" y="0" size="1.778" layer="27" ratio="10">&gt;VALUE</text>
<wire x1="10.795" y1="-0.3175" x2="13.335" y2="-0.3175" width="0.1524" layer="21"/>
<wire x1="13.335" y1="-0.3175" x2="13.335" y2="-2.2225" width="0.1524" layer="21"/>
<wire x1="9.525" y1="-0.635" x2="10.16" y2="0.9525" width="0.1524" layer="21"/>
<wire x1="10.16" y1="2.2225" x2="10.16" y2="0.9525" width="0.1524" layer="21"/>
<symbol name="K">
<wire x1="-3.81" y1="-1.905" x2="-1.905" y2="-1.905" width="0.254" layer="94"/>
<wire x1="3.81" y1="-1.905" x2="3.81" y2="1.905" width="0.254" layer="94"/>
<wire x1="3.81" y1="1.905" x2="1.905" y2="1.905" width="0.254" layer="94"/>
<wire x1="-3.81" y1="1.905" x2="-3.81" y2="-1.905" width="0.254" layer="94"/>
<wire x1="0" y1="-2.54" x2="0" y2="-1.905" width="0.1524" layer="94"/>
<wire x1="0" y1="-1.905" x2="3.81" y2="-1.905" width="0.254" layer="94"/>
<wire x1="0" y1="2.54" x2="0" y2="1.905" width="0.1524" layer="94"/>
<wire x1="0" y1="1.905" x2="-3.81" y2="1.905" width="0.254" layer="94"/>
<wire x1="-1.905" y1="-1.905" x2="1.905" y2="1.905" width="0.1524" layer="94"/>
<wire x1="-1.905" y1="-1.905" x2="0" y2="-1.905" width="0.254" layer="94"/>
<wire x1="1.905" y1="1.905" x2="0" y2="1.905" width="0.254" layer="94"/>
<text x="1.27" y="2.921" size="1.778" layer="96">&gt;VALUE</text>
<text x="1.27" y="5.08" size="1.778" layer="95">&gt;PART</text>
<pin name="2" x="0" y="-5.08" visible="pad" length="short" direction="pas" rot="R90"/>
<pin name="1" x="0" y="5.08" visible="pad" length="short" direction="pas" rot="R270"/>
<symbol name="S">
<wire x1="0" y1="3.175" x2="0" y2="1.905" width="0.254" layer="94"/>
<wire x1="0" y1="-3.175" x2="0" y2="-1.905" width="0.254" layer="94"/>
<wire x1="0" y1="-1.905" x2="-1.27" y2="1.905" width="0.254" layer="94"/>
<circle x="0" y="-1.905" radius="0.127" width="0.4064" layer="94"/>
<text x="-2.54" y="-2.54" size="1.778" layer="95" rot="R90">&gt;PART</text>
<pin name="P" x="0" y="-5.08" visible="pad" length="short" direction="pas" swaplevel="1" rot="R90"/>
<pin name="S" x="0" y="5.08" visible="pad" length="short" direction="pas" swaplevel="1" rot="R270"/>
<deviceset name="JW1A" prefix="K">
<description>&lt;b&gt;Power relay&lt;/b&gt;&lt;p&gt;
Source: Panasonic Electric Works Co., Ltd. / jw.catalog.pdf</description>
<gate name="_" symbol="K" x="0" y="0" addlevel="must"/>
<gate name="1" symbol="S" x="20.32" y="0" addlevel="always"/>
<device name="" package="JW1A">
<connect gate="1" pin="P" pad="6"/>
<connect gate="1" pin="S" pad="4"/>
<connect gate="_" pin="1" pad="1"/>
<connect gate="_" pin="2" pad="8"/>
<technology name=""/>
<library name="supply2">
<description>&lt;b&gt;Supply Symbols&lt;/b&gt;&lt;p&gt;
GND, VCC, 0V, +5V, -5V, etc.&lt;p&gt;
Please keep in mind, that these devices are necessary for the
automatic wiring of the supply signals.&lt;p&gt;
The pin name defined in the symbol is identical to the net which is to be wired automatically.&lt;p&gt;
In this library the device names are the same as the pin names of the symbols, therefore the correct signal names appear next to the supply symbols in the schematic.&lt;p&gt;
&lt;author&gt;Created by;/author&gt;</description>
<symbol name="+09V">
<wire x1="-0.635" y1="1.27" x2="0.635" y2="1.27" width="0.1524" layer="94"/>
<wire x1="0" y1="0.635" x2="0" y2="1.905" width="0.1524" layer="94"/>
<circle x="0" y="1.27" radius="1.27" width="0.254" layer="94"/>
<text x="-1.905" y="3.175" size="1.778" layer="96">&gt;VALUE</text>
<pin name="+9V" x="0" y="-2.54" visible="off" length="short" direction="sup" rot="R90"/>
<deviceset name="+9V" prefix="SUPPLY">
<description>&lt;b&gt;SUPPLY SYMBOL&lt;/b&gt;</description>
<gate name="G$1" symbol="+09V" x="0" y="0"/>
<device name="">
<technology name=""/>
<class number="0" name="default" width="0" drill="0">
<part name="IC1" library="atmel" deviceset="MEGA8-P" device=""/>
<part name="SP1" library="buzzer" deviceset="KSS1201" device="" value=""/>
<part name="PE1" library="supply1" deviceset="PE" device="" value=""/>
<part name="P+1" library="supply1" deviceset="+5V" device=""/>
<part name="PE2" library="supply1" deviceset="PE" device=""/>
<part name="PE3" library="supply1" deviceset="PE" device=""/>
<part name="T1" library="transistor" deviceset="2N706" device="" value=""/>
<part name="K1" library="relay" deviceset="JW1A" device="" value=""/>
<part name="PE4" library="supply1" deviceset="PE" device="" value=""/>
<part name="SUPPLY1" library="supply2" deviceset="+9V" device=""/>
<part name="P+2" library="supply1" deviceset="VCC" device="" value=""/>
<part name="P+3" library="supply1" deviceset="VCC" device="" value=""/>
<part name="P+4" library="supply1" deviceset="VCC" device="" value=""/>
<part name="P+5" library="supply1" deviceset="VCC" device="" value=""/>
<text x="99.06" y="88.9" size="1.778" layer="91">~120 VAC IN</text>
<text x="99.06" y="66.04" size="1.778" layer="91">~120 VAC OUT</text>
<text x="86.36" y="53.34" size="1.778" layer="91">Optional Light Controller</text>
<text x="-10.16" y="83.82" size="1.778" layer="91"></text>
<instance part="IC1" gate="G$1" x="30.48" y="45.72"/>
<instance part="SP1" gate="1" x="60.96" y="78.74"/>
<instance part="PE1" gate="M" x="66.04" y="76.2"/>
<instance part="P+1" gate="1" x="-2.54" y="38.1" rot="R90"/>
<instance part="PE2" gate="M" x="2.54" y="66.04"/>
<instance part="PE3" gate="M" x="2.54" y="40.64"/>
<instance part="T1" gate="G$1" x="88.9" y="68.58"/>
<instance part="K1" gate="_" x="91.44" y="78.74"/>
<instance part="K1" gate="1" x="104.14" y="78.74"/>
<instance part="PE4" gate="M" x="91.44" y="60.96"/>
<instance part="SUPPLY1" gate="G$1" x="91.44" y="86.36"/>
<instance part="P+2" gate="VCC" x="104.14" y="86.36"/>
<instance part="P+3" gate="VCC" x="109.22" y="86.36"/>
<instance part="P+4" gate="VCC" x="109.22" y="71.12" rot="R180"/>
<instance part="P+5" gate="VCC" x="104.14" y="71.12" rot="R180"/>
<net name="N$1" class="0">
<pinref part="IC1" gate="G$1" pin="PC0(ADC0)"/>
<pinref part="SP1" gate="1" pin="1"/>
<wire x1="55.88" y1="78.74" x2="55.88" y2="73.66" width="0.1524" layer="91"/>
<net name="PE" class="0">
<pinref part="SP1" gate="1" pin="2"/>
<pinref part="PE1" gate="M" pin="PE"/>
<pinref part="PE3" gate="M" pin="PE"/>
<pinref part="IC1" gate="G$1" pin="GND@1"/>
<wire x1="2.54" y1="43.18" x2="7.62" y2="43.18" width="0.1524" layer="91"/>
<pinref part="PE2" gate="M" pin="PE"/>
<pinref part="IC1" gate="G$1" pin="GND"/>
<wire x1="2.54" y1="68.58" x2="7.62" y2="68.58" width="0.1524" layer="91"/>
<pinref part="T1" gate="G$1" pin="E"/>
<pinref part="PE4" gate="M" pin="PE"/>
<net name="+5V" class="0">
<pinref part="P+1" gate="1" pin="+5V"/>
<pinref part="IC1" gate="G$1" pin="VCC@1"/>
<wire x1="0" y1="38.1" x2="7.62" y2="38.1" width="0.1524" layer="91"/>
<net name="N$2" class="0">
<pinref part="T1" gate="G$1" pin="C"/>
<pinref part="K1" gate="_" pin="2"/>
<net name="+9V" class="0">
<pinref part="K1" gate="_" pin="1"/>
<pinref part="SUPPLY1" gate="G$1" pin="+9V"/>
<net name="N$3" class="0">
<pinref part="IC1" gate="G$1" pin="PC2(ADC2)"/>
<pinref part="T1" gate="G$1" pin="B"/>
<wire x1="55.88" y1="68.58" x2="86.36" y2="68.58" width="0.1524" layer="91"/>
<net name="VCC" class="0">
<pinref part="K1" gate="1" pin="S"/>
<pinref part="P+2" gate="VCC" pin="VCC"/>
<wire x1="109.22" y1="83.82" x2="109.22" y2="73.66" width="0.1524" layer="91"/>
<pinref part="P+3" gate="VCC" pin="VCC"/>
<pinref part="P+4" gate="VCC" pin="VCC"/>
<pinref part="K1" gate="1" pin="P"/>
<pinref part="P+5" gate="VCC" pin="VCC"/>
<net name="N$4" class="0">
<pinref part="IC1" gate="G$1" pin="PC3(ADC3)"/>
<wire x1="55.88" y1="66.04" x2="68.58" y2="66.04" width="0.1524" layer="91"/>
<net name="N$5" class="0">
<pinref part="IC1" gate="G$1" pin="PC4(ADC4/SDA)"/>
<wire x1="55.88" y1="63.5" x2="68.58" y2="63.5" width="0.1524" layer="91"/>
<net name="N$6" class="0">
<pinref part="IC1" gate="G$1" pin="PC5(ADC5/SCL)"/>
<wire x1="55.88" y1="60.96" x2="68.58" y2="60.96" width="0.1524" layer="91"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment