Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- static uint16_t delayCnt;
- static uint16_t step = 5;
- void delay(uint16_t t){
- uint8_t i;
- for(i=0; i<t; i++){
- _delay_ms(1);
- }
- }
- void aktivnost(){
- PORTA = PORTA << 1;
- if(PORTA != 0xfe && PORTA != 0b11111100){
- PORTA |= 0x01;
- }
- }
- int main(void){
- PORTA = 0xff;
- DDRA = 0xff;
- DDRB = 0;
- PORTB = _BV(0) | _BV(1);
- while (1) {
- if(bit_is_clear(PINB, 0)){
- if(delayCnt + step < 500)
- delayCnt += step;
- }
- if(bit_is_clear(PINB, 1)){
- if(delayCnt + step > 100)
- delayCnt -= step;
- }
- aktivnost();
- delay(delayCnt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement