trigPin = 7echoPin = 8arduino = Runtime.createAndStart("arduino", "Arduino")arduino.connect("COM15")sr04 = Runtime.createAndStart("sr04", "UltrasonicSensor")sr04.attach(arduino, trigPin, echoPin)# blocking examplesduration = sr04.ping()print durationrange = sr04.range()print range# non blocking - event examplesr04.startRanging()
References
- (TODO - add UltrasonicSenor Service Page Link)
- http://www.parallax.com/product/28015
- http://arduino.cc/en/Tutorial/ping
thanks !
that work very well :-)