int kkkk(void) { velocity(255,255); forward(); while(1) { servo_1(0); servo_2(0); servo_3(0); forward(); red_read(); //display the pulse count when red filter is selected _delay_ms(500); green_read(); //display the pulse count when green filter is selected _delay_ms(500); blue_read(); //display the pulse count when blue filter is selected _delay_ms(500); lcd_wr_command(0x01); print_sensor(1,1,3); //Prints value of White Line Sensor1 print_sensor(1,5,2); //Prints Value of White Line Sensor2 print_sensor(1,9,1); //Prints Value of White Line Sensor3 print_sensor(2,1,11); servo_1(100); servo_2(100); servo_3(100); _delay_ms(7000); } }
int scan()//return the color no. { red_read(); blue_read(); green_read(); _delay_ms(100); if(!(ADC_Conversion(11)>55 && ADC_Conversion(11)<100)) return EMPTY; if (red<threshold && green < threshold && blue < threshold) { return BLACK; } else { if (red > blue) { if (red > green) return RED; else return GREEN; } else if (blue > green) return BLUE; else return GREEN; } }
int main(void) { init_devices(); lcd_set_4bit(); lcd_init(); color_sensor_scaling(); while(1) { red_read(); //display the pulse count when red filter is selected _delay_ms(500); green_read(); //display the pulse count when green filter is selected _delay_ms(500); blue_read(); //display the pulse count when blue filter is selected _delay_ms(500); no_filter();//display the pulse count when no filter is selected _delay_ms(500); } }
//SORTMAN //MAIN SORTING FUNCTION //R-0 L-1 int colorCalc() { red_read(); blue_read(); green_read(); if (!(red>threshold && green > threshold && blue > threshold)) return BLACK; else { if (red > blue) { if (red > green) return RED; else return GREEN; } else if (blue > green) return BLUE; else return GREEN; } }
int scan()//return the color no. { red_read(); blue_read(); green_read(); if (red<threshold && green < threshold && blue < threshold) return BLACK; else { if (red > blue) { if (red > green) return RED; else return GREEN; } else if (blue > green) return BLUE; else return GREEN; } }
static void prvVerifyDemoFiles( void ) { BaseType_t xFileNumber, xReadNumber; char cFilePath[ 64 ]; const BaseType_t xMaxFiles = 5; long lChar; int32_t lBytesRead, lFildes, lStatus; int iByte; /* Read back the files that were created by prvCreateDemoFiles(). */ for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ ) { /* Generate the file name. */ sprintf( cFilePath, "/root%03d.txt", xFileNumber ); /* Print out the file name and the directory from which the file is being read. */ printf( "Reading file %s\r\n", cFilePath ); /* Open the file for reading. */ lFildes = red_open( cFilePath, RED_O_RDONLY ); configASSERT( lFildes != -1 ); /* Read the file into the RAM buffer, checking the file contents are as expected. The size of the file depends on the file number. */ for( xReadNumber = 0; xReadNumber < xFileNumber; xReadNumber++ ) { /* Start with the RAM buffer clear. */ memset( cRAMBuffer, 0x00, fsRAM_BUFFER_SIZE ); lBytesRead = red_read( lFildes, cRAMBuffer, fsRAM_BUFFER_SIZE ); configASSERT( lBytesRead == fsRAM_BUFFER_SIZE ); /* Check the RAM buffer is filled with the expected data. Each file contains a different repeating ascii character that indicates the number of the file. */ for( lChar = 0; lChar < fsRAM_BUFFER_SIZE; lChar++ ) { configASSERT( cRAMBuffer[ lChar ] == ( '0' + ( char ) xFileNumber ) ); } } /* Close the file. */ lStatus = red_close( lFildes ); configASSERT( lStatus == 0 ); } /* Generate the file name. */ sprintf( cFilePath, "%s/file.txt", pcDirectory2 ); /* Print out the file name and the directory from which the file is being read. */ printf( "Reading file %s\r\n", cFilePath ); /* This time the file is opened for reading. */ lFildes = red_open( cFilePath, RED_O_RDONLY ); configASSERT( lFildes != -1 ); /* Read the file. */ lBytesRead = red_read( lFildes, cRAMBuffer, fsRAM_BUFFER_SIZE ); configASSERT( lBytesRead == fsRAM_BUFFER_SIZE ); /* Verify the file 1 byte at a time. */ for( iByte = 0; iByte < fsRAM_BUFFER_SIZE; iByte++ ) { configASSERT( cRAMBuffer[ iByte ] == ( char ) ( ( int ) '0' + iByte ) ); } /* Finished so close the file. */ lStatus = red_close( lFildes ); configASSERT( lStatus == 0 ); }
int calcThresh() { int c[4],i; red_read(); blue_read(); green_read(); for(i=0;i<4;i++) c[i]=0; for(i=0;i<4;i++) { //read(); if(red>green && red>blue) if(c[0]>red) { if(c[3]<red) c[3]=red; } else { if(c[3]<c[0]) c[3]=c[0]; c[0]=red; } else if(blue>green && red<blue) if(c[1]>blue) { if(c[3]<blue) c[3]=blue; } else { if(c[3]<c[1]) c[3]=c[1]; c[1]=blue; } else if(c[2]>green) { if(c[3]<green) c[3]=green; } else { if(c[3]<c[2]) c[3]=c[2]; c[2]=green; } } int t=c[3]; lcd_cursor(1,1); //set the cursor on row 1, column 1 lcd_string("Threshold"); // Display "Blue Pulses" on LCD t+=200; lcd_print(2,1,t,5); _delay_ms(10000); lcd_wr_command(0x01); //Clear the LCD lcd((char*)t); return t; }