From 2a3f7c514b1bf8a0e08c9448fc81410b83de69c5 Mon Sep 17 00:00:00 2001 From: sowgro Date: Thu, 23 Oct 2025 15:20:24 -0400 Subject: push activity 9 --- project/Core/Src/Activties/activity9.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 project/Core/Src/Activties/activity9.c (limited to 'project/Core/Src/Activties') diff --git a/project/Core/Src/Activties/activity9.c b/project/Core/Src/Activties/activity9.c new file mode 100644 index 0000000..c9f6569 --- /dev/null +++ b/project/Core/Src/Activties/activity9.c @@ -0,0 +1,32 @@ +/* + * activity9.c + * + * Created on: Oct 23, 2025 + * Author: sowgro + */ + +#include "GPIO.h" +#include +#include "stm32l4xx.h" +#include "LED.h" +#include + +// write a function that prints on/off when the blue button is pressed + +void activity9_run() { + GPIO_Init(); + int prev_status = -1; + for (;;) { + int status = !GPIOC->IDR; + if (status != prev_status) { + prev_status = status; + if (status) { + printf("on\r\n"); + LED_On(); + } else { + printf("off\r\n"); + LED_Off(); + } + } + } +} -- cgit v1.2.3