SlideShare une entreprise Scribd logo
1  sur  7
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date
: 29/11/2013
Author : NeVaDa
Company :
Comments:
Chip type
: ATmega164PA
Program type
: Application
AVR Core Clock frequency: 8,000000 MHz
Memory model
: Small
External RAM size
: 0
Data Stack size
: 256
*****************************************************/
#include <mega164a.h>
#include <delay.h>
#include <stdio.h>
char numero;
int i=0;
int a,c;
// Declare your global variables here
// Alphanumeric LCD Module functions
#include <alcd.h>
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
i++;
if(i==1)
{
lcd_clear();
lcd_gotoxy(0,0);

4

// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_puts("SISTEMA");
lcd_gotoxy(0,1);
// posicion en la lcd del dato

4

x menor a 9 y y menor a

lcd_puts("ON");
}
if(i==2)
{
lcd_clear();
lcd_gotoxy(0,0);

4
4

// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_puts("SISTEMA");
lcd_gotoxy(0,1);
// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_puts("OFF");
i=0;
PORTB=0X00;
numero=0;
}
}
// Standard Input/Output functions
void main(void)
{
// Declare your local variables here
// Crystal Oscillator division factor: 1
#pragma optsizeCLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out
Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;
//
//
//
//

Timer/Counter 1 initialization
Clock source: System Clock
Clock value: Timer1 Stopped
Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2A output: Disconnected
// OC2B output: Disconnected
ASSR=0x00;
TCCR2A=0x00;
TCCR2B=0x00;
TCNT2=0x00;
OCR2A=0x00;
OCR2B=0x00;
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Any change
// INT1: Off
// INT2: Off
// Interrupt on any change on pins PCINT0-7: Off
// Interrupt on any change on pins PCINT8-15: Off
// Interrupt on any change on pins PCINT16-23: Off
// Interrupt on any change on pins PCINT24-31: Off
EICRA=0x01;
EIMSK=0x01;
EIFR=0x01;
PCICR=0x00;
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=0x00;
// Timer/Counter 1 Interrupt(s) initialization
TIMSK1=0x00;
// Timer/Counter 2 Interrupt(s) initialization
TIMSK2=0x00;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x18;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x33;
// USART1 initialization
// USART1 disabled
UCSR1B=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
ADCSRB=0x00;
DIDR1=0x00;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
// Alphanumeric LCD initialization
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTA Bit 0
// RD - PORTA Bit 1
// EN - PORTA Bit 2
// D4 - PORTA Bit 4
// D5 - PORTA Bit 5
// D6 - PORTA Bit 6
// D7 - PORTA Bit 7
// Characters/line: 8
lcd_init(8);
// Global enable interrupts
#asm("sei")
lcd_gotoxy(0,0);
4

x menor a 9 y y menor a

lcd_puts("SISTEMA");
lcd_gotoxy(0,1);

4

// posicion en la lcd del dato

// posicion en la lcd del dato

x menor a 9 y y menor a

// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_puts("OFF");

while (1)
{
/*
lcd_gotoxy(0,0);
4
lcd_putchar('A');
delay_ms(200);
lcd_clear();
delay_ms(200);
lcd_gotoxy(0,3);
4
lcd_puts("HOLA");

// para enviar caracteres

// posicion en la lcd del dato

x menor a 9 y y menor a
lcd_gotoxy(0,1);
4

// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_putchar('a');
*/
if(i==1)

{

numero=getchar();
// scanf("%c", &dato);
switch (numero) {
case '1':
delay_ms(200);
lcd_gotoxy(0,3);
4

// posicion en la lcd del dato

x menor a 9 y y menor a

lcd_puts("JUEGO 1");
for(a=0;a<10;a++)
{
PORTB=0XFF;
delay_ms(200);
PORTB=0X00;
delay_ms(200);
}

//puerto A en alto
//libreria de retardo
//puerto A en bajo
//libreria de retardo

break;

4

case '2':
delay_ms(200);
lcd_gotoxy(0,3);

// posicion en la lcd del dato

lcd_puts("JUEGO 2");
for(c=0;c<5;c++)
{
PORTB=0x01;
delay_ms(200);
PORTB=0x02;
delay_ms(200);
PORTB=0x04;
delay_ms(200);
PORTB=0x08;
delay_ms(200);
PORTB=0x10;
delay_ms(200);
PORTB=0x20;
delay_ms(200);
PORTB=0x40;
delay_ms(200);
PORTB=0x80;
delay_ms(200);
}
break;

default:
};

//libreria de retardo
//libreria de retardo
//libreria de retardo
//libreria de retardo
//libreria de retardo
//libreria de retardo
//libreria de retardo
//libreria de retardo

x menor a 9 y y menor a
}

}
}
}

}
}

Contenu connexe

Plus de Eduardo Salazar

Plus de Eduardo Salazar (9)

Madeon discography
Madeon discographyMadeon discography
Madeon discography
 
Si
SiSi
Si
 
30 s
30 s30 s
30 s
 
Tx y rx usart
Tx y rx usartTx y rx usart
Tx y rx usart
 
Familias lOGICa
Familias lOGICaFamilias lOGICa
Familias lOGICa
 
Lady gaga..
Lady gaga..Lady gaga..
Lady gaga..
 
Un anciano amigo mio me conto
Un anciano amigo mio me contoUn anciano amigo mio me conto
Un anciano amigo mio me conto
 
Un anciano amigo mio me conto
Un anciano amigo mio me contoUn anciano amigo mio me conto
Un anciano amigo mio me conto
 
Un anciano amigo mio me conto
Un anciano amigo mio me contoUn anciano amigo mio me conto
Un anciano amigo mio me conto
 

