Heartbeat LED
A very nice illumination effect is the Heratbeat effect. The following Software enables an Atmel Controller (typically Tiny12) to pulsate LED's connected to it. This is a really hypnotizing effect, suited well for case Modding and RC Model DIY. Maybe you want to illuminate your CPU with this Eyecatcher!

You could use this this circuit circuit to obtain a very small PCB that can be used nearly everywhere.

To download the Source Code, follow this link.

The Program is very straightforward, but some of the techniques shown can be ust in larger projects.

Reading of the EEPROM



The Main Loop only generates a Software PWM Signal.

The Timer Interrupt changes the brightnes between a minimum and a maximum, with different speed, creating a very realistic Heartbeat effect!

Program developed with AVR Studio 4.10.

When programming, store the OSCCAL-Value in EEPROM-Cell $3f !

;Hearbeat LED

;(C) 2004 Markus Vohburger

;Gewerbliche Nutzung untersagt.


;Registerdefinitionen für Tiny12 ladan

.include "tn12def.inc"

.def temp1 = r16

.def temp2 = r17

.def output = r18


.def swcount = r19

.def output = r20

;Zähler für PWM

.def pwmcount = r21

;Richtung heller oder dunkler

.def direction = r25

;Wert für PWM

.def pwmvalue = r27

;Kalibrierbyte für internen Oszillator ist in EEPROM $3f gespeichert

.equ EE_OSCCAL= $3f;


.org $0000

rjmp main

;Timer 0 Overflow Interrupt Vektor

;timer overflow interrut handler

.org OVF0Addr

rjmp OVF0Handler

;Hauptprogramm beginnt hier

.org $0010


;set internal osc cal

ldi temp1,EE_OSCCAL

rcall readeeprom

out osccal,temp1

;Ports Setup

ldi temp1,$1f

out ddrb,temp1

ldi temp1,$1f

out portb,temp1

clr pwmcount

clr pwmvalue

clr direction

;Timer zurücksetzen

clr temp1

out tcnt0,temp1

;Timer interrupts an

ldi temp1,(1<<toie0)

out timsk,temp1

;Timer starten

ldi temp1,$02

out tccr0,temp1

ldi swcount,0


;hauptschleife, implementiert die PWM


;leds aus

ldi output,$1f


cp pwmvalue,pwmcount

brsh writeoutput

;leds an (PB0 bis PB2)

andi output,$18


out portb,output

inc pwmcount

rjmp loop

;subroutine zum Lesen aus EEprom


sbic eecr,eewe

rjmp readeeprom

out eear,temp1

in temp1,eedr


;Timer 0 Interrupthandler


;statusregister sichern

in r1,sreg

;Softwarezähler erhöhen

inc swcount

cpi swcount,$04

brlo exit_ovf0handler

clr swcount

cpi direction,$00

breq dodec

;pwmwert erhöhen


inc pwmvalue

cpi pwmvalue,$80

brlo exit_ovf0handler

clr direction

ldi pwmvalue,$80

rjmp exit_ovf0handler

;pwmwert verringern

;das Verringern geschieht doppelt so schnell wie das Erhöhen, um den Effekt zu verbessern


dec pwmvalue

dec pwmvalue

cpi pwmvalue,$01

brsh exit_ovf0handler

ldi pwmvalue,$01

ldi direction,$01

;ende der Timer 0 Interrupt Routine


out sreg,r1


Additional Information,Basics,DIY Kit, Links for Schematic
Sponsored Ads:

You are Visitor Nr. 183900