diff --git a/btn-pwm/main.c b/btn-pwm/main.c new file mode 100644 index 0000000..4ea1b37 --- /dev/null +++ b/btn-pwm/main.c @@ -0,0 +1,57 @@ +/* + * Use the timers pwm to dim a light on demand. + */ +#define F_CPU 16000000UL +#define __AVR_ATmega328P__ +#include +#include +#include + +#define PWM_LOW 24 +#define PWM_HIGH 192 + +int state = 0; + +// code for INT0 +ISR(INT0_vect) { + OCR0A = PWM_HIGH; // max value for timer + PORTB |= (1<