{"id":755,"date":"2019-02-22T22:52:11","date_gmt":"2019-02-22T21:52:11","guid":{"rendered":"http:\/\/unckel.de\/blog\/?p=755"},"modified":"2019-12-07T22:03:24","modified_gmt":"2019-12-07T21:03:24","slug":"arduino-parksensor-in-der-garage","status":"publish","type":"post","link":"https:\/\/unckel.de\/blog\/arduino-parksensor-in-der-garage\/","title":{"rendered":"Arduino: Parksensor in der Garage"},"content":{"rendered":"\n<p>Gro\u00dfes Auto, kleine Garage &#8211; jeder Zentimeter z\u00e4hlt! Ich m\u00f6chte mein Auto genau so in der Garage abstellen, dass das Garagentor gerade noch zu geht um vor dem Auto m\u00f6glichst viel Platz zu haben. Nat\u00fcrlich gibt es daf\u00fcr die verschiedensten einfachen Methoden. Als Bastler habe ich mich aber f\u00fcr eine L\u00f6sung mit Arduino entschieden!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"547\" src=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405-1000x547.jpg\" alt=\"\" class=\"wp-image-756\" srcset=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405-1000x547.jpg 1000w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405-400x219.jpg 400w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405-768x420.jpg 768w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405-300x164.jpg 300w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/20190222_222405.jpg 1679w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption>Entwurf<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"414\" src=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1-1000x414.jpg\" alt=\"\" class=\"wp-image-758\" srcset=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1-1000x414.jpg 1000w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1-400x166.jpg 400w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1-768x318.jpg 768w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1-300x124.jpg 300w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/Grafik1-1.jpg 1520w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption>Abh\u00e4ngig der Distanz zum Sensor \u00e4ndert sich die Darstellung der 8&#215;8 Dot Matrix.<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;SR04.h>\n#include &lt;LedControl.h>\n\nSR04 sr04 = SR04(3, 4);\nLedControl lc = LedControl(12, 10, 11, 1);\n\nint distance;  \/\/ sensor distance\nint parkpos;   \/\/ park distance in front of sensor in cm\nint ledbrght;  \/\/ brightness\n\n\/\/ all signs\/frames\nbyte frm_dis_6[8] = { B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001 };\nbyte frm_dis_5[8] = { B01000001, B01000001, B01000001, B01000001, B01000001, B01000001, B01000001, B01000001 };\nbyte frm_dis_4[8] = { B00100001, B00100001, B00100001, B00100001, B00100001, B00100001, B00100001, B00100001 };\nbyte frm_dis_3[8] = { B00010001, B00010001, B00010001, B00010001, B00010001, B00010001, B00010001, B00010001 };\nbyte frm_dis_2[8] = { B00001001, B00001001, B00001001, B00001001, B00001001, B00001001, B00001001, B00001001 };\nbyte frm_dis_1[8] = { B00000101, B00000101, B00000101, B00000101, B00000101, B00000101, B00000101, B00000101 };\nbyte frm_arr_a[8] = { B00001000, B00001100, B11111110, B11111111, B11111110, B00001100, B00001000, B00000000 };\nbyte frm_arr_b[8] = { B00010000, B00110000, B01111111, B11111111, B01111111, B00110000, B00010000, B00000000 };\nbyte frm_stop[8]  = { B00111100, B01111110, B11111111, B11111111, B11111111, B11111111, B01111110, B00111100 };\n\nvoid writeSign(byte arr[8]) {\n  for (int i = 0; i &lt; 8; i++) {\n    lc.setRow(0, i, arr[i]);\n  }\n}\n\nvoid setup() {\n\n  \/\/ start MAX72xx, set brightness and clear display \n  lc.shutdown(0, false);\n  lc.setIntensity(0, 5);\n  lc.clearDisplay(0);\n\n  Serial.begin(9600);\n  delay(1000);\n}\n\nvoid loop() {\n\n  \/\/ read poti B and set led intensity\n  ledbrght = analogRead(A7);\n  ledbrght = ledbrght\/75; \/\/ 0 - 15\n  lc.setIntensity(0, ledbrght);\n\n  \/\/ read distance in cm\n  distance = sr04.Distance();\n\n  \/\/ read poti A and set park position in cm  \n  parkpos = analogRead(A3);\n  parkpos = parkpos\/5.2 + 10; \/\/ 10 - 200\n\n  \/\/ tha rocket science magic ;)\n  if      (distance &lt; 200 + parkpos  &amp;&amp; distance >= 30 + parkpos) { writeSign(frm_arr_a); }\n  else if (distance &lt;  30 + parkpos  &amp;&amp; distance >= 25 + parkpos) { writeSign(frm_dis_6); }\n  else if (distance &lt;  25 + parkpos  &amp;&amp; distance >= 20 + parkpos) { writeSign(frm_dis_5); }\n  else if (distance &lt;  20 + parkpos  &amp;&amp; distance >= 15 + parkpos) { writeSign(frm_dis_4); }\n  else if (distance &lt;  15 + parkpos  &amp;&amp; distance >= 10 + parkpos) { writeSign(frm_dis_3); }\n  else if (distance &lt;  10 + parkpos  &amp;&amp; distance >=  5 + parkpos) { writeSign(frm_dis_2); }\n  else if (distance &lt;   5 + parkpos  &amp;&amp; distance >=      parkpos) { writeSign(frm_dis_1); }\n  else if (distance &lt;       parkpos  &amp;&amp; distance >= -5 + parkpos) { writeSign(frm_stop);  }\n  else if (distance &lt;  -5 + parkpos )                             { writeSign(frm_arr_b); }\n  else                                                            { lc.clearDisplay(0);   }\n\n  delay(100);\n}\n\n\n<\/code><\/pre>\n\n\n\n<p>Geh\u00e4use und weitere Infos folgen&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gro\u00dfes Auto, kleine Garage &#8211; jeder Zentimeter z\u00e4hlt! Ich m\u00f6chte mein Auto genau so in der Garage abstellen, dass das Garagentor gerade noch zu geht um vor dem Auto m\u00f6glichst viel Platz zu haben. Nat\u00fcrlich gibt es daf\u00fcr die verschiedensten einfachen Methoden. Als Bastler habe ich mich aber f\u00fcr eine L\u00f6sung mit Arduino entschieden! Geh\u00e4use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-755","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/comments?post=755"}],"version-history":[{"count":1,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/755\/revisions"}],"predecessor-version":[{"id":759,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/755\/revisions\/759"}],"wp:attachment":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/media?parent=755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/categories?post=755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/tags?post=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}