#include "main.h"

void SystemClock_Config(void);

int main(void)
{
    RCC->AHBENR |= (1 << 17) | (1 << 19); //enabling clock

    GPIOA->MODER &= ~((1 << 1) | (1 << 0)); //setting GPIOA output
    GPIOA->PUPDR &= ~((1 << 1) | (1 << 0)); //no pullup or pulldown
    GPIOA->OSPEEDR |= (1 << 10); //pin speed to high

   GPIOB->MODER &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 0));


    while (1)
    {
        // Read input data from switches
        uint8_t input = (GPIOB->IDR >> 0);

        // Check input value and control RGB LEDs accordingly
        if (input >= 1 && input <= 42)
        {
            GPIOA->ODR = (1 << 0); // Turn on RED LED
        }
        else if (input >= 43 && input <= 84)
        {
            GPIOA->ODR = (1 << 0) | (1 << 1); // Turn on RED and GREEN LED
        }
        else if (input >= 85 && input <= 127)
        {
            GPIOA->ODR = (1 << 1); // Turn on GREEN LED
        }
        else if (input >= 128 && input <= 169)
        {
            GPIOA->ODR = (1 << 1) | (1 << 2); // Turn on GREEN and BLUE LED
        }
        else if (input >= 170 && input <= 212)
        {
            GPIOA->ODR = (1 << 2); // Turn on BLUE LED
        }
        else if (input >= 213 && input <= 254)
        {
            GPIOA->ODR = (1 << 0) | (1 << 2); // Turn on BLUE and RED LED
        }
        else if (input == 0 || input == 255)
        {
            GPIOA->ODR = (1 << 0) | (1 << 1) | (1 << 2); // Turn on all three colors
        }
        el