Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /*
  2. * binluku2.c
  3. *
  4. * Created: 25.11.2014 13:27:48
  5. * Author: gg eazy
  6. */
  7.  
  8.  
  9.  
  10. #define F_CPU 1000000UL
  11. #include <avr/io.h>
  12. #include <util/delay.h>
  13. #define SWITCH3 !(PIND & (1<<PORTD4))
  14. #define SWITCH4 !(PIND & (1<<PORTD5))
  15. #define YLOS 1
  16. #define ALAS 0
  17.  
  18.  
  19. int main(void){
  20. unsigned char luku = 0, suunta=0;
  21. unsigned int viive=50;
  22. DDRB = 0xFF;
  23. PORTB= 0xFF;
  24. DDRD = 0x40;
  25. PORTD= 0x7C;
  26. luku = 0x01;
  27. while(1){
  28. PORTB=~luku;
  29. _delay_ms(viive);
  30. if(suunta == YLOS){
  31. luku++;
  32. }
  33. if(suunta == ALAS){
  34. luku--;
  35. }
  36. if(luku==255){
  37. suunta = ALAS;
  38. }
  39. if(luku==0){
  40. suunta = YLOS;
  41. }
  42. if(SWITCH3==0){
  43. suunta = ALAS;
  44. }
  45. if(SWITCH4==0){
  46. suunta = YLOS;
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement