From b85b77b88d79298025f0eff2163d23667d075cde Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 31 Oct 2023 11:24:34 +0100 Subject: [PATCH] button pwm --- btn-pwm/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ buttons/main.c | 1 - 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 btn-pwm/main.c 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<