Skip to content

Instantly share code, notes, and snippets.

@szczys
szczys / atmega168-analog-comparator.c
Created December 3, 2011 22:56
ATmega168 Analog Comparator example
/*
AVR ATmega168 Analog Comparator Demonstration
by Mike Szczys
I'm using a voltage divider with a photoresistor on
PC6 and a voltage divider with equal values on PC7
to yield a 2.5V reference signal.
The analog comparator is set to throw an interrupt
whenever there is a zero crossing. I then check the
@szczys
szczys / avr-asm-delay.S
Created July 6, 2011 16:19
AVR assembler delay routine
;Begin delaying
LDI ZH,0xFF ;Set high byte
LDI ZL,0xFF ;Set low byte
DelayLoop:
SBIW ZL,1 ;subtract one from word
BRNE DelayLoop ;Branch back to DelayLoop unless zero flag was set
;Go on with the rest of life