Bu yazımızda STM32VLDiscovery ile yaklaşık 1 saniye süreyle yanıp sönen LED uygulaması yapacağız.
LED Yakmak İçin Gereken Devre
LED Yakma (Blink) Kodu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include "stm32f10x.h" // Device header #include "stm32f10x_gpio.h" // Keil::Device:StdPeriph Drivers:GPIO #include "stm32f10x_rcc.h" // Keil::Device:StdPeriph Drivers:RCC void delay(uint32_t time); int main(){ GPIO_InitTypeDef GPIO_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStruct); while(1){ GPIO_SetBits(GPIOB, GPIO_Pin_0); delay(3000000); GPIO_ResetBits(GPIOB, GPIO_Pin_0); delay(3000000); } } void delay(uint32_t time){ while(time--); } |
Gerekli Malzemeler
- STM32VLDISCOVERY (STM32F100RB)
- Breadboard
- LED
- 220 veya 330 Ω direnç
- Jumper kablo