Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../avrkit/avrkit.h"
- #include <stdio.h>
- #include <avr/io.h>
- int vel(int speed)
- {
- switch(read_butt()){
- case 0b01110000:
- speed=100;
- break;
- case 0b10110000:
- speed=600;
- break;
- case 0b11010000:
- speed=400;
- break;
- case 0b11100000:
- speed=100;
- break;
- default:
- break;
- }
- return speed;
- }
- int main()
- {
- // inicializace prostredi
- avrkit_init();
- //ÚLOHY 1,2
- /*DDRC=0xFF;
- PORTC=7;
- delay_ms(1000);
- while(1){
- for(int i=0;i<5;i++)
- {
- PORTC=PORTC<<1;
- delay_ms(1000);
- }
- PORTC=0b11100000;
- while(read_butt() == 0b11110000)
- {
- }
- for(int i=0;i<5;i++)
- {
- PORTC=PORTC>>1;
- delay_ms(1000);
- }
- }*/
- //ÚLOHA 3
- /*DDRC=0xFF;
- int speed=1000;
- PORTC=7;
- delay_ms(speed);
- while(1){
- for(int i=0;i<5;i++)
- {
- speed=vel(speed);
- PORTC=PORTC<<1;
- delay_ms(speed);
- }
- PORTC=0b11100000;
- for(int i=0;i<5;i++)
- {
- speed=vel(speed);
- PORTC=PORTC>>1;
- delay_ms(speed);
- }
- }*/
- DDRC=0xFF;
- int light=10;
- int night=0;
- PORTB=1;
- while (1)
- {
- if (read_butt()== 0b11100000)
- {
- if(light<10)
- {
- light++;
- }
- }
- if(read_butt()== 0b11010000)
- {
- if(light>0)
- {
- light--;
- }
- }
- night=10-light;
- PORTB=1;
- delay_ms(light);
- PORTB=0;
- delay_ms(night);
- printf("%d\n",light);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement