WeChat_20230609232735
接上篇:【英飞凌PSoC 6 RTT开发板试用】机器人机械臂控制原创开源(1) 开箱(产品介绍) - RT-Thread嵌入式技术论坛 - 电子技术论坛 - 广受欢迎的专业电子论坛! https://bbs.elecfans.com/jishu_2361912_1_1.html
源代码:
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_gpio.h"
#define D2_PIN GET_PIN(5, 0)
#define D3_PIN GET_PIN(5, 1)
#define D6_PIN GET_PIN(11, 4)
#define D7_PIN GET_PIN(11, 5)
#define D8_PIN GET_PIN(5, 6)
int main(void)
{
int v ;
rt_pin_mode(D2_PIN , PIN_MODE_OUTPUT);
rt_pin_mode(D3_PIN , PIN_MODE_OUTPUT);
rt_pin_mode(D8_PIN , PIN_MODE_OUTPUT);
rt_pin_mode(D6_PIN , PIN_MODE_OUTPUT);
rt_pin_mode(D7_PIN , PIN_MODE_OUTPUT);
for (;;)
{
rt_pin_write(D8_PIN, PIN_HIGH);
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D6_PIN, PIN_HIGH);
rt_thread_mdelay(1);
rt_pin_write(D6_PIN, PIN_LOW);
rt_thread_mdelay(19);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D7_PIN, PIN_HIGH);
rt_thread_mdelay(1);
rt_pin_write(D7_PIN, PIN_LOW);
rt_thread_mdelay(19);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D2_PIN, PIN_HIGH);
rt_thread_mdelay(1);
rt_pin_write(D2_PIN, PIN_LOW);
rt_thread_mdelay(19);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D3_PIN, PIN_HIGH);
rt_thread_mdelay(1);
rt_pin_write(D3_PIN, PIN_LOW);
rt_thread_mdelay(19);
}
rt_pin_write(D8_PIN, PIN_LOW);
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D2_PIN, PIN_HIGH);
rt_thread_mdelay(2);
rt_pin_write(D2_PIN, PIN_LOW);
rt_thread_mdelay(18);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D3_PIN, PIN_HIGH);
rt_thread_mdelay(2);
rt_pin_write(D3_PIN, PIN_LOW);
rt_thread_mdelay(18);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D6_PIN, PIN_HIGH);
rt_thread_mdelay(2);
rt_pin_write(D6_PIN, PIN_LOW);
rt_thread_mdelay(18);
}
for ( v = 80 ; v > 60 ; v-- )
{
rt_pin_write(D7_PIN, PIN_HIGH);
rt_thread_mdelay(2);
rt_pin_write(D7_PIN, PIN_LOW);
rt_thread_mdelay(18);
}
}
}
英飞凌PSoc62
|