Arduino框架下联盛德W801实现流水灯示例
- 📺🎬🎞📽效果演示:
- 📌Hi-LinkDuino/w80x_arduino固件平台(不推荐)
https://github.com/Hi-LinkDuino/w80x_arduino
- 📌board707/w80x_arduino固件平台(推荐)
https://kgithub.com/board707/w80x_arduino
🛠相关配置
-
- 🌿Hi-LinkDuino/w80x_arduino固件平台
- 🌿Hi-LinkDuino/w80x_arduino固件平台
-
- 🌿board707/w80x_arduino固件平台
- 🌿board707/w80x_arduino固件平台
🚩烧录注意事项
-
(基于Hi-LinkDuino/w80x_arduino固件平台使用),当点击上传按键后,下面的信息框里面出现
wait serial sync......
时,按一下板子上的Reset
按键,即可开始烧录程序。
-
🔰烧录完成后需要再一次按一下Reset复位按键,程序才会跑起来。
- ✨在board707/w80x_arduino固件平台不需要以上这些操作。
📝流水灯示例代码
- ⚡注意这是在基于
Hi-LinkDuino \w80x_arduino
固件平台代码
#include <stdio.h>
#include <Arduino.h>
//#include "wm_hal.h"
static volatile uint8_t led_flag = 0;
uint8_t Pin[]={PB5,PB25,PB26,PB18,PB17,PB16,PB11};
void setup() {
// put your setup code here, to run once:
printf("Led Demo\r\n");
for(int i=0;i<7;i++)
{
pinMode(Pin[i], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
if(!led_flag)
{
for(uint8_t i=0;i<7;i++)
{
digitalWrite(Pin[i], (GPIO_PinState)1);
HAL_Delay(200);
}
led_flag =1;
}
else
{
for(uint8_t j=7;j>0;j--)
{
digitalWrite(Pin[j-1], (GPIO_PinState)0);
HAL_Delay(200);
}
led_flag =0;
}
}
- 🏳🌈注意这是在基于
board707/w80x_arduino
固件平台代码
#include <stdio.h>
#include <Arduino.h>
//int led = LED_BUILTIN_1;//W801 :LED_BUILTIN_1 - LED_BUILTIN_7
static volatile bool led_flag = 0;
uint8_t Pin[] = {PB5, PB25, PB26, PB18, PB17, PB16, PB11};
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
Serial.begin(115200);
Serial.printf("Led Demo\r\n");
for (int i = 0; i < 7; i++)
{
pinMode(Pin[i], OUTPUT);
}
}
// the loop routine runs over and over again forever:
void loop() {
static uint8_t cnt = 0;
Serial.printf("cnt:%d \n", cnt);
if (!led_flag)
{
for (uint8_t i = 0; i < 7; i++)
{
digitalWrite(Pin[i], HIGH);
delay (200);
}
led_flag = 1;
}
else
{
for (uint8_t j = 7; j > 0; j--)
{
digitalWrite(Pin[j - 1], LOW);
delay (200);
}
led_flag = 0;
}
cnt++;
}