Push Button dan LED untuk STM32F103C8T6 Pada Keil
How to Configure Push Button and LED for STM32 in Keil
Source Code:
#include "stm32f10x.h"
int main(void){
// Push button PIN C 15
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitTypeDef PB;
PB.GPIO_Pin = GPIO_Pin_15;
PB.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOC, &PB);
// LED PIN B 12
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitTypeDef LED;
LED.GPIO_Pin = GPIO_Pin_12;
LED.GPIO_Mode = GPIO_Mode_Out_PP;
LED.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &LED);
while(1){
if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_15) == 0)
{
GPIO_WriteBit(GPIOB, GPIO_Pin_12, Bit_SET);}
else{
GPIO_WriteBit(GPIOB, GPIO_Pin_12, Bit_RESET);}
}
}
untuk lihat videonya :
video by : Robotik ID
0 Comments