Advertisement
SIKER_98

asdasd

Apr 28th, 2020
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <REGX51.H>
  2. #include <intrins.h> // do _nop_
  3.  
  4. #define TRUE 1
  5.  
  6. void przycisk(void) interrupt 0 {// dzialanie po wcisnieciu
  7. P1++;
  8. }
  9.  
  10. void setup(void){
  11. P1 = 0x00;
  12. EX0 = 1;
  13. IT0 = 1; // detekcja zbocza opadajacego ( nie wykrycie stanu niskiego )
  14. EA = 1;
  15. }
  16.  
  17. void delay(unsigned char ms) // opuzniacz na zasadzie instrukcji nop{
  18. unsigned long us = 1000 * ms;
  19. while (us--)
  20. _nop_();
  21. }
  22.  
  23. void dioda(){
  24. if(P1%2 == 0){
  25. P0_0 = 0x00;
  26. P2_0 = 0x00;
  27. delay(5);
  28. P0_0 = 0x01;
  29. P2_0 = 0x01;
  30. delay(5);
  31. }
  32. else{
  33. P0_0 = 0x01;
  34. P2_0 = 0x00;
  35. }
  36. }
  37.  
  38. void main(void){
  39. setup();
  40. while (TRUE)
  41. dioda();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement