hey guys, i need your help, i want make a anemometer on lcd using
pic16f877a or pic18f458, i dont know how to make the right program using micro c. all i got i s this code, i made this code.....pls help me, i want to get the concept of a bike speedo meter using reed switch.....
//============ INITIALIZATION===============
void Initialization()
{
trisb = 0x03; // initialize PORTB RB0 and RB1 as input the rest is output
portd = 0; // initialize the value of PORTD as 0
Lcd_Init(&PORTB);
Lcd_Cmd(LCD_CURSOR_OFF);
}
//================ STATUS DISPLAY =================
void Initial_Display()
{
delay_ms(200);
Lcd_Chr(1,1,'W');Lcd_Chr_Cp('i');Lcd_Chr_Cp('n');Lcd_Chr_Cp('d');
Lcd_Chr_Cp(' ');Lcd_Chr_Cp('S');Lcd_Chr_Cp('p');Lcd_Chr_Cp('e');
Lcd_Chr_Cp('e');Lcd_Chr_Cp('d');Lcd_Chr_Cp(' ');Lcd_Chr_Cp(':');
Lcd_Chr(1,18,'k');Lcd_Chr_Cp('p');Lcd_Chr_Cp('h');
delay_ms(10);
}
//=======================================================
void Digit1_ws(unsigned short ones)
{
switch(ones)
{
case 1: Lcd_Chr(1,16,'1');
break;
case 2: Lcd_Chr(1,16,'2');
break;
case 3: Lcd_Chr(1,16,'3');
break;
case 4: Lcd_Chr(1,16,'4');
break;
case 5: Lcd_Chr(1,16,'5');
break;
case 6: Lcd_Chr(1,16,'6');
break;
case 7: Lcd_Chr(1,16,'7');
break;
case 8: Lcd_Chr(1,16,'8');
break;
case 9: Lcd_Chr(1,16,'9');
break;
case 0: Lcd_Chr(1,16,'0');
break;
}
}
void Digit2_ws(unsigned short tens)
{
switch(tens)
{
case 1: Lcd_Chr(1,15,'1');
break;
case 2: Lcd_Chr(1,15,'2');
break;
case 3: Lcd_Chr(1,15,'3');
break;
case 4: Lcd_Chr(1,15,'4');
break;
case 5: Lcd_Chr(1,15,'5');
break;
case 6: Lcd_Chr(1,15,'6');
break;
case 7: Lcd_Chr(1,15,'7');
break;
case 8: Lcd_Chr(1,15,'8');
break;
case 9: Lcd_Chr(1,15,'9');
break;
case 0: Lcd_Chr(1,15,'0');
break;
}
}
void Digit3_ws(unsigned short hundreds)
{
switch(hundreds)
{
case 1: Lcd_Chr(1,14,'1');
break;
case 2: Lcd_Chr(1,14,'2');
break;
case 3: Lcd_Chr(1,14,'3');
break;
case 4: Lcd_Chr(1,14,'4');
break;
case 5: Lcd_Chr(1,14,'5');
break;
case 6: Lcd_Chr(1,14,'6');
break;
case 7: Lcd_Chr(1,14,'7');
break;
case 8: Lcd_Chr(1,14,'8');
break;
case 9: Lcd_Chr(1,14,'9');
break;
case 0: Lcd_Chr(1,14,'0');
break;
}
}
//=======================================================
void WindSpeed()
{
int x=0,y=0,z=0;
while(1)
{
Digit1_ws(x);
if(portb.f1==0)
{
while(portb.f1==0)
{
}
x++;
Digit1_ws(x);
if(x==10)
{
x=0;
Digit1_ws(x);
y++;
Digit2_ws(y);
if(y==10)
{
y=0;
Digit2_ws(y);
z++;
Digit3_ws(z);
}
}
}
}
}
//=============== Main Function =======================
void main()
{
Initialization();
Initial_Display();
while(1)
{
WindSpeed();
}
}