平头哥CDK W806-KIT单片机技术交流组
直播中

jf_73431417

3年用户 11经验值
擅长:嵌入式技术
私信 关注

【联盛德W806-KIT开发板试用体验】w806(基于Arduino)——点亮LED灯

一、搭建Arduino环境1、安装Arduino IDE1)下载Arduino IDE
Arduino官网地址:Arduino Docs | Arduino Documentation | Arduino Documentation
2)安装Arduino IDE
打开安装包一路next即可。
2、在Arduino IDE上安装W806库1)添加开发板管理器网址
打开Arduino IDE,依次打开 文件 -> 首选项,在“附加开发板管理器网址”一栏添加以下网址。
https://cdn.jsdelivr.net/gh/Hi-LinkDuino/w80x_arduino/package_w80x_proxy_index.json
2)重新启动Arduino IDE
添加网址之后关闭Arduino IDE,再重新打开。
3)下载安装W806库
依次打开 工具 -> 开发板-> 开发板管理器,找到w80x_duino并安装(可以通过搜索快速找到)。

下载安装完成之后就能看到W806的库了。使用的时候最好先重新启动一下Arduino IDE。


二、编写代码#include #include //#include "wm_hal.h"static volatile uint8_t key_flag = 0;static void GPIO_Init(void){    GPIO_InitTypeDef GPIO_InitStruct = {0};    __HAL_RCC_GPIO_CLK_ENABLE();    GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2;    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT;    GPIO_InitStruct.Pull = GPIO_NOPULL;    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_PIN_SET);    GPIO_InitStruct.Pin = GPIO_PIN_5;    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;    GPIO_InitStruct.Pull = GPIO_PULLUP;    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);    HAL_NVIC_SetPriority(GPIOB_IRQn, 0);    HAL_NVIC_EnableIRQ(GPIOB_IRQn);}void setup() {  // put your setup code here, to run once:    printf("Led Demorn");    HAL_Init();    GPIO_Init();}void loop() {   // put your main code here, to run repeatedly:    HAL_Delay(500);    key_flag++;        if (key_flag % 3 == 0)    {        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)0);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)1);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)1);    }    else if (key_flag % 3 == 1)    {        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)1);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)0);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)1);    }    else    {        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)1);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)1);        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)0);    }}
三、编译烧录并运行1)连接板子
根据自己的板子连接好电源和串口,并在Arduino IDE上面选择设备对于的端口号。


2)烧录程序上传
点击“上传”按键,上传的过程中按提示按主板上的复位键即可下载,等待右下角进度条结束即可完成烧录。

3)运行结果




  • mmexport1641805926320.png
  • mmexport1641805926320.png

回帖(2)

Williamzs

2022-2-15 21:48:38
安装库的时候出错了,什么原因?见以下图片
win10专业版
举报
  • arduino_W801Err.png

Williamzs

2022-2-20 17:00:44
将这个地址 打开
https://cdn.jsdelivr.net/gh/Hi-L ... 0x_proxy_index.json

发现这个json文件中有这个地址:
"url": "https://github.com.cnpmjs.org/Hi-LinkDuino/w80x_arduino/releases/download/v0.0.1/w80x_arduino-0.0.1.zip",
这个地址是不对的,改为
"url": "https://github.com/Hi-LinkDuino/w80x_arduino/releases/download/v0.0.1/w80x_arduino-0.0.1.zip",
试 过 好 几次,不知道怎么成功了,下载了这个zip包,再研究一下怎 么 自 行 arduino的 库文件 包 吧,应该就可以用了
举报

更多回帖

发帖
×
20
完善资料,
赚取积分