Pulse_Sensor_V01/main.c
/* In ra man hinh so nguyen n voi so cho hien thi bang length(chua ke vi tri cua dau) */
In ra man hinh so nguyen n voi so cho hien thi bang length(chua ke vi tri cua dau)
In ra man hinh so nguyen n voi so cho hien thi bang length ( chua ke vi tri cua dau )
void LCD_PrintDecimal(long n, unsigned char length)
{
    unsigned char du,luu=length;
    if(n>=0)
        LCD_Display(' ');       
    else
    {
        LCD_Display('-');           
        n*=-1;
    }
    LCD_CursorShift(1,length-1);    
    P2OUT &=~  0x02;
    _delay_cycles(lcd_delay);
    LCD_Command(0x04);        
    while(length)
    {
        du = n % 10;
        n = n / 10;
        LCD_Display(0x30 + du);
        length--;
    }
    LCD_CursorShift(1,luu);     
    P2OUT &=~ 0x02;
    _delay_cycles(lcd_delay);
    LCD_Command(0x06);        
}
void LCD_PrintDecimal ( long n , unsigned char length ) { unsigned char du , luu = length ; if ( n >= 0 ) LCD_Display ( ' ' ) ; else { LCD_Display ( ' ' ) ; n *= -1 ; } LCD_CursorShift ( 1 , length - 1 ) ; P2OUT &= ~ 0x02 ; _delay_cycles ( lcd_delay ) ; LCD_Command ( 0x04 ) ; while ( length ) { du = n % 10 ; n = n / 10 ; LCD_Display ( 0x30 + du ) ; length -- ; } LCD_CursorShift ( 1 , luu ) ; P2OUT &= ~ 0x02 ; _delay_cycles ( lcd_delay ) ; LCD_Command ( 0x06 ) ; }
In ra man hinh so nguyen n voi so cho hien thi bang length(chua ke vi tri cua dau)
In ra man hinh so nguyen n voi so cho hien thi bang length ( chua ke vi tri cua dau )
// de trong 1 ki tu o dau cho hien thi dau //In so duong //In so am // dich con tro sang phai length-1 vi tri // chuyen sang che do in lui // Bat dau in lan luot cac chu so tu hang don vi // dua con tro sang phai length+1 vi tri de in tiep // chuyen lai ve che do in xuoi