Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * switch temp.c
- *
- * Created: 07.10.2021 15:19:00
- * Author : rockd
- */
- /*
- * C Program to Blink an LED with ATmega32 Microcontroller
- *
- * Author: DILIP RAJA
- */
- #include <avr/io.h>
- #define F_CPU 1000000
- #include <util/delay.h>
- #define time 80
- void pause (unsigned long a)
- {
- unsigned long counter ;
- for(counter=a;counter>0;counter--)
- asm("nop");
- }
- int main(void)
- {
- uint8_t i=0;
- DDRB = 0b11111101;
- //DDRC = 0x0;
- PORTB|=(1<<PB1);
- while(1)
- {
- //_delay_ms(20);
- pause (100L*time);
- switch(i)
- {
- case 0:
- PORTB|=(1<<PB0);
- break;
- pause (5L*time);
- case 1:
- PORTB|=(1<<PB0);
- pause (100L*time);
- //_delay_ms(500);
- PORTB&=~(1<<PB0);
- pause (100L*time);
- //_delay_ms(500);
- break;
- pause (5L*time);
- case 2:
- PORTB|=(1<<PB0);
- pause (20L*time);
- //_delay_ms(100);
- PORTB&=~(1<<PB0);
- pause (20L*time);
- //_delay_ms(100);
- break;
- pause (5L*time);
- case 3:
- PORTB|=(1<<PB0);
- pause (10L*time);
- //_delay_ms(50);
- PORTB&=~(1<<PB0);
- pause (10L*time);
- //_delay_ms(50);
- break;
- pause (5L*time);
- case 4:
- PORTB|=(1<<PB0);
- pause (5L*time);
- //_delay_ms(20);
- PORTB&=~(1<<PB0);
- pause (5L*time);
- //_delay_ms(20);
- break;
- pause (5L*time);
- case 5:
- PORTB|=(1<<PB0);
- pause (2L*time);
- //_delay_ms(1000);
- PORTB&=~(1<<PB0);
- pause (2L*time);
- //_delay_ms(1000);
- break;
- pause (5L*time);
- //default:
- //PORTD|=(1<<PB6);
- //break;
- }
- pause (1000L*time);
- //_delay_ms(400);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment