Advertisement
Atdiy

Untitled

Aug 18th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. /*
  2. Button Display.c
  3.  
  4. Dislays the state of the P3 button in the SimpleIDE Terminal.
  5. 1 -> button pressed, 0 -> button not pressed.
  6.  
  7. http://learn.parallax.com/propeller-c-simple-circuits/check-pushbuttons
  8. */
  9.  
  10. #include "simpletools.h" // Include simpletools
  11.  
  12. int main() // main function
  13. {
  14. while(1) // Endless loop
  15. {
  16. int button = input(5); // P3 input -> button variable
  17. printf("button = %d\n", button); // Display button state
  18.  
  19. if(button == 1)
  20. {
  21. high(0);
  22. pause(50);
  23. low(0);
  24. pause(50);
  25. }
  26. else
  27. {
  28. high(1);
  29. pause(50);
  30. low(1);
  31. pause(50);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement