1.代码
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include "stm32f10x.h"
void Delay(unsigned int count) { unsigned int i; for(;count!=0;count--) { i = 5000; while(i--); } } unsigned int i; int main(void) { GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB, GPIO_Pin_5 | GPIO_Pin_8);
while (1) { if(i%6!=0) { GPIO_ResetBits(GPIOB, GPIO_Pin_5); Delay(10); GPIO_SetBits(GPIOB, GPIO_Pin_5); Delay(10); i++; } else { GPIO_ResetBits(GPIOB, GPIO_Pin_8); Delay(100); GPIO_SetBits(GPIOB, GPIO_Pin_8); Delay(100); i++; } } }
|
2.模拟图

代码下载链接(123云盘):https://www.123684.com/s/wFuijv-i8Zgh