Question
Lab3_4.c : Modify Lab3_3.c code such that the four lights will continuously toggle until the USER button is pressed. The four lights will start toggling
Lab3_4.c
: Modify Lab3_3.c code such that the four lights will continuously toggle until the USER
button is pressed. The four lights will start toggling again once the USER button is pressed again. This behavior should repeat all the time.
Lab3_3.c code:
#define GREEN_LED 12
#define ORANGE_LED 13
#define RED_LED 14
#define BLUE_LED 15
#define PUSH_BUTTON 0
#include "stm32f4xx.h"
int main(void)
{
RCC -> AHB1ENR |= (1<<3 | 1<<0);
int i;
int j;
for (i= GREEN_LED; i <= BLUE_LED; i++)
{
GPIOD -> MODER |= (1<<(2*i));
GPIOD -> MODER &=~ (1<<(2*i+1));
GPIOD -> PUPDR &=~ (1<<(2*i) | 1<<(2*i+1));
GPIOD -> OTYPER &=~ (1<
}
GPIOA -> MODER &=~(1<<(2*PUSH_BUTTON)| 1<<(2*PUSH_BUTTON+1));
i =0;
while(i<1)
{
while (((GPIOA -> IDR)&(1< { } if (((GPIOA -> IDR)&(1< { GPIOD -> ODR |= (1< GPIOD -> ODR |= (1< GPIOD -> ODR |= (1< GPIOD -> ODR |= (1< } else { GPIOD -> ODR &=~ (1< GPIOD -> ODR &=~ (1< GPIOD -> ODR &=~ (1< GPIOD -> ODR &=~ (1< } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started