PDF Google Drive Downloader v1.1


Report a problem

Content text KON309E_Experiment2-12.pdf

MICROCONTROLLER SYSTEMS (KON 309E) LABORATORY REPORT Experiment - 2 Team 12 Mert Aşıcı - 30170353 Yunus Emre Çalışkan - 40140330 Atahan Terzi - 40160460 Bünyamin Abay - 40180563 Istanbul Technical University Control & Automation Engineering Department
PART I In the first part of the lab application, our goal is to design a state machine that simulates traffic lights. In this state machine, after the red light is on for 10 seconds at first, the yellow light will turn on for 2 seconds and the green light will be next. If the pedestrian presses the button while the green light is on, the yellow light will turn on for 2 seconds and will switch to the red light. (If the button is pressed while the green light is not on, no change will occur.) Figure 1: Circuit diagram By looking at Figure 1, it can be seen that pins 12,13 and 14 from port B were used for the traffic lights while the button is connected to pin 0 of port A. 100 Ω resistors were used for LED light sources with push-pull output mode and a 10 kΩ resistor was used for the button with pull-down input mode. LEDs were connected to the given pins as in Table 1. 1
Red LED Port B Pin 12 Yellow LED Port B Pin 13 Green LED Port B Pin 14 Table 1: LED ports and pins for Part I Code for Part I #include "stm32f10x.h" // Device header #include "delay.h" // Importing the “delay.h” file // Function prototypes void GPIO_Configuration(void); void EXTI_Configuration(void); void EXTI0_IRQHandler(void); // To extern the variables extern int LED_State, state, flag; extern uint32_t delVar; int LED_State; //The variable used for the turn-on order of the LEDs uint32_t delVar; // delay multiplier, where we determine the delay time int flag = 0; // Variable that specifies how many times the delay multiplier is multiplied // Pin configurations void GPIO_Configuration(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitTypeDef GPIOInitStructure; // Configuration for LEDs // 12 -> RED, 13 -> YELLOW, 14 -> GREEN GPIOInitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14; GPIOInitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIOInitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOB, &GPIOInitStructure); // Configuration for button GPIOInitStructure.GPIO_Pin = GPIO_Pin_0; GPIOInitStructure.GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIOA, &GPIOInitStructure); 2

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.