|
<
媒介:
正在前里的根底上,将传感器的管足初初化,读与传感器形态,写逻辑停止掌握。该传感器返回数字旌旗灯号(0/1)。
1、4种输进形式:
输进浮空 输进上推 输进下推 模仿输进
因为传感器返回的是0/1形态,接纳输进上推形式。
2、电路图:
3、查阅相干脚册
四个管足出有出格功用。
4、中减代码
main.c
- #include "motor.h"
- #include "stdio.h"
- #include "delay.h"
- #include "stm32f10x.h"
- #include "followline.h"
- u8 UART3_data,UART1_data;
- u8 UART3_rcv[20],UART3_rcv_count;
- u8 UART1_rcv[50],UART1_rcv_count,Uart1_finish;
- int main(void)
- {
- delay_init();
- GPIO_init();
- followline_init();
- TIME4_init(7199,10);
- while(1)
- {
- if(right_2)
- {
- car_go(5);
- }
- else
- {
- car_stop();
- }
- }
- }
复造代码 followline.c
- #include "followline.h"
- void followline_init(void)
- {
-
- //界说管足的构造体
- GPIO_InitTypeDef GPIO_InitStruct_C,GPIO_InitStruct_B;
-
- //设置PC15\14\13管足的参数,用于驱动机电
- GPIO_InitStruct_C.GPIO_Mode=GPIO_Mode_IPU;
- GPIO_InitStruct_C.GPIO_Pin=GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_13;
-
- //设置PB12管足的参数,用于驱动机电
- GPIO_InitStruct_C.GPIO_Mode=GPIO_Mode_IPU;
- GPIO_InitStruct_C.GPIO_Pin=GPIO_Pin_12;
-
- GPIO_Init(GPIOC, &GPIO_InitStruct_B);
- GPIO_Init(GPIOB, &GPIO_InitStruct_C);
- }
复造代码 follow.h
- #ifndef __FOLLOWLINE_H__
- #define __FOLLOWLINE_H__
- #include "stm32f10x_gpio.h"
- #define right_2 GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_12)
- #define right_1 GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_15)
- #define left_2 GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_14)
- #define left_1 GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13)
- void followline_init(void);
-
- #endif
复造代码
免责声明:假如进犯了您的权益,请联络站少,我们会实时删除侵权内乱容,感谢协作! |
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,按照目前互联网开放的原则,我们将在不通知作者的情况下,转载文章;如果原文明确注明“禁止转载”,我们一定不会转载。如果我们转载的文章不符合作者的版权声明或者作者不想让我们转载您的文章的话,请您发送邮箱:Cdnjson@163.com提供相关证明,我们将积极配合您!
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并自负版权等法律责任。
|