Beispiel #1
0
//Function to Initialize LCD 
void lcd_init() 
{ 
 _delay_ms(1); 
 lcd_wr_command(0x28); //4-bit mode and 5x8 dot character font 
 lcd_wr_command(0x01); //Clear LCD display 
 lcd_wr_command(0x06); //Auto increment cursor position 
 lcd_wr_command(0x0E); //Turn on LCD and cursor 
 lcd_wr_command(0x80); //Set cursor position 
}
void lcd_cursor (char row, char column)
{
	switch (row) {
		case 1: lcd_wr_command (0x80 + column - 1); break;
		case 2: lcd_wr_command (0xc0 + column - 1); break;
		case 3: lcd_wr_command (0x94 + column - 1); break;
		case 4: lcd_wr_command (0xd4 + column - 1); break;
		default: break;
	}
}
//Function to Initialize LCD
void lcd_init()
{
	_delay_ms(1);

	lcd_wr_command(0x28);			//LCD 4-bit mode and 2 lines.
	lcd_wr_command(0x01);
	lcd_wr_command(0x06);
	lcd_wr_command(0x0E);
	lcd_wr_command(0x80);
		
}
//Function to Initialize LCD
void lcd_init()
{
	//lcd_set_4bit();
	lcd_reset_RW();
	lcd_reset_EN();

	_delay_ms(1);
	lcd_wr_command(0x38);			//LCD 4-bit mode and 2 lines.
	lcd_wr_command(0x0f);
	lcd_wr_command(0x06);
	lcd_wr_command(0x01);
	lcd_wr_command(0x80);
}
Beispiel #5
0
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);
	   
    }
}
void main()
{
	unsigned char tag1[] = "4100A352E959";	// This is the valid tag the system is looking for
	unsigned char *str;
	rf_init_devices();

	while(1)
	{
		_delay_ms(50);
		rf_display();		// read the tag, store it and display
		str = rf_return();		// get the read tag details into another string
		lcd_cursor(1,1);
		lcd_string(str);
		_delay_ms(100);
	
		if(!strcmp(str,tag1))		// compare the required tag with the tag which is read
		{
			lcd_cursor(2,1);
			lcd_string(" Valid Tag");
		}	
		else
		{
			lcd_cursor(2,1);
			lcd_string(" invalid tag");
		}	

		_delay_ms(100);
		lcd_wr_command(0x01);
	}
	
	return 0;
	
}
Beispiel #7
0
void lcd(char *str)
{
	
	lcd_wr_command(0x01);
	lcd_cursor(1,1);
	lcd_string(str);
	buzzer();
	_delay_ms(1000);
}
void main(void)
{
	rf_init_devices();	//initializes the usart3, configures lcd ports and initializes the lcd,
	lcd_cursor(2,4);	//move the cursor to 2nd row 4th column
	_delay_ms(50);
	rf_display();		//this function is used to scan the rfid tag and is used to display the same on the lcd screen
	cli();
	lcd_wr_command(0x01);	//this code is used to clear the lcd screen
	
	return 0;
}
void no_filter()
{
	filter_clear(); //select clear filter
	pulse=0; //reset the count to 0
	_delay_ms(500); //capture the pulses for 100 ms or 0.1 second
	no_ff = (pulse);  //store the count in variable called blue
	_delay_ms(100);
	lcd_cursor(1,1);  //set the cursor on row 1, column 1
	lcd_string("no filter"); // Display "no filter" on LCD
	lcd_print(2,1,no_ff,5);  //Print the count on second row
	_delay_ms(1000);	// Display for 1000ms or 1 second
	lcd_wr_command(0x01); //Clear the LCD
}
void blue_read(void) // function to select blue filter and display the count generated by the sensor on LCD. The count will be more if the color is blue. The count will be very less if its red or green.
{
	//Blue
	filter_blue(); //select blue filter
	pulse=0; //reset the count to 0
	_delay_ms(100); //capture the pulses for 100 ms or 0.1 second
	blue = pulse;  //store the count in variable called blue
	
	lcd_cursor(1,1);  //set the cursor on row 1, column 1
	lcd_string("Blue Pulses"); // Display "Blue Pulses" on LCD
	lcd_print(2,1,blue,5);  //Print the count on second row
	_delay_ms(1000);	// Display for 1000ms or 1 second
	lcd_wr_command(0x01); //Clear the LCD
}
void green_read(void) // function to select green filter and display the count generated by the sensor on LCD. The count will be more if the color is green. The count will be very less if its blue or red.
{
	//Green
	filter_green(); //select green filter
	pulse=0; //reset the count to 0
	_delay_ms(100); //capture the pulses for 100 ms or 0.1 second
	green = pulse;  //store the count in variable called green
	
	lcd_cursor(1,1);  //set the cursor on row 1, column 1
	lcd_string("Green Pulses"); // Display "Green Pulses" on LCD
	lcd_print(2,1,green,5);  //Print the count on second row
	_delay_ms(1000);	// Display for 1000ms or 1 second
	lcd_wr_command(0x01); //Clear the LCD
}
/*
 * Main function, will call different phases, locate/clean
 */
int main(void)
{
	unsigned char sharp;
	unsigned int value=0;
	init_devices();
	lcd_set_4bit();
	lcd_init();
	lcd_wr_command(0x0C);// Display ON Cursor OFF
	while(1) {
		if (phase == 1) {
			locate();	
		}
		sharp = ADC_Conversion(11);	//Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp"
		value = Sharp_GP2D12_estimation(sharp); //Stores Distance calsulated in a variable "value".
		lcd_print(2,1,value,3);
	}
	servo_1_free();
	return 0;
}
Beispiel #13
0
void lcd_cursor_on(void)
{
	lcd_wr_command(0x0E);
}
//Function to bring cursor at home position
void lcd_home()
{
	lcd_wr_command(0x80);
}
Beispiel #15
0
void display_clear(void)
{
	lcd_wr_command(0x01);
}	
Beispiel #16
0
//Display ON/ OFF Control 0(rs) 0(rw) 0 0 0 0 1 D C B Set display(D), cursor(C), and blinking of cursor(B) on/off control bit.
void lcd_cursor_off(void)
{
	lcd_wr_command(0x0C);
}
Beispiel #17
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;
}