资料下载地址:STM32+三色LED智能调光系统源程序 易安卓APP 原理图
三色LED手机智能调光系统概述: 单片机源程序如下: |
/* Includes ------------------------------------------------------------------*/
//#include "stm32f0xx.h"
//#include <stdint.h>
#include <stdio.h>
#include "main.h"
#include "FLASH1.h"
#include "UART1.h"
#include "CMD.h"
#include "TIM_1.h"
uint8_t flag=0;
uint8_t kk=0;
void Init_GPIO()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //??LED
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF, &GPIO_InitStructure);
}
void INIT_PWM()
{
LightStu.LightStu=1;
LightStu.PWM1=45;
LightStu.PWM2=45;
LightStu.PWM3=45;
}
int main(void)
{
INIT_PWM();
Init_GPIO();
SysTick_Config(48000);
UART_INIT();
ConnTime=0;
while(ConnTime < 1000); //延时100ms
kk = INIT_8266();
if(kk)
{
while(1); //初始化8266不成功
}
TIM3_INIT();
RX_flag=0;
rxflag=0;
while (1)
{
if(flag)
{
GPIO_SetBits(GPIOF,GPIO_Pin_0);
}
else
{
GPIO_ResetBits(GPIOF,GPIO_Pin_0);
}
// if(flag)
// {
// flag=0;
// //UART1_TX_CHAR("AT\r\n");
// }
if(RX_flag == 1)
{
RX_Data();
RX_flag=0;
rxflag=0;
}
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/