Lcd

  • 1. /***************************************************** This program was produced by the CodeWizardAVR V2.05.0 Professional Automatic Program Generator © Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 29/11/2013 Author : NeVaDa Company : Comments: Chip type : ATmega164PA Program type : Application AVR Core Clock frequency: 8,000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega164a.h> #include <delay.h> #include <stdio.h> char numero; int i=0; int a,c; // Declare your global variables here // Alphanumeric LCD Module functions #include <alcd.h> // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { i++; if(i==1) { lcd_clear(); lcd_gotoxy(0,0); 4 // posicion en la lcd del dato x menor a 9 y y menor a lcd_puts("SISTEMA"); lcd_gotoxy(0,1); // posicion en la lcd del dato 4 x menor a 9 y y menor a lcd_puts("ON"); } if(i==2) { lcd_clear(); lcd_gotoxy(0,0); 4 4 // posicion en la lcd del dato x menor a 9 y y menor a lcd_puts("SISTEMA"); lcd_gotoxy(0,1); // posicion en la lcd del dato x menor a 9 y y menor a lcd_puts("OFF"); i=0; PORTB=0X00; numero=0;
  • 2. } } // Standard Input/Output functions void main(void) { // Declare your local variables here // Crystal Oscillator division factor: 1 #pragma optsizeCLKPR=0x80; CLKPR=0x00; #ifdef _OPTIMIZE_SIZE_ #pragma optsize+ #endif // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTB=0x00; DDRB=0xFF; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF // OC0A output: Disconnected // OC0B output: Disconnected TCCR0A=0x00; TCCR0B=0x00; TCNT0=0x00; OCR0A=0x00; OCR0B=0x00; // // // // Timer/Counter 1 initialization Clock source: System Clock Clock value: Timer1 Stopped Mode: Normal top=0xFFFF
  • 3. // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=0xFF // OC2A output: Disconnected // OC2B output: Disconnected ASSR=0x00; TCCR2A=0x00; TCCR2B=0x00; TCNT2=0x00; OCR2A=0x00; OCR2B=0x00; // External Interrupt(s) initialization // INT0: On // INT0 Mode: Any change // INT1: Off // INT2: Off // Interrupt on any change on pins PCINT0-7: Off // Interrupt on any change on pins PCINT8-15: Off // Interrupt on any change on pins PCINT16-23: Off // Interrupt on any change on pins PCINT24-31: Off EICRA=0x01; EIMSK=0x01; EIFR=0x01; PCICR=0x00; // Timer/Counter 0 Interrupt(s) initialization TIMSK0=0x00; // Timer/Counter 1 Interrupt(s) initialization TIMSK1=0x00; // Timer/Counter 2 Interrupt(s) initialization TIMSK2=0x00; // USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Receiver: On // USART0 Transmitter: On // USART0 Mode: Asynchronous // USART0 Baud Rate: 9600 UCSR0A=0x00; UCSR0B=0x18;
  • 4. UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x33; // USART1 initialization // USART1 disabled UCSR1B=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; ADCSRB=0x00; DIDR1=0x00; // ADC initialization // ADC disabled ADCSRA=0x00; // SPI initialization // SPI disabled SPCR=0x00; // TWI initialization // TWI disabled TWCR=0x00; // Alphanumeric LCD initialization // Connections specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTA Bit 0 // RD - PORTA Bit 1 // EN - PORTA Bit 2 // D4 - PORTA Bit 4 // D5 - PORTA Bit 5 // D6 - PORTA Bit 6 // D7 - PORTA Bit 7 // Characters/line: 8 lcd_init(8); // Global enable interrupts #asm("sei") lcd_gotoxy(0,0); 4 x menor a 9 y y menor a lcd_puts("SISTEMA"); lcd_gotoxy(0,1); 4 // posicion en la lcd del dato // posicion en la lcd del dato x menor a 9 y y menor a // posicion en la lcd del dato x menor a 9 y y menor a lcd_puts("OFF"); while (1) { /* lcd_gotoxy(0,0); 4 lcd_putchar('A'); delay_ms(200); lcd_clear(); delay_ms(200); lcd_gotoxy(0,3); 4 lcd_puts("HOLA"); // para enviar caracteres // posicion en la lcd del dato x menor a 9 y y menor a
  • 5. lcd_gotoxy(0,1); 4 // posicion en la lcd del dato x menor a 9 y y menor a lcd_putchar('a'); */ if(i==1) { numero=getchar(); // scanf("%c", &dato); switch (numero) { case '1': delay_ms(200); lcd_gotoxy(0,3); 4 // posicion en la lcd del dato x menor a 9 y y menor a lcd_puts("JUEGO 1"); for(a=0;a<10;a++) { PORTB=0XFF; delay_ms(200); PORTB=0X00; delay_ms(200); } //puerto A en alto //libreria de retardo //puerto A en bajo //libreria de retardo break; 4 case '2': delay_ms(200); lcd_gotoxy(0,3); // posicion en la lcd del dato lcd_puts("JUEGO 2"); for(c=0;c<5;c++) { PORTB=0x01; delay_ms(200); PORTB=0x02; delay_ms(200); PORTB=0x04; delay_ms(200); PORTB=0x08; delay_ms(200); PORTB=0x10; delay_ms(200); PORTB=0x20; delay_ms(200); PORTB=0x40; delay_ms(200); PORTB=0x80; delay_ms(200); } break; default: }; //libreria de retardo //libreria de retardo //libreria de retardo //libreria de retardo //libreria de retardo //libreria de retardo //libreria de retardo //libreria de retardo x menor a 9 y y menor a