Afficheur LCD+ATMEGA 16+SWITCH : clignote ?
Répondre à la discussion
Affichage des résultats 1 à 2 sur 2

Afficheur LCD+ATMEGA 16+SWITCH : clignote ?



  1. #1
    invite449a62af

    Afficheur LCD+ATMEGA 16+SWITCH : clignote ?


    ------

    salut à tout
    programme d'affichage sur LCD+ATMEGA 16+SWITCH
    Mon problème c'est que mon afficheur clignote alors que moi je veux l'affichage des message son clignote






    #define F_CPU 4000000UL
    #include <avr/delay.h>
    #include <avr/io.h>

    /*LCD function declarations */
    void LCD_send_command(unsigned char cmnd);// commande de lcd
    void LCD_send_data(unsigned char data);//
    void LCD_init();
    void LCD_goto(unsigned char y, unsigned char x);
    void LCD_print(char *string);
    void LCD_blink();
    void LCD_scroll(unsigned char direction);

    #define LED_1 0 PORT A //afficheur de OT
    #define LED_2 1 PORT A //afficheur de HO2S
    #define LED_3 2 PORT A //afficheur de H2O
    #define LED_4 3 PORT A //afficheur de CO
    #define LED_5 4 PORT A //afficheur de CSS

    #define LCD_DATA_PORT PORTB
    #define LCD_DATA_DDR DDRB
    #define LCD_DATA_PIN PINB

    #define LCD_CNTRL_PORT PORTC
    #define LCD_CNTRL_DDR DDRC
    #define LCD_CNTRL_PIN PINC

    #define LCD_RS_PIN 0
    #define LCD_RW_PIN 1
    #define LCD_ENABLE_PIN 2
    #define lcd_clear();

    int main(void)
    {
    unsigned char i;
    DDRD=0b00000000;
    DDRA=0b11111111;


    while(1)
    {


    if(bit_is_set(PIND,0))
    {
    LCD_init();
    LCD_goto(1,2);
    LCD_print("vous avez /r un probleme dans le moteur");
    LCD_goto(2,3);
    LCD_print("");
    if(bit_is_clear(PIND,0))
    {

    PORTA=0b00000001;
    }

    }
    if(bit_is_set(PIND,1))
    {
    LCD_init();
    LCD_goto(1,2);
    LCD_print("verifier le /r papion");

    if(bit_is_clear(PIND,1))
    {
    LCD_print("");
    }

    }
    if(bit_is_set(PIND,2))
    {
    LCD_init();
    LCD_goto(1,2);
    LCD_print("verifier la /r cinture");
    if(bit_is_clear(PIND,2))
    {
    LCD_print(" ");
    }

    }

    if(bit_is_set(PIND,3))
    {

    LCD_init();
    LCD_goto(1,2);
    LCD_print("verifier le /r reserve d'eau");
    if(bit_is_clear(PIND,3))
    {
    LCD_print(" ");
    }


    }
    if(bit_is_set(PIND,4))
    {
    LCD_init();
    LCD_goto(1,2);
    LCD_print("verifier le /r niveau d'huil");
    if(bit_is_clear(PIND,4))
    {
    LCD_print(" ");
    }

    }


    if(bit_is_set(PIND,5))
    {
    LCD_init();
    LCD_goto(1,2);
    LCD_print("danger gaz /r d'echapement ");
    if(bit_is_clear(PIND,5))
    {
    LCD_print(" ");
    }

    }
    unsigned char i;
    {

    LCD_init();
    LCD_goto(1,2);
    LCD_print("");
    LCD_goto(2,3);
    LCD_print("");
    }

    }
    }

    /* This function sends a command 'cmnd' to the LCD module*/
    void LCD_send_command(unsigned char cmnd)
    {
    LCD_DATA_PORT = cmnd;
    LCD_CNTRL_PORT &= ~(1<<LCD_RW_PIN);
    LCD_CNTRL_PORT &= ~(1<<LCD_RS_PIN);

    LCD_CNTRL_PORT |= (1<<LCD_ENABLE_PIN);
    _delay_us(2);
    LCD_CNTRL_PORT &= ~(1<<LCD_ENABLE_PIN);
    _delay_us(10);
    }

    /* This function sends the data 'data' to the LCD module*/
    void LCD_send_data(unsigned char data)
    {
    LCD_DATA_PORT = data;
    LCD_CNTRL_PORT &= ~(1<<LCD_RW_PIN);
    LCD_CNTRL_PORT |= (1<<LCD_RS_PIN);

    LCD_CNTRL_PORT |= (1<<LCD_ENABLE_PIN);
    _delay_us(2);
    LCD_CNTRL_PORT &= ~(1<<LCD_ENABLE_PIN);
    _delay_us(100);
    }

    void LCD_init()
    {
    LCD_CNTRL_DDR = 0xFF;
    LCD_CNTRL_PORT = 0x00;
    LCD_DATA_DDR = 0xFF;
    LCD_DATA_PORT = 0x00;

    _delay_ms(10);
    LCD_send_command(0x38);
    LCD_send_command(0x0C);
    LCD_send_command(0x01);
    _delay_ms(10);
    LCD_send_command(0x06);
    }

    /* This function moves the cursor the line y column x on the LCD module*/
    void LCD_goto(unsigned char y, unsigned char x)
    {
    unsigned char firstAddress[] = {0x80,0xC0,0x94,0xD4};

    LCD_send_command(firstAddress[y-1] + x-1);
    _delay_ms(10);
    }

    void LCD_print(char *string)
    {
    unsigned char i;

    while(string[i]!=0)
    {
    LCD_send_data(string[i]);
    i++;
    }
    }

    void LCD_blink()
    {
    LCD_send_command(0x08);
    _delay_ms(250);
    LCD_send_command(0x0C);
    _delay_ms(250);
    }

    void LCD_scroll(unsigned char direction)
    {
    if(direction == 0)
    LCD_send_command(0x18);
    else
    LCD_send_command(0x1C);

    _delay_ms(500);
    }

    -----

  2. #2
    invite449a62af

    Re : Afficheur LCD+ATMEGA 16+SWITCH : clignote ?


    voila j''ai ajoute des modification mais le problème reste le même surtout quand j'ajoute des lignes pour allumer des LED



    * Website: www.AVR-Tutorials.com
    */
    Code:
    #define F_CPU	4000000UL
    #include <avr/delay.h>
    #include <avr/io.h>
     
    /*LCD function declarations */
    void LCD_send_command(unsigned char cmnd);// commande de lcd
    void LCD_send_data(unsigned char data);//
    void LCD_init();
    void LCD_goto(unsigned char y, unsigned char x);
    void LCD_print(char *string);
    void LCD_blink();
    void LCD_scroll(unsigned char direction);
    
    #define LCD_DATA_PORT	PORTB
    #define LCD_DATA_DDR	DDRB
    #define LCD_DATA_PIN	PINB
     
    #define LCD_CNTRL_PORT	PORTC
    #define LCD_CNTRL_DDR	DDRC
    #define LCD_CNTRL_PIN	PINC
     
    #define LCD_RS_PIN		0
    #define LCD_RW_PIN		1
    #define LCD_ENABLE_PIN	2
    #define lcd_clear(); 
     
    int main(void)
    {
    	unsigned char i;
       DDRD=0b00000000;
       DDRA=0b11111111;
    
     
    	while(1)
        {
    	
     
       if(bit_is_set(PIND,0))
       		{
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print(" vous avez\r un probleme");
    		LCD_goto(2,3);
    		LCD_print("");
    						if(bit_is_clear(PIND,0))
    						{
    		
    				lcd_clear(); 
    						}
    
    		}
    		if(bit_is_set(PIND,1))
       		{
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print(" verifier le\r     papion");
    
    					if(bit_is_clear(PIND,1))
    						{
    						LCD_print("");
    						}
    
    		}
    		if(bit_is_set(PIND,2))
       		{
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print(" verifier la\r  cinture");
    						if(bit_is_clear(PIND,2))
    				{
    						LCD_print(" ");
    						}
    
    		}
    
    		if(bit_is_set(PIND,3))
       		{
    
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print(" verifier le\r reserve d'eau");
    						if(bit_is_clear(PIND,3))
    				{
    						LCD_print(" ");
    						}
    
    
    		}
    		if(bit_is_set(PIND,4))
       		{
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print(" verifier le\r niveau d'huil");
    				if(bit_is_clear(PIND,4))
    				{
    						LCD_print(" ");
    						}
    
    		}
    
    
    if(bit_is_set(PIND,5))
       		{
           	LCD_init();
    		LCD_goto(1,2);
    		LCD_print("danger gaz\r  d'echapement ");
    						if(bit_is_clear(PIND,5))
    				{
    						LCD_print(" ");
    						}
    
    		}
    	unsigned char i;
    	{
     
        LCD_init();
    	LCD_goto(1,2);
    	LCD_print("");
    	LCD_goto(2,3);
    	LCD_print("");
    	}
       
        }
    }
     
    /* This function sends a command 'cmnd' to the LCD module*/
    void LCD_send_command(unsigned char cmnd)
    {
    	LCD_DATA_PORT = cmnd;
    	LCD_CNTRL_PORT &= ~(1<<LCD_RW_PIN);
    	LCD_CNTRL_PORT &= ~(1<<LCD_RS_PIN);
     
    	LCD_CNTRL_PORT |= (1<<LCD_ENABLE_PIN);
    	_delay_us(2);
    	LCD_CNTRL_PORT &= ~(1<<LCD_ENABLE_PIN);
    	_delay_us(10);
    }
     
    /* This function sends the data 'data' to the LCD module*/
    void LCD_send_data(unsigned char data)
    {
    	LCD_DATA_PORT = data;
    	LCD_CNTRL_PORT &= ~(1<<LCD_RW_PIN);
    	LCD_CNTRL_PORT |= (1<<LCD_RS_PIN);
     
    	LCD_CNTRL_PORT |= (1<<LCD_ENABLE_PIN);
    	_delay_us(2);
    	LCD_CNTRL_PORT &= ~(1<<LCD_ENABLE_PIN);
    	_delay_us(100);
    }
     
    void LCD_init()
    {
    	LCD_CNTRL_DDR = 0xFF;
    	LCD_CNTRL_PORT = 0x00;
    	LCD_DATA_DDR = 0xFF;
    	LCD_DATA_PORT = 0x00;
     
    	_delay_ms(10);
    	LCD_send_command(0x38);
    	LCD_send_command(0x0C);
    	LCD_send_command(0x01);
    	_delay_ms(10);
    	LCD_send_command(0x06);
    }
     
    /* This function moves the cursor the line y column x on the LCD module*/
    void LCD_goto(unsigned char y, unsigned char x)
    {
    	unsigned char firstAddress[] = {0x80,0xC0,0x94,0xD4};
     
    	LCD_send_command(firstAddress[y-1] + x-1);
    	_delay_ms(10);	
    }
     
    void LCD_print(char *string)
    {
    	unsigned char i;
     
    	while(string[i]!=0)
    	{
    		LCD_send_data(string[i]);
    		i++;
    	}
    }
     
    void LCD_blink()
    {
    	LCD_send_command(0x08);
    	_delay_ms(250);
    	LCD_send_command(0x0C);
    	_delay_ms(250);
    }
     
    void LCD_scroll(unsigned char direction)
    {
    	if(direction == 0)
    		LCD_send_command(0x18);
    	else
    		LCD_send_command(0x1C);
     
    	_delay_ms(500);
    }
    Dernière modification par Jack ; 04/06/2013 à 13h15. Motif: balises code

Discussions similaires

  1. [Blanc] panne refrigerateur brandt SL3720, afficheur clignote et bippe
    Par invitef3b5e5da dans le forum Dépannage
    Réponses: 6
    Dernier message: 29/04/2012, 10h29
  2. [Blanc] Réfrigérateur Samsung HS : Afficheur clignote
    Par inviteacd4cdba dans le forum Dépannage
    Réponses: 5
    Dernier message: 22/03/2011, 21h08
  3. librairie protocole lcd sous ATmega
    Par inviteb61e4847 dans le forum Électronique
    Réponses: 6
    Dernier message: 23/02/2011, 11h17
  4. LCD graphique sur ATMEGA
    Par invite3570b5f7 dans le forum Électronique
    Réponses: 6
    Dernier message: 07/12/2010, 08h55
  5. afficheur lcd en afficheur 7 segment
    Par invite3cc40cdb dans le forum Électronique
    Réponses: 3
    Dernier message: 04/02/2008, 10h43
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...