1、最近比较忙,加班累成狗
2、初步学习单片机KEIL啥都不会,引脚都看不懂。
3、忙到最近终于看懂了一些
4、讲基本的流水灯程序作了简单的修改
由于用户按键是PA0,定义了一下
/* defined the LED2 pin: PD13 */
#define LED2_PIN GET_PIN(D, 13)
/* defined the LED3 pin: PD14 */
#define LED3_PIN GET_PIN(D, 14)
/* defined the LED4 pin: PD15 */
#define LED4_PIN GET_PIN(D, 15)
/* defined the USER pin: PA0 */
#define USER_PIN GET_PIN(A, 0)
int asd=0;
int main(void)
{
uint32_t Speed = 300;
/* set LED2 pin mode to output */
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
/* set LED3 pin mode to output */
rt_pin_mode(LED3_PIN, PIN_MODE_OUTPUT);
/* set LED4 pin mode to output */
rt_pin_mode(LED4_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(USER_PIN, PIN_MODE_INPUT);
// asd = USER_PIN;
while (1)
{
asd = rt_pin_read(USER_PIN);
if(asd ==1)
{
rt_pin_write(LED2_PIN, PIN_LOW);
rt_thread_mdelay(Speed);
rt_pin_write(LED3_PIN, PIN_LOW);
rt_thread_mdelay(Speed);
rt_pin_write(LED4_PIN, PIN_LOW);
rt_thread_mdelay(Speed);
rt_pin_write(LED2_PIN, PIN_HIGH);
rt_thread_mdelay(Speed);
rt_pin_write(LED3_PIN, PIN_HIGH);
rt_thread_mdelay(Speed);
rt_pin_write(LED4_PIN, PIN_HIGH);
rt_thread_mdelay(Speed);
}
}
就是让按键按下的时候流水灯才正常跑,之前两个红色标注的地方不对,一个是定义错误,一个是定义了上拉输入,导致弄了半天程序也不对,希望看到的同学少走弯路 |