Advertisement
mikolajmki

asd

Oct 28th, 2022
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. /*
  2. * GccApplication4.c
  3. *
  4. * Created: 28.10.2022 08:54:14
  5. * Author : Student_PL
  6. */
  7.  
  8. #include <avr/io.h>
  9. #include <util/delay.h>
  10.  
  11.  
  12. int main(void)
  13. {
  14. DDRA = 0xFF;
  15. //int state = 0;
  16. DDRB = 0xF0; //
  17. PORTB = 0x0F; //
  18. //PORTD &=~(1<<4);
  19. PORTA=3;
  20. while (1)
  21. {
  22. _delay_ms(3);
  23. if((PINB&(1<<0))==0){
  24. PORTA=0b00000001;
  25. }
  26. if((PINB&(1<<1))==0){
  27. PORTA=0b00000002;
  28. }
  29. if((PINB&(1<<2))==0){
  30. PORTA=0b00000003;
  31. }
  32. if((PINB&(1<<3))==0){
  33. PORTA=0b00000004;
  34. }
  35.  
  36. // while((PIND & 0x0F) != 0x0F) {
  37. // PORTD &= 0x0F;
  38. // }
  39. // while((PIND & 0x0F) == 0x0F) {
  40. // while((PIND & 0x0F) == 0x0F) {
  41. // _delay_ms(20);
  42. // }
  43. // _delay_ms (40);
  44. // }
  45. // PORTD = 0xEF;
  46. // if((PIND & 0x0F) != 0x0F) {
  47. // state = 1;
  48. // }
  49. // if (state == 1) {
  50. // PORTA = 0b00000001;
  51. }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement