void main(void) { Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Init_Interrupts(); TimeMsec = RESET_TIME; Init_Timers(); // Initialize Timers Init_LCD(); // Initialize LCD // "0123456789abcdef" display_1 = " Homework 9 "; display_2 = " "; Display_Process(); /* ---------- Begining of the "While" Operating System ------------- */ while(ALWAYS) // Can the Operating system run { ADC_Process(); Control_Process(); Menu_Process(); if(TimeMsec % EVERY_50 == RESET_TIME) { Display_Process(); } } }
void printMacAddress(void){ if(macFG==TRUE && UCA1BRW == 52){ //when mac address needed, will take from buffer, and print to screen. while(IOTBufferReceive[37]=='\0'); //wait until all received for(i=21;i<=28;i++){ //capture first half of MAC address firstMacBuff[i-21]=IOTBufferReceive[i]; } for(i=30;i<=37;i++){ //capture second half of MAC address secondMacBuff[i-30]=IOTBufferReceive[i]; } lcd_4line(); display_1="Mac Addr:"; macPtr=firstMacBuff; display_2=macPtr; macPtr=secondMacBuff; display_3=macPtr; display_4=" "; Display_Process(); macFG=FALSE; for(i=0;i<40;i++){ //clear IOT buffer so that junk isnt written to terminal after junk-->command IOTBufferReceive[i]='\0'; } IOTIndexReceive=0; } }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD Init_ADC(); // Initialize ADC //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run Menu_Process(); ADC_Process(); // call sampling function if(display_count >= FOR_FOURTH_SECOND){ // update screen every 250 msec Display_Process(); display_count = SWITCH_OFF; } if(menu_items == FALSE){ display_4 = "SW2: Menu"; } if(switch_two_pressed){ menu_items = TRUE; switch_two_pressed = SWITCH_OFF; } } //------------------------------------------------------------------------------ }
void draw_circle(void){ Time_Sequence=0; int i=0; // 1234567890 display_1 = "FirstTask"; posL1 = 0; display_2 = "DrawCircle"; posL2 = 0; display_3 = "ECE306"; posL3 = 2; display_4 = "Skang"; posL4 = 3; big = 0; Display_Process(); while(Time_Sequence<300){} Time_Sequence=0; //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(i<10) { // Can the Operating system run switch(Time_Sequence){ case 20: // 100 msec if(one_time){ Init_LEDs(); // Initialize LEDs one_time = 0; i++; } Time_Sequence = 0; // case 18: // 50 msec if(one_time){ P3OUT |= LED5; // Change State of LED 5 one_time = 0; } case 1: // if(one_time){ P3OUT |= LED7; // Change State of LED 7 one_time = 0; } break; // default: break; } if(Time_Sequence > 20){ Time_Sequence = 0; } } current_job=circle; next_job=eight; }
void main(void) { Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Init_Interrupts(); //PJOUT |= LED1; // Turn LED 1 on to indicate boot TimeMsec = RESET_TIME; Init_Timers(); // Initialize Timers Init_LCD(); // Initialize LCD //Init_LEDs(); // Initialize LEDs // "0123456789abcdef" display_1 = " PROJECT 5 "; display_2 = " "; Display_Process(); P1OUT |= IR_LED; waitMsec(10); /* ---------- Begining of the "While" Operating System ------------- */ while(ALWAYS) // Can the Operating system run { if(TimeMsec % EVERY_50 == RESET_TIME) Display_Process(); //Refreshes screen every 50 'ticks' if(TimeMsec % EVERY_2 == RESET_TIME) { Switches_Process(); // Poll for switch state change every other 'tick' ADC_Process(); } Motors_Process(); Control_Process(); } }
void main(void) { // The 'while' operating system Init_System(); while(ALWAYS) { Display_Process(); Menu_Process(); ADC_Process(); CMD_Process(); } }
static void startConfig() { // Show Start Configuring Message SERIAL_FLAG_ENABLE(CONFIG_WIFI); DISABLE_TIMER_ISR(TB1CCTL1); wifiResetCount=CLEAR; display_1 = ""; display_2 = "Configuring"; display_3 = "..."; display_4 = "..."; Display_Process(); }
void parseIOTData(void){ for(i=0;i<=100-3;i++){ //search through received strings if(receiving[i]=='D'){ if(receiving[i+1]==':'){ if(receiving[i+2]=='2'){ Five_msec_Delay(1); if(receiving[i+3]=='1'){ display_4="Scanning"; Display_Process(); } else if(receiving[i+3]=='4'){ countP=0; //initialize period counter Five_msec_Delay(3); //short delay to allow all characters to enter j=0; for(i=17;receiving[i] != '\r';i++){ //go from beginning of address until 2nd period hit (2nd group) if(receiving[i] == '.'){ countP++; } if(countP >=2){ //stop copying to buffer if 2nd period has been hit (2nd "group" is copied) break; } firstipBuff[j]=receiving[i]; j++; } posL3=(10-j)/2; //center first half of ip address i++; //skip the period for(j=0;receiving[i] != '\r';i++){ secondipBuff[j]=receiving[i]; j++; } posL4=(10-j)/2; //center second half of ip address display_1=SSIDPtr; //from D:25 display_2=" ipaddr "; ipPtr=firstipBuff; display_3=ipPtr; ipPtr=secondipBuff; display_4=ipPtr; lcd_4line(); Display_Process(); Five_msec_Delay(600); //display IP for 3 seconds before screen gets cleared by menus posL1=0; //reset line positions back to beginning posL3=0; posL4=0; } else if(receiving[i+3]=='5'){ Five_msec_Delay(5);//short delay to allow all characters to enter for(i=32;receiving[i] != '\'' && i<=42 ;i++){ //copy SSID until end of quoted name or until max size for LCD is hit SSIDBuff[i-32]=receiving[i]; } SSIDPtr=SSIDBuff; posL1=(10-(i-32))/2; //center SSID //SSID is displayed in D:24 } } else if(receiving[i+2]=='3'){ //clear display once scanning is complete if(receiving[i+3]=='5'){ display_4=" "; Display_Process(); } } else if(receiving[i+2]=='4'){ //detect disassociation --> reassociate by resetting module if(receiving[i+3]=='1'){ uart_puts("AT+CFUN=1\r"); //Get SSID to ncsu PJOUT &= ~IOT_RESET; //reset IOT Five_msec_Delay(10); //wait 50 ms PJOUT |= IOT_RESET; //turn IOT back on (stop reset) } } } } } }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD Init_ADC(); // Initialize ADC Init_Serial_UCA1(0); // BAUD rate 9600 Init_Serial_UCA0(1); // BAUD rate 9600 Five_msec_Delay(1); PJOUT |= IOT_STA_MINIAP; //turning on miniap (only works this way) IR_LED_OFF(); lcd_BIG_mid(); display_1 = " David "; display_2 = "Project 8"; display_3 = " Pryor "; display_4 = ""; Display_Process(); //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run ADC_Process(); // call sampling function if(MainFG){ Menu_Process(); } else if(BaudMenuFG==TRUE){ Baud_Menu(); } else if(IOTMenuFG==TRUE){ IOT_Menu(); } if(StartCommandFG){ //StartCommandFG is true once "." has been received commandTree(); } printMacAddress(); //prints mac address to screen macFG=FALSE; //turn off command to print mac address clearReceiveBuffer(); parseIOTData(); } //------------------------------------------------------------------------------ }
void com_menu_program(void){ outchar_com(current_com_character); outchar_com('6'); if(current_com_character == '2') if(current_com_character == '3') if(current_com_character == '7') switch (current_com_character) { case 'W': case 'w': display_2 = "Forward"; posL2 = RESET; Display_Process(); left_forward(3500); right_forward(3000); __delay_cycles(8000000); left_forward(RESET); right_forward(RESET); display_2 = ""; posL4 = RESET; Display_Process(); break; case 'X': case 'x': display_2 = "Reverse"; posL2 = RESET; Display_Process(); left_reverse(3000); right_reverse(3000); __delay_cycles(2500000); left_reverse(0); right_reverse(0); display_2 = ""; posL4 = RESET; break; case 'D': case 'd': display_2 = "Left"; posL2 = RESET; Display_Process(); left_forward(3000); right_reverse(3000); __delay_cycles(2500000); left_forward(0); right_reverse(0); display_2 = ""; posL4 = RESET; break; case 'A': case 'a': display_2 = "Left"; posL2 = RESET; Display_Process(); right_forward(3000); left_reverse(3000); __delay_cycles(2500000); right_forward(0); left_reverse(0); //waitForSeconds(6); display_2 = ""; posL4 = RESET; break; case 'S': display_2 = "Right"; posL2 = RESET; Display_Process(); right_reverse(3000); left_forward(3000); __delay_cycles(2500000); right_reverse(0); left_forward(0); //waitForSeconds(6); display_2 = ""; posL4 = RESET; display_2 = "Right"; posL2 = RESET; Display_Process(); right_reverse(3000); left_forward(3000); __delay_cycles(2500000); right_forward(0); left_reverse(0); //waitForSeconds(6); display_2 = ""; posL4 = RESET; break; case 's': display_2 = "Left"; posL2 = RESET; Display_Process(); right_forward(3000); left_reverse(3000); __delay_cycles(2500000); right_forward(0); left_reverse(0); //waitForSeconds(6); display_2 = ""; posL4 = RESET; display_2 = "Right"; posL2 = RESET; Display_Process(); right_reverse(3000); left_forward(3000); __delay_cycles(2500000); right_reverse(0); left_forward(0); //waitForSeconds(6); display_2 = ""; posL4 = RESET; break; case 'F': follow_toggle = 1; line_int_toggle = 1; Line_Follow(); break; case 'f': follow_toggle = 0; Line_Follow(); right_stop(); left_stop(); break; default: left_forward(0); right_reverse(0); left_reverse(0); right_forward(0); } waitForSeconds(1); current_com_character = 0x00; print_com_CR(); //------------------------------------------------------------------------------ }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers five_msec_sleep(COUNT_TWOFIDDY_MSEC); // 250 msec delay for the clock to settle (50) Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD // 1234567890 display_1 = "NCSU"; posL1 = LINE_POS_3; display_2 = "WOLFPACK"; posL2 = LINE_POS_1; display_3 = "ECE306"; posL3 = LINE_POS_2; display_4 = "D Pryor"; posL4 = LINE_POS_1; big = SWITCH_OFF; Display_Process(); //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run switch(Time_Sequence){ case COUNT_TWELVEFIDDY_MSEC: // 1250 msec (250) if(one_time){ Init_LEDs(); // Initialize LEDs one_time = SWITCH_OFF; } Time_Sequence = SWITCH_OFF; // case COUNT_ONETHOUSAND_MSEC: // 1000 msec (200) if(one_time){ one_time = SWITCH_OFF; } case COUNT_SEVENFIDDY_MSEC: // 750 msec (150) if(one_time){ one_time = SWITCH_OFF; } case COUNT_FIVEHUNNED_MSEC: // 500 msec (100) if(one_time){ one_time = SWITCH_OFF; } case COUNT_TWOFIDDY_MSEC: // 250 msec (50) if(one_time){ one_time = SWITCH_OFF; } size_count++; if(size_count > MAX_SIZE_COUNT){ size_count = SWITCH_OFF; if(big){ //lcd_BIG_mid(); big = SWITCH_OFF; }else{ //lcd_4line(); big = SWITCH_ON; } } Display_Process(); break; // default: break; } Switches_Process(); // Check for switch state change if(Time_Sequence > COUNT_TWELVEFIDDY_MSEC){ Time_Sequence = SWITCH_OFF; } } //------------------------------------------------------------------------------ }
void main(void){ //------------------------------------------------------------------------------ // Main Program // This is the main routine for the program. Execution of code starts here. // The operating system is Back Ground Fore Ground. // //------------------------------------------------------------------------------ init_ports(); Init_Clocks(); Init_Conditions(); init_timers(); five_msec_delay(QUARTER_SECOND); Init_LCD(); setup_sw_debounce(); init_adc(); P1OUT |= IR_LED; init_serial_uart(); WDTCTL = WDTPW + WDTHOLD; setup_pwm(); set_motor_speed(R_FORWARD, PWM_RES); set_motor_speed(L_FORWARD, PWM_RES); unsigned int time_sequence = START_VAL; // counter for switch loop unsigned int previous_count = START_VAL; // automatic variable for // comparing timer_count unsigned int display_count = START_VAL; is_follow_running = FALSE; //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run if(get_timer_count() > display_count + QUARTER_SECOND) { display_count = get_timer_count(); Display_Process(); time_sequence = START_VAL; } update_switches(); // Check for switch state change update_menu(); if(is_follow_running) run_follow(); if(uca0_is_message_received()) { BufferString message = uca0_read_buffer(TRUE); receive_command(message.head + message.offset); } if(uca1_is_message_received()) { update_menu(); BufferString message = uca1_read_buffer(TRUE); uca0_transmit_message(message.head, message.offset); if(find(WIFI_COMMAND_SYMBOL, message)) { receive_command(message.head + message.offset); } if(find(LOST_WIFI_COMMAND_SYMBOL, message)) { receive_command(CONNECT_NCSU); } } if(time_sequence > SECOND_AND_A_QUARTER) time_sequence = START_VAL; unsigned int current_timer_count = get_timer_count(); if(current_timer_count > previous_count) { previous_count = current_timer_count % UINT_16_MAX; time_sequence++; } } //------------------------------------------------------------------------------ }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run if(do_this == TRUE){ Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = "FORWARD"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line(); //forward Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = "REVERSE"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line_reverse(); //reverse Five_msec_Delay(FOR_ONE_SECOND); display_2 = "FORWARD"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line(); //forward Five_msec_Delay(FOR_ONE_SECOND); display_2 = "CW-SPIN"; //change display posL2 = LINE_POS_1; Display_Process(); //push display clockwise_spin(); //forward Five_msec_Delay(FOR_ONE_SECOND); display_2 = "CCW-SPIN"; //change display posL2 = LINE_POS_1; Display_Process(); //push display counterclockwise_spin(); //forward Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = ""; //clear display posL2 = LINE_POS_1; Display_Process(); //push display do_this = FALSE; } } //------------------------------------------------------------------------------ }
void IR_Calibration(void){ //============================================================================== // COMMANDTREE // // Description: This function is used as a command tree for input commands // // Passed : no variables passed // Locals: proceed // Returned: no values returned // Globals: ADC_Left_Detector // ADC_Right_Detector // thresholdL // thresholdR // left_calibration_black // right_calibration_black // left_calibration_white // right_calibration_white // display_1 // display_2 // display_3 // display_4 // switch_two_pressed // // Author: David Pryor // Date: April 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== int proceed = RESET; ADC_Process(); // call sampling function IR_LED_ON(); Five_msec_Delay(FOR_ONE_SECOND); display_1 = "White Test"; display_2 = "Press SW2"; display_3 = ""; display_4 = ""; Display_Process(); while(proceed == FALSE){ if(switch_two_pressed){ proceed = TRUE; switch_two_pressed = FALSE; } } ADC_Process(); // call sampling function right_calibration_white = ADC_Right_Detector; left_calibration_white = ADC_Left_Detector; proceed = RESET; display_1 = "Black Test"; display_2 = "Press SW2"; display_3 = ""; display_4 = ""; Display_Process(); while(proceed == FALSE){ if(switch_two_pressed){ proceed = TRUE; switch_two_pressed = FALSE; } } ADC_Process(); // call sampling function right_calibration_black = ADC_Right_Detector; left_calibration_black = ADC_Left_Detector; IR_LED_OFF(); thresholdR = ((right_calibration_black + right_calibration_white)/HALF)+THRESHOLD_SENSITIVITY; thresholdL = ((left_calibration_black + left_calibration_white)/HALF)+THRESHOLD_SENSITIVITY; }
void receive_command(char* command) { BufferString temp_command; temp_command.head = command; temp_command.offset = START_ZERO; if(compare(command, COMMAND_AKNOWLEDGE)) { uca0_transmit_message(AKNOWLEDGE_MESSAGE, NO_OFFSET); } else if(compare(command, SLOW_BAUD)) { uca1_set_current_baud(BAUD_115200); uca0_transmit_message(SLOW_BAUD_MESSAGE, NO_OFFSET); uca1_transmit_message(SLOW_BAUD_COMMAND, NO_OFFSET); five_msec_delay(SECOND + SECOND); uca1_transmit_message(SAVE_COMMAND, NO_OFFSET); five_msec_delay(SECOND); uca1_set_current_baud(BAUD_9600); uca1_transmit_message(RESET_COMMAND, NO_OFFSET); PJOUT &= ~IOT_RESET; five_msec_delay(QUARTER_SECOND); PJOUT |= IOT_RESET; uca0_transmit_message(RESET_MESSAGE, NO_OFFSET); five_msec_delay(QUARTER_SECOND); uca1_transmit_message(G_MAC_COMMAND, NO_OFFSET); } else if(compare(command, FAST_BAUD)) { uca1_set_current_baud(BAUD_9600); uca0_transmit_message(FAST_BAUD_MESSAGE, NO_OFFSET); uca1_transmit_message(FAST_BAUD_COMMAND, NO_OFFSET); five_msec_delay(SECOND + SECOND); uca1_transmit_message(SAVE_COMMAND, NO_OFFSET); five_msec_delay(SECOND); uca1_set_current_baud(BAUD_115200); uca1_transmit_message(RESET_COMMAND, NO_OFFSET); PJOUT &= ~IOT_RESET; five_msec_delay(QUARTER_SECOND); PJOUT |= IOT_RESET; uca0_transmit_message(RESET_MESSAGE, NO_OFFSET); } else if(compare(command, CONNECT_NCSU)) { uca0_transmit_message(CONNECT_NCSU_MESSAGE, NO_OFFSET); uca1_transmit_message(SET_SSID_NCSU_COMMAND, NO_OFFSET); uca1_transmit_message(GET_SSID_NCSU_COMMAND, NO_OFFSET); five_msec_delay(QUARTER_SECOND); uca1_transmit_message(SET_HOST_NAME_COMMAND, NO_OFFSET); uca1_transmit_message(GET_HOST_NAME_COMMAND, NO_OFFSET); five_msec_delay(QUARTER_SECOND); uca1_transmit_message(SET_PRIVACY_MODE_COMMAND, NO_OFFSET); uca1_transmit_message(GET_PRIVACY_MODE_COMMAND, NO_OFFSET); five_msec_delay(QUARTER_SECOND); uca1_transmit_message(SET_NETWORK_MODE_COMMAND, NO_OFFSET); uca1_transmit_message(GET_NETWORK_MODE_COMMAND, NO_OFFSET); uca1_transmit_message(SAVE_COMMAND, NO_OFFSET); uca1_transmit_message(GET_NETWORK_MODE_COMMAND, NO_OFFSET); uca1_transmit_message(SAVE_COMMAND, NO_OFFSET); five_msec_delay(QUARTER_SECOND); uca1_transmit_message(RESET_COMMAND, NO_OFFSET); PJOUT &= ~IOT_RESET; five_msec_delay(QUARTER_SECOND); PJOUT |= IOT_RESET; uca0_transmit_message(RESET_MESSAGE, NO_OFFSET); } else if(compare(command, GET_WIFI_STATUS)) { uca1_transmit_message(GET_WIFI_STATUS_COMMAND, NO_OFFSET); } else if(compare(command, GET_WIFI_IP)) { uca1_transmit_message(GET_WIFI_IP_COMMAND, NO_OFFSET); } // Forward Command else if(find(CAR_FORWARD, temp_command)) { display_1 = CLEAR_LINE; display_2 = command; display_3 = CLEAR_LINE; display_4 = CLEAR_LINE; set_motor_speed(R_FORWARD, (int) (MAX_SPEED * 0.87f)); set_motor_speed(L_FORWARD, MAX_SPEED); lcd_BIG_mid(); five_msec_delay(QUARTER_SECOND); Display_Process(); uca0_transmit_message("SUCCESS", NO_OFFSET); turn_on_motor(R_FORWARD); turn_on_motor(L_FORWARD); if(CH_TO_DIG(command[COMMAND_TIME_POS]) <= 9) five_msec_delay(SECOND * CH_TO_DIG(command[COMMAND_TIME_POS]) / COMMAND_TURN_RATIO); turn_off_motor(R_FORWARD); turn_off_motor(L_FORWARD); lcd_4line(); if(command[COMMAND_LENGTH] == COMMAND_CHAR_SYMBOL) receive_command(command + COMMAND_LENGTH); } // Backward Command else if(find(CAR_BACKWARD, temp_command)) { display_1 = CLEAR_LINE; display_2 = command; display_3 = CLEAR_LINE; display_4 = CLEAR_LINE; lcd_BIG_mid(); five_msec_delay(QUARTER_SECOND); Display_Process(); uca0_transmit_message("SUCCESS", NO_OFFSET); turn_on_motor(R_REVERSE); turn_on_motor(L_REVERSE); five_msec_delay(SECOND * CH_TO_DIG(command[COMMAND_TIME_POS])); turn_off_motor(R_REVERSE); turn_off_motor(L_REVERSE); lcd_4line(); if(command[COMMAND_LENGTH] == COMMAND_CHAR_SYMBOL) receive_command(command + COMMAND_LENGTH); } // Right Command else if(find(CAR_RIGHT, temp_command)) { display_1 = CLEAR_LINE; display_2 = command; display_3 = CLEAR_LINE; display_4 = CLEAR_LINE; lcd_BIG_mid(); five_msec_delay(QUARTER_SECOND); Display_Process(); uca0_transmit_message("SUCCESS", NO_OFFSET); turn_on_motor(R_REVERSE); turn_on_motor(L_FORWARD); if(CH_TO_DIG(command[COMMAND_TIME_POS]) <= 9) five_msec_delay(SECOND * CH_TO_DIG(command[COMMAND_TIME_POS]) / COMMAND_TURN_RATIO); turn_off_motor(R_REVERSE); turn_off_motor(L_FORWARD); lcd_4line(); if(command[COMMAND_LENGTH] == COMMAND_CHAR_SYMBOL) receive_command(command + COMMAND_LENGTH); } // Left Command else if(find(CAR_LEFT, temp_command)) { display_1 = CLEAR_LINE; display_2 = command; display_3 = CLEAR_LINE; display_4 = CLEAR_LINE; lcd_BIG_mid(); five_msec_delay(QUARTER_SECOND); Display_Process(); uca0_transmit_message("SUCCESS", NO_OFFSET); turn_on_motor(R_FORWARD); turn_on_motor(L_REVERSE); if(CH_TO_DIG(command[COMMAND_TIME_POS]) <= 9) five_msec_delay(SECOND * CH_TO_DIG(command[COMMAND_TIME_POS]) / COMMAND_TURN_RATIO); turn_off_motor(R_FORWARD); turn_off_motor(L_REVERSE); lcd_4line(); if(command[COMMAND_LENGTH] == COMMAND_CHAR_SYMBOL) receive_command(command + COMMAND_LENGTH); } else if(find(CAR_LINE_FOLLOW, temp_command)) { is_follow_running = is_follow_running ? FALSE : TRUE; } }