1596 views|1 replies

4

Posts

0

Resources
The OP
 

[Zhongke Bluexun AB32VG1 RISC-V board "meets" RTT] GPIO simulation realizes full-color LED lights [Copy link]

 This post was last edited by Chou Didi on 2021-4-16 15:44

1. Development environment:
RT-Thread version: 4.0.3
Operating system: Windows 10
RT-Thread Studio version: 2.1.0

Microcontroller: AB32VG1 (32-bit RISC-V processor)

2. Onboard Introduction

There is little information about the development board. The following figure shows the information obtained through RT-Thread Studio. This article will use GPIO to simulate the control of RGB LED lights to achieve full color control.

IO port corresponding to LED
LED-R PE1
LED-G PE4
LED-B PA2

3. Environment Construction

The construction of the environment mainly involves the installation and package management of RT-Thread Studio, the creation and configuration of the project, and the download of the program. The configuration of the environment is based on the reference of the blog article Environment Construction Reference .

4. Realize full-color LED light flashing

(1) LED lamp circuit diagram

The LED lights are connected with a common anode.

(2) Implementation code

/**Includes*********************************************************************/
#include <rtthread.h>
#include "board.h"

int main(void)
{
uint32_t cnt = 0;

uint8_t pin_r = rt_pin_get("PE.1");
uint8_t pin_g = rt_pin_get("PE.4");
uint8_t pin_b = rt_pin_get("PA.2");


rt_pin_mode(pin_r, PIN_MODE_OUTPUT);
rt_pin_mode(pin_g, PIN_MODE_OUTPUT);
rt_pin_mode(pin_b, PIN_MODE_OUTPUT);


while (1)
{
//红
rt_pin_write(pin_r, PIN_LOW);
rt_pin_write(pin_g, PIN_HIGH);
rt_pin_write(pin_b, PIN_HIGH);
rt_thread_mdelay(1000);

//绿
rt_pin_write(pin_r, PIN_HIGH);
rt_pin_write(pin_g, PIN_LOW);
rt_pin_write(pin_b, PIN_HIGH);
rt_thread_mdelay(1000);

//蓝
rt_pin_write(pin_r, PIN_HIGH);
rt_pin_write(pin_g, PIN_HIGH);
rt_pin_write(pin_b, PIN_LOW);
rt_thread_mdelay(1000);

//黄(红+绿)
rt_pin_write(pin_r, PIN_LOW);
rt_pin_write(pin_g, PIN_LOW);
rt_pin_write(pin_b, PIN_HIGH);
rt_thread_mdelay(1000);

//紫(红+蓝)
rt_pin_write(pin_r, PIN_LOW);
rt_pin_write(pin_g, PIN_HIGH);
rt_pin_write(pin_b, PIN_LOW);
rt_thread_mdelay(1000);

//青(绿+蓝)
rt_pin_write(pin_r, PIN_HIGH);
rt_pin_write(pin_g, PIN_LOW);
rt_pin_write(pin_b, PIN_LOW);
rt_thread_mdelay(1000);

//白(红+绿+蓝)
rt_pin_write(pin_r, PIN_LOW);
rt_pin_write(pin_g, PIN_LOW);
rt_pin_write(pin_b, PIN_LOW);
rt_thread_mdelay(1000);

//黑(全部关闭)
rt_pin_write(pin_r, PIN_HIGH);
rt_pin_write(pin_g, PIN_HIGH);
rt_pin_write(pin_b, PIN_HIGH);
rt_thread_mdelay(1000);
cnt++;

}

return 0;
}

(3) Experimental phenomenon

4c4fad529663f7e9faf84dcd4b8e428a.mp4

2.95 MB, downloads: 0

This post is from Domestic Chip Exchange

Latest reply

nmg
Congratulations, the environment is ready. By the way, how did you get it done in the end?   Details Published on 2021-4-16 16:16
 
 

5213

Posts

239

Resources
2
 

Congratulations, the environment is ready. By the way, how did you get it done in the end?

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list