AUTOMATIC BRAKE SYSTEM

Photo of author

By Jackson Taylor

YouTube video
PROGRAM  int c1=0,speed;  char distance[8];  void usinit(void);  void uscheck(void); // LCD module connections sbit LCD_RS at RD2_bit; sbit LCD_EN at RD3_bit; sbit LCD_D4 at RD4_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D7 at RD7_bit; sbit LCD_RS_Direction at TRISD2_bit; sbit LCD_EN_Direction at TRISD3_bit; sbit LCD_D4_Direction at TRISD4_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D7_Direction at TRISD7_bit; // End LCD module connections void InitMain() { PWM1_Init(5000); PWM2_Init(5000); } void main(){ trisc.f3=0;  trisc.f0=0;   portc.f0=0;  portc.f3=0;      InitMain();      PWM1_Start();      PWM2_Start();   Lcd_Init();                        // Initialize LCD   Lcd_Cmd(_LCD_CLEAR);               // Clear display   Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off   usinit();   adcon1=7;   trise.f2=0;   trisc.f3=0;  trisc.f0=0;   portc.f0=0;  portc.f3=0;   trisb.f7=0;  portb.f7=0;   while(1)   {       uscheck();   Lcd_Cmd(_LCD_CLEAR);           Lcd_Out(2,1,”DISTANCE=”);          Lcd_Out_cp(distance);            if(c1<30){porte.f2=1;portb.f7=0; Lcd_Out(1,1,”OBSTACLE CLOSER”);} else { porte.f2=0;  portb.f7=1; }            speed=c1*4;            if (speed>255) speed=255;            PWM1_Set_Duty(speed); PWM2_Set_Duty(speed);   } } void uscheck(void) {  portb.f2=1  ;   delay_us(10);    portb.f2=0  ;    while(!portb.f3);    c1=0;    while(portb.f3) {c1++;  delay_us(58); }        // 1CM ==58US       IntToStr(c1, distance);       delay_ms(200); } void usinit(void) {       trisb.f3=1; //echoPin       trisb.f2=0;   //trigPin } CIRCUIT
See also
CD4066B Quad Bilateral Switch