AbstractBeliefs

Untitled

Sep 25th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. int state=0;
  2. int oldstate=0;
  3.  
  4. void setup(){
  5. pinMode(3,INPUT);
  6. Serial.begin(9600);
  7. }
  8.  
  9.  
  10. void loop(){
  11. state=digitalRead(3);
  12.  
  13. if(state!=oldstate){
  14. if(state==HIGH){
  15. Serial.print(5, DEC);
  16. }
  17. }
  18.  
  19. oldstate=state;
  20. }
  21.  
  22.  
  23. PYTHON
  24.  
  25.  
  26.  
  27.  
  28. import os,serial
  29. s=serial.Serial("/dev/tty.usbmodemfa141",9600)
  30. while(1):
  31. if s.inWaiting() > 0:
  32. print s.read()
Advertisement
Add Comment
Please, Sign In to add comment