Professional Documents
Culture Documents
Coding Susi
Coding Susi
h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
#define Lamp1 PORTA.0
#define Lamp2 PORTA.1
#define Lamp3 PORTA.2
#define Lamp4 PORTA.3
#define Lamp5 PORTA.4
#define Lamp6 PORTA.5
#define Lamp7 PORTA.6
#define Lamp8 PORTA.7
char val;
void main(void)
{
// Declare your local variables here
// Port B 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
PORTB=0x00;
DDRB=0x00;
// 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
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=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: Of
// Input Capture on Falling Edge
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCSR=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x47;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
while (1)
{
// Place your code here
val=getchar();
if(val=='1'){
Lamp1=1;
}else
if(val=='2'){
Lamp2=1;
}else
if(val=='3'){
Lamp3=1;
}else
if(val=='4'){
Lamp4=1;
}else
if(val=='5'){
Lamp5=1;
}else
if(val=='6'){
Lamp6=1;
}else
if(val=='7'){
Lamp7=1;
}else
if(val=='8'){
Lamp8=1;
}
else
if(val=='9'){
Lamp1=1;
Lamp2=1;
Lamp3=1;
Lamp4=1;
Lamp5=1;
Lamp6=1;
Lamp7=1;
Lamp8=1;
}else
if(val=='A'){
Lamp1=0;
}else
if(val=='B'){
Lamp2=0;
}else
if(val=='C'){
Lamp3=0;
}else
if(val=='D'){
Lamp4=0;
}else
if(val=='E'){
Lamp5=0;
}else
if(val=='F'){
Lamp6=0;
}else
if(val=='G'){
Lamp7=0;
}else
if(val=='H'){
Lamp8=0;
}else
if(val=='I'){
Lamp1=0;
Lamp2=0;
Lamp3=0;
Lamp4=0;
Lamp5=0;
Lamp6=0;
Lamp7=0;
Lamp8=0;
}
}
}