基于STM32的DIY作品——表情包盒

创作过程及功能演示:

基于stm32的DIY作品——表情包盒_哔哩哔哩_bilibili

(三连三连三连0^0重要的话说三遍)

部分代码:

main.c

#include "stm32f10x.h"                  // Device header
#include "OLED.H"
#include "PWM.H"
#include "Delay.h"
#include "Servo.h"
#include "key.h"
#include "Timer.h"
#include "Servo.h"

uint8_t i;
uint8_t time;
uint8_t KeyNum;
uint8_t Servo_time;

int main(void)
{
	OLED_Init();
	PWM_Init();
	Timer_Init();
	key_Init();
	OLED_Clear();
	Servo_SetAngle(78);
	//Servo_SetAngle(115);
	while(1)
	{
		if(i == 0)
		{
			if(KeyNum == 1)
			{
				Servo_SetAngle(115);
				OLED_BMP(7);
				Delay_ms(500);
				OLED_Clear();
				Delay_ms(500);
				OLED_BMP(7);
				Delay_ms(500);
				OLED_Clear();
				Delay_ms(500);
				OLED_BMP(7);
				Delay_ms(1000);
				Servo_Control_Speed(115,78);
				OLED_Clear();
				i++;
			}
		}
		else if(i == 1)
		{
			if(KeyNum == 1)
			{
				Servo_SetAngle(115);
				OLED_BMP(7);
				Delay_ms(300);
				OLED_Clear();
				Delay_ms(300);
				OLED_BMP(7);
				Delay_ms(1500);
				OLED_BMP(8);
				Delay_ms(1500);
				Servo_SetAngle(78);
				OLED_Clear();
				i ++;
			}
		}
		else if(i == 2)
		{
			if(KeyNum == 1)
			{
				Servo_SetAngle(115);
				OLED_BMP(5);
				Delay_ms(3000);
				Servo_Control_Speed(115,78);
				OLED_Clear();
				i = 0;
			}
		}
		
	}
}


//void Servo_Delay(uint8_t TIME)
//{
//	Servo_time++;
//	if(Servo_time==5)
//	{
//		Servo_SetAngle(i);
//		Servo_time=0;
//	}
//}

void TIM3_IRQHandler(void)//定时器的中断,不是编码器的中断,编码器的要自己测速
{
	if(TIM_GetITStatus(TIM3,TIM_IT_Update)==SET)
	{
		time++;
		if(time==5)
		{
			KeyNum = keynum_get();
            time=0;
        }
		TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
	}
}

全套资源:

百度网盘链接:https://pan.baidu.com/s/14wJvLBdRrVVYME2wJ0vKCQ?pwd=pjlm 
提取码:pjlm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值