int main() 
{
    int adcValue;
    int temp;
    
    ADC_Init();       /* Initialize the ADC module */
    
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus PORTB.4 to PORTB.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
    LCD_Init(2,16);
    
    while(1)
    {
        adcValue = ADC_GetAdcValue(0); // Read the ADC value of channel zero(PA0) where the temperature sensor(LM35) is connected
        
        /* Convert the raw ADC value to equivalent temperature with 5v as ADC reference
		 Step size of AdC= (5v/1023)=4.887mv = 5mv.
		 for every degree celcius the Lm35 provides 10mv voltage change.
	     1 step of ADC=5mv=0.5'c, hence the Raw ADC value can be divided by 2 to get equivalent temp*/
        
        temp = adcValue/2.0; // Divide by 2 to get the temp value.
        LCD_GoToLine(0);
        LCD_Printf("ADC0 Value:%4d \nTemp:%dC\n\r",adcValue,temp);     // Display adc value and temp LCD
		
    }
    
    return (0);
}
int main() 
{
    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTB.4 to PORTB.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
    LCD_Init(1,16);
    
    LCD_DisplayString("Explore Lcd 1x16");
    
    while(1);
    
    return (0);
}
int main()
{
	/*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTC.4 to PORTC.7*/
	LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PC_4,PC_5,PC_6,PC_7);
	LCD_Init(2,16);
	
	LCD_DisplayString("Explore Embedded");
	LCD_DisplayString("Lcd 4-bit Mode");
	while(1);
	
	return (0);
}
void LCD_4bit_test()
{
     UART_TxString("\n\r LCD DataBus:(PD4-PD7)  RS-PB.0  RW-PB.1  EN-PB.2 ");
      UART_Printf("\n\r Make connections and hit 'k' to test ");
      while(UART_RxChar()!='k');
      LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PD_4,PD_5,PD_6,PD_7);
      LCD_Init(2,16);
      DELAY_ms(100);
      LCD_DisplayString("Explore Embedded");
      LCD_DisplayString("Lcd 4-bit Mode");
      while(1);
}
Exemple #5
0
int main() 
{	   
    SystemInit(); 
		 
    /*Connect RS->P1_27, RW->P1_28, EN->P1_29 and data bus(D4:D7 - P1_16:P1_23)*/
    LCD_SetUp(P1_27,P1_28,P1_29,P1_16,P1_17,P1_18,P1_19,P1_20,P1_21,P1_22,P1_23);
    LCD_Init(2,16);
    
    LCD_DisplayString("Explore Embedded");
    LCD_DisplayString("Lcd 8-bit Mode");

    while(1);
}
Exemple #6
0
int main() 
{	
     SystemInit();		
    /*Connect RS, RW, EN and data bus to PORT0.4 to PORT0.7*/
    LCD_SetUp(P2_0,P2_1,P2_2,P_NC,P_NC,P_NC,P_NC,P1_24,P1_25,P1_26,P1_27);
    LCD_Init(2,16);
    
    LCD_DisplayString("Explore Embedded");
    LCD_DisplayString("Lcd 4-bit Mode");
    while(1);
    
    
}
int main()
{
	DDRC=0xff;   //Configure PORTC(Lcd databus) as output
	DDRD=0xe0;   //Configure INT0,INT1 as input and PORTD5-PORTD7(rs,rw,en) as output
	
	LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
	LCD_Init(2,16);
	
	GICR=0xc0;   //Enable External Interrupts INT0 and INT1
	MCUCR=0x08;  //Configure INT0 active low level triggered and INT1 as falling edge
	
	sei();     // Enable global interrupts by setting global interrupt enable bit in SREG
	
	while(1)
	{
		LCD_Printf("EINT0:%4u\n",cnt_zero);
		LCD_Printf("EINT1:%4u\n",cnt_one);
	}
}
Exemple #8
0
int main()
{
    int adcValue;
    float volt;
    SystemInit();
    ADC_Init();       /* Initialize the ADC module, Note: Max ADC Input voltage 3.3v */

    /*Connect RS->P1_16, RW->P1_17, EN->P1_18 and data bus(D4:D7 - P1_20:P1_23)*/
    LCD_SetUp(P1_16,P1_17,P1_18,P_NC,P_NC,P_NC,P_NC,P1_20,P1_21,P1_22,P1_23);
    LCD_Init(2,16);

    while(1)
    {
        adcValue = ADC_GetAdcValue(AD0_1); // Read the ADC value of channel AD0.1, Max ADC voltage 3.3v
        volt = (adcValue*3.3)/1023;       // ADC_REF Voltage=3.3v and ADC resolution 10bit
        LCD_GoToLine(0);
        LCD_Printf("ADC0 Value:%4d\nVolt:%f",adcValue,volt);     // Display Raw adc value and Equivalent temp on LCD
    }
}
int main() 
{
    int count = 0;
	
    /*Connect RS->P0.0, RW->P0.1, EN->P0.2 and data bus to P0.4 to P0.7*/
    LCD_SetUp(P0_0,P0_1,P0_2,P_NC,P_NC,P_NC,P_NC,P0_4,P0_5,P0_6,P0_7);
    LCD_Init(2,16);
    
    LCD_DisplayString("Decimal");

    while(1)
    {
        LCD_GoToLine(1);
        LCD_Printf("Count=%4d",count);
        DELAY_ms(500);
        count++;
    }
    
    return (0);
}
Exemple #10
0
int main (void) 
{
    SystemInit();

    /*        RS   RW   EN   D0   D1   D2   D3   D4    D5    D6    D7      P_NC(Not connected)*/
    LCD_SetUp(P2_0,P2_1,P2_2,P_NC,P_NC,P_NC,P_NC,P1_24,P1_25,P1_26,P1_27); 
    LCD_Init(2,16);

    /* EINT0 is configured as FallingEdge interrupt and myExtIntrIsr_0 will be called by EINT0_IRQHandler */
    EINT_AttachInterrupt(EINT0,myExtIntrIsr_0,FALLING);  

    /* EINT1 is configured as Active Low interrupt and myExtIntrIsr_1 will be called by EINT1_IRQHandler */
    EINT_AttachInterrupt(EINT1,myExtIntrIsr_1,LOW);

    while(1)
    {
        LCD_GoToLine(0);
        LCD_Printf("EINT0=%8u EINT1:%8u",cnt1,cnt2); /* Display the occurrence of EINT0 and EINT1 */
    }
}
Exemple #11
0
int main()
{
    char str[50];
    int len = 0;
    SystemInit();

    /*Connect RS->P1_16, RW->P1_17, EN->P1_18 and data bus(D4:D7 - P1_20:P1_23)*/
    LCD_SetUp(P1_16,P1_17,P1_18,P_NC,P_NC,P_NC,P_NC,P1_20,P1_21,P1_22,P1_23);
    LCD_Init(2,16);
    UART0_Init(9600);
    LCD_DisplayString("send data from  serial terminal");
    while(1)
    {
        len = UART0_RxString(str);
        UART0_Printf("Received String:%s   size=%2d\n\r",str,len);
        LCD_Clear();
        LCD_Printf("str:%s size=%2d",str,len);
    }


}
int main() 
{
    char str[50];
    int len = 0;
	
    /*Connect RS->P0.0, RW->P0.1, EN->P0.2 and data bus to P0.4 to P0.7*/
    LCD_SetUp(P0_0,P0_1,P0_2,P_NC,P_NC,P_NC,P_NC,P0_4,P0_5,P0_6,P0_7);
    LCD_Init(2,16);
	
    UART_Init(9600);
    LCD_DisplayString("send data from  serial terminal");
	
    while(1)
    {
        len = UART_RxString(str);
        //UART_Printf("Received String:%s   size=%2d\n\r",str,len);
        LCD_Clear();
        LCD_Printf("str:%s size=%2d",str,len);
    }
    
    return (0);
}
Exemple #13
0
int main() 
{
    int count = 0;

	SystemInit();

    /*Connect RS->PD0, RW->PD1, EN->PD2 and data bus to PORTB*/
    LCD_SetUp(P2_0,P2_1,P2_2,P1_20,P1_21,P1_22,P1_23,P1_24,P1_25,P1_26,P1_27);
    LCD_Init(2,16);
    
    LCD_DisplayString("Decimal");

    while(1)
    {
        LCD_GoToLine(1);
        LCD_Printf("Count=%4d",count);
        DELAY_ms(500);
        count++;
    }
    
    
}
Exemple #14
0
int main()
{
   uint16_t pot_value,ldr_value, temp_raw, temp_final;
   float voltage;
   
   SystemInit();                              //Clock and PLL configuration

   /* Setup/Map the controller pins for LCD operation 
               RS   RW   EN    D0    D1    D2   D3     D4   D5    D6    D7*/
    LCD_SetUp(P2_0,P2_1,P2_2,P1_20,P1_21,P1_22,P1_23,P1_24,P1_25,P1_26,P1_27);

  
    LCD_Init(2,16);      /* Specify the LCD type(2x16) for initialization*/
    ADC_Init();          /* Initialize the ADC */
    while(1)
    {
        pot_value  = ADC_GetAdcValue(0); /* Read pot value connect to AD0(P0_23) */
        ldr_value  = ADC_GetAdcValue(1); /* Read LDR value connect to AD1(P0_24) */
        temp_raw   = ADC_GetAdcValue(2); /* Read Temp value connect to AD2(P0_25) */

     /* Converting the raw adc value to equivalent temperature with 3.3v as ADC reference using 12bit resolution.
        Step size of ADC= (3.3v/2^12)= 3.3/4096 = 0.0008056640625 = 0.0806mv
        For every degree celcius the Lm35 provides 10mv voltage change.
        1 degree celcius = 10mv = 10mv/0.0806mv = 12.41 uinits            
        Hence the Raw ADC value can be divided by 12.41 to get equivalent temp
        */        
       
         temp_final = temp_raw/12.41;

        /* Vin = (Adc_value * REF)/ 2^12 */
        voltage = (pot_value * 3.3)/ 4096.0;

        LCD_GoToLine(0);
        LCD_Printf("P:%4d %f",pot_value,voltage);
        LCD_Printf("\nL:%4d T:%4d",ldr_value,temp_final);       
    }
}
int main() 
{
    rtc_t rtc;

    /*Connect RS->PB0, RW->PB1, EN->PB2 and data bus to PORTB.4 to PORTB.7*/
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
    LCD_Init(2,16);

    RTC_Init();
    rtc.hour = 0x10; //  10:40:20 am
    rtc.min =  0x40;
    rtc.sec =  0x00;

    rtc.date = 0x01; //1st Jan 2016
    rtc.month = 0x01;
    rtc.year = 0x16;
    rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day.




    /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
         and reflash the code. Else the time will be set every time the controller is reset*/
    RTC_SetDateTime(&rtc);  //  10:40:20 am, 1st Jan 2016


    /* Display the Time and Date continuously */
    while(1)
    {
        RTC_GetDateTime(&rtc);
        LCD_GoToLine(0);
        LCD_Printf("time:%2x:%2x:%2x  \nDate:%2x/%2x/%2x",(uint16_t)rtc.hour,(uint16_t)rtc.min,(uint16_t)rtc.sec,(uint16_t)rtc.date,(uint16_t)rtc.month,(uint16_t)rtc.year);
    }

    return (0);
}