{"id":354,"date":"2012-05-20T21:23:20","date_gmt":"2012-05-20T21:23:20","guid":{"rendered":"http:\/\/www.redrobe.com\/mike\/?p=354"},"modified":"2012-05-20T21:23:20","modified_gmt":"2012-05-20T21:23:20","slug":"arduino-andultrasonic-sensor-to-my-arduino-board-robot-eyes","status":"publish","type":"post","link":"https:\/\/redrobe.com\/mike\/arduino-andultrasonic-sensor-to-my-arduino-board-robot-eyes\/","title":{"rendered":"Arduino and SR04 ultrasonic sensor &#8211; robot eyes !"},"content":{"rendered":"<p>Hooked an SR04 ultrasonic sensor to my <a href=http:\/\/www.redrobe.com\/mike\/arduino-starter-kit\/>arduino board<\/a> &#8211; robot eyes !<\/p>\n<p>Ranger sensor uses sonar to give accurate distance measurement to objects or obstacles placed in front of it. They&#8217;re surprisingly sensitive \/ accurate &#8211; I was able to reliably measure to a millimeter at 15cm range.<\/p>\n<p>These sensors are also now VERY cheap \u00a32.37 (4$) delivered from HK, and accurate to a few mm.<\/p>\n<p>Added a servo for visual feedback:<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/P2x0AP4e4uQ\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>Arduino code is basically sending a trigger on one pin, receiving a timing value on another,<br \/>\nwhich can then be converted into a distance:<\/p>\n<ul>\npinMode(TP,OUTPUT);<br \/>\n   pinMode(EP,INPUT);<br \/>\n   Trig_pin=TP;<br \/>\n   Echo_pin=EP;<\/p>\n<p>digitalWrite(Trig_pin, LOW);<br \/>\n  delayMicroseconds(2);<br \/>\n  digitalWrite(Trig_pin, HIGH);<br \/>\n  delayMicroseconds(10);<br \/>\n  digitalWrite(Trig_pin, LOW);<br \/>\n  duration = pulseIn(Echo_pin,HIGH);<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hooked an SR04 ultrasonic sensor to my arduino board &#8211; robot eyes ! Ranger sensor uses sonar to give accurate [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[16,33,51],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-arduino-2","tag-arduino","tag-electronics","tag-robots"],"_links":{"self":[{"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":0,"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"wp:attachment":[{"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redrobe.com\/mike\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}