Python serial inwaiting example

broken image
broken image

PingTime=pingTime/1000000 //convert pingTime to seconds by dividing by 1000000 (microseconds in a second) PingTime = pulseIn(echoPin, HIGH) //pingTime is presented in microceconds

broken image

put your main code here, to run repeatedly:ĭigitalWrite(trigPin, LOW) //Set trigger pin lowĭelayMicroseconds(2000) //Let signal settleĭigitalWrite(trigPin, HIGH) //Set trigPin highĭelayMicroseconds(15) //Delay in high stateĭigitalWrite(trigPin, LOW) //ping has now been sentĭelayMicroseconds(10) //Delay in low state put your setup code here, to run once: Int echoPin=11 //Sensor Echo pin connected to Arduino pin 11įloat pingTime //time for ping to travel from sensor to target and returnįloat targetDistance //Distance to Target in inchesįloat speedOfSound=776.5 //Speed of sound in miles per hour when temp is 77 degrees.

broken image

What could be causing this?Īrduino code: int trigPin=13 //Sensor Trig pin connected to Arduino pin 13 However when I run it in python it has all sorts of random new lines and \r's thrown in there. When I run my code in the serial monitor it looks just fine. I'm having a hard time getting the distance measurements over to python.