Team Updates

int a;int b;int d;int x=0;int y=0;
void read1(){TMR1H = 0;TMR1L = 0;
PORTa.F6 = 1;Delay_us(10);PORTa.F6 = 0;
while(!PORTa.F7);T1CON.F0 = 1;while(PORTa.F7);T1CON.F0 = 0;
a = (TMR1L | (TMR1H<<8));a = a/34;a = a + (a/5);
if(a<11){a=a+1;}else a=a;}
void read2(){TMR1H = 0;TMR1L = 0;
PORTa.F1 = 1;Delay_us(10);PORTa.F1 = 0;
while(!PORTa.F0);T1CON.F0 = 1;while(PORTa.F0);T1CON.F0 = 0;
b = (TMR1L | (TMR1H<<8));b = b/34;b = b + (b/5);
if(b<11){b=b+1;}else b=b;}
void read3(){TMR1H = 0;TMR1L = 0;
PORTa.F2 = 1;Delay_us(10);PORTa.F2 = 0;
while(!PORTa.F3);T1CON.F0 = 1; while(PORTa.F3);T1CON.F0 = 0;
d = (TMR1L | (TMR1H<<8));d = d/34;d = d + (d/5); if(d<11){d=d+1;}else d=d;}
void main()
{ cmcon=7; T1CON = 0x10; TRISB = 0b00000000; TRISa = 0b10001001; porta=0; portb=0;delay_ms(100);
loop:
read2();x=b;delay_ms(200); read2();y=b;
b=(x-y);
if( b>=14){portb.f0=1;read1();read3();
if(a>=d){portb.f7=1;portb.f4=1;delay_ms(200);portb.f7=0;portb.f4=0;}
if(d>=a){portb.f1=1;portb.f3=1;delay_ms(200);portb.f1=0;portb.f3=0;}
}
if( b<=10){portb.f0=0;}
goto loop;
}
view raw Car program 2. hosted with ❤ by GitHub
samahadhodSama Hadhod
Floating system.
Floating system.
samahadhodSama Hadhod
Automatic control system.
Automatic control system.
samahadhodSama Hadhod
communication system.
communication system.
samahadhodSama Hadhod
Car speed system; An image of how we will control the speed of the car.
Car speed system; An image of how we will control the speed of the car.
samahadhodSama Hadhod
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
char hs; char duty1; char duty2;char x=0;
void main() {
adcon1=7;
trisa=0b00111101;trisb=0b10000000;trisc=0b00000000;trisd=0b00000000;
porta=0;portb=0;portc=0;portd=0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
PWM1_Init(5000); // Initialize PWModule at 5KHz
PWM2_Init(5000);
PWM1_Start(); // start PWM1
PWM2_Start(); // start PWM2
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,4,"salvum car");
Lcd_Out(2,3,"sama+haneen");
delay_ms(4000);
Lcd_Cmd(_LCD_CLEAR);
loop:
if (UART1_Data_Ready()) {hs = UART1_Read();}
if(hs==48){PWM1_Set_Duty(0);PWM2_Set_Duty(0);}
if(hs==49){PWM1_Set_Duty(150);PWM2_Set_Duty(150);}
if(hs==50){PWM1_Set_Duty(150);PWM2_Set_Duty(150);}
if(hs==51){PWM1_Set_Duty(175);PWM2_Set_Duty(175);}
if(hs==52){PWM1_Set_Duty(175);PWM2_Set_Duty(175);}
if(hs==53){PWM1_Set_Duty(200);PWM2_Set_Duty(200);}
if(hs==54){PWM1_Set_Duty(200);PWM2_Set_Duty(200);}
if(hs==55){PWM1_Set_Duty(225);PWM2_Set_Duty(225);}
if(hs==56){PWM1_Set_Duty(225);PWM2_Set_Duty(225);}
if(hs==57){PWM1_Set_Duty(255);PWM2_Set_Duty(255);}
if(hs=='q'){PWM1_Set_Duty(255);PWM2_Set_Duty(255);}
if(hs=='F'){portd.f0=1;portd.f2=1; }
if(hs=='B'){portd.f1=1;portd.f3=1; }
if(hs=='R'){portd.f0=1;portd.f3=1; }
if(hs=='L'){portd.f1=1;portd.f2=1; }
if(hs=='S'){portd.f0=0;portd.f1=0;portd.f2=0;portd.f3=0;delay_ms(5); }
if(hs=='W'){portd.f6=1;}
if(hs=='w'){portd.f6=0;}
if(hs=='U'){portd.f5=1;}
if(hs=='u'){portd.f5=0;}
if(hs=='V'){portd.f4=1;}
if(hs=='v'){portd.f4=0;}
if(hs=='o'){loop5:
if(porta.f0==1){portd.f1=1;portd.f2=1;delay_ms(200);portd.f2=0;portd.f1=0;delay_ms(200);}
if(portb.f7==1){portd.f0=1;portd.f3=1;delay_ms(200);portd.f0=0;portd.f3=0;delay_ms(200);}
if (UART1_Data_Ready()) {hs = UART1_Read();}
if(hs=='y'){goto loop;}
goto loop5;
}
if(hs=='X'){while(porta.f2==0){PWM1_Set_Duty(255);PWM2_Set_Duty(255);portd.f0=1;portd.f2=1;}
loop2:
PWM1_Set_Duty(125);PWM2_Set_Duty(125);
if (UART1_Data_Ready()) {hs = UART1_Read();}
if(hs=='x')
{portd.f0=0;portd.f1=0;portd.f2=0;portd.f3=0;delay_ms(5);PWM1_Set_Duty(255);PWM2_Set_Duty(255);delay_ms(200);goto loop; }
goto loop2;
}
if(porta.f3==1){PWM1_Set_Duty(125);PWM2_Set_Duty(125);
for(x=0;x<5;x++){portd.f4=1;portd.f5=1;portd.f6=1;delay_ms(150);portd.f4=0;portd.f5=0;portd.f6=0;delay_ms(150);}
portd.f0=0;portd.f1=0;portd.f2=0;portd.f3=0;delay_ms(3000);
PWM1_Set_Duty(255);PWM2_Set_Duty(255);}
goto loop;
}
view raw Car program. hosted with ❤ by GitHub
samahadhodSama Hadhod
NASA Logo

SpaceApps is a NASA incubator innovation program.