Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int state=0;
- int oldstate=0;
- void setup(){
- pinMode(3,INPUT);
- Serial.begin(9600);
- }
- void loop(){
- state=digitalRead(3);
- if(state!=oldstate){
- if(state==HIGH){
- Serial.print(5, DEC);
- }
- }
- oldstate=state;
- }
- PYTHON
- import os,serial
- s=serial.Serial("/dev/tty.usbmodemfa141",9600)
- while(1):
- if s.inWaiting() > 0:
- print s.read()
Advertisement
Add Comment
Please, Sign In to add comment