Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ***********************************************************************
- //
- // Demo program pro vyuku predmetu APPS (07/2014)
- // Petr Olivka, katedra informatiky, FEI, VSB-TU Ostrava
- // email:petr.olivka@vsb.cz
- //
- // Priklad pouzit vyvojoveho nastroje AVR-KIT:
- // ovladani LED a tlacitek.
- // Blikani LED PIND2 a PIND3 lze zastavit stiskem tlacitka PIND4-PIND7
- //
- // ***********************************************************************
- // nejprve hlavickovy soubor AVR-KITu
- #include "../avrkit/avrkit.h"
- #include <stdio.h>
- #include <avr/io.h>
- int T,T1R,T0R,T1L,T0L,procenta1,procenta2,tlacitko,blue,red;
- int main()
- {
- // inicializace prostredi
- avrkit_init();
- printf( "AVR-KIT ready...\n\n" );
- // Cely port b jako vystup
- DDRB |= 0xFF;
- red = 0;
- blue = 0;
- int procenta1 = 10 ;
- int procenta2 = 100;
- int T = 10;
- int T1L = procenta1 * T/100;
- int T0L = T - T1L;
- int T1R = procenta2 * T/100;
- int T0R = T - T1R;
- while ( 1 )
- {
- /*if ( read_butt() == 0b11100000 )
- {
- tlacitko = 1;
- }
- if ( read_butt() == 0b11010000 )
- {
- tlacitko = 2;
- }
- if (tlacitko == 1)
- {
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB1 );
- // zpozdeni
- delay_ms(T1L);
- PORTB &= ~( 1 << PINB1);
- delay_ms(T0L);
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB1 );
- // zpozdeni
- delay_ms(T1L);
- PORTB &= ~( 1 << PINB1);
- delay_ms(T0L);
- }
- if (tlacitko == 2)
- {
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB5 );
- // zpozdeni
- delay_ms(T1R);
- PORTB &= ~( 1 << PINB5);
- delay_ms(T0R);
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB5 );
- // zpozdeni
- delay_ms(T1R);
- PORTB &= ~( 1 << PINB5);
- delay_ms(T0R);
- }
- }
- */
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB1 );
- // zpozdeni
- delay_ms(T1L);
- PORTB &= ~( 1 << PINB1);
- delay_ms(T0L);
- // rozsviceni LED PIND2
- PORTB |= ( 1 << PINB5 );
- // zpozdeni
- delay_ms(T1R);
- PORTB &= ~( 1 << PINB5);
- delay_ms(T0R);
- /*
- if ( read_butt() == 0b11100000 )
- {
- tlacitko = 1;
- }
- if ( read_butt() == 0b11010000 )
- {
- tlacitko = 2;
- }
- if ( read_butt() == 0b10110000 )
- {
- tlacitko = 3;
- }
- if ( read_butt() == 0b01110000)
- {
- tlacitko = 4;
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement