{"id":470,"date":"2011-08-12T21:11:38","date_gmt":"2011-08-12T19:11:38","guid":{"rendered":"http:\/\/www.capri-soft.de\/blog\/?p=470"},"modified":"2011-08-13T17:13:29","modified_gmt":"2011-08-13T15:13:29","slug":"projektvorstellung-microcontrollerbasierter-roboter-mit-infrarotsensor","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=470","title":{"rendered":"Projektvorstellung: Microcontrollerbasierter Roboter mit Infrarotsensor (1) und -entfernungsmesser (2)"},"content":{"rendered":"<h1>Aufgabenstellung<\/h1>\n<p>F\u00fcr die Steuerung kabelloser Ger\u00e4te (wie z.B. Elektromotoren) wird eine programmierbare, batteriebetriebene L\u00f6sung gesucht, die Eingabewerte von Sensoren annehmen und verarbeiten kann.<\/p>\n<h1>Ansatz<\/h1>\n<p>Durch die Verwendung des programmierbaren Arduino-Boards (arduino.cc) k\u00f6nnen Motoren mit niedriger Spannung bis zu 5 Volt betrieben werden. <\/p>\n<h1>L\u00f6sung<\/h1>\n<h3>Projekt 1: Infrarotsensor<\/h3>\n<p><iframe loading=\"lazy\" width=\"425\" height=\"349\" src=\"http:\/\/www.youtube.com\/embed\/Vxzq1jzX9cE?hl=de&#038;fs=1\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<h3>Projekt 2: Entfernungsmesser<\/h3>\n<p><iframe loading=\"lazy\" width=\"425\" height=\"349\" src=\"http:\/\/www.youtube.com\/embed\/SeaMFW2NAng?hl=de&#038;fs=1\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<h3>Zusammenstellung des Roboters (Projekt 1)<\/h3>\n<p>Die folgenden Hardware-Komponenten werden benutzt:<\/p>\n<ul>\n<li>Tamiya Track&#038;Wheel Set<\/li>\n<li>Tamiya Twin-Motor Gear Box (Motorkonfiguration: Type C)<\/li>\n<li>Platine DFRobotShop Rover\n<ul>\n<li>Arduino Duemilanove; Prozessor ATMega 328<\/li>\n<li>integrierter Motorcontroller (besetzt Pins 5-8)<\/li>\n<li>USB Schnittstelle<\/li>\n<li>Battery-Fach<\/li>\n<\/ul>\n<\/li>\n<li>Infrarotsensor: DFR0094<\/li>\n<\/ul>\n<h3>Zusammenstellung des Roboters (Projekt 2)<\/h3>\n<p>Die folgenden Hardware-Komponenten werden benutzt:<\/p>\n<ul>\n<li>Tamiya Track&#038;Wheel Set<\/li>\n<li>Tamiya Twin-Motor Gear Box (Motorkonfiguration: Type C)<\/li>\n<li>Platine DFRobotShop Rover\n<ul>\n<li>Arduino Duemilanove; Prozessor ATMega 328<\/li>\n<li>integrierter Motorcontroller (besetzt Pins 5-8)<\/li>\n<li>USB Schnittstelle<\/li>\n<li>Battery-Fach<\/li>\n<\/ul>\n<\/li>\n<li>IR Range Sensor: SHARP GP2D12 IR Ranger Sensor<\/li>\n<\/ul>\n<h3>Verdrahtung des Roboters (Projekt 1)<\/h3>\n<p>Infrarotsensor: <\/p>\n<ul>\n<li>Arduino 5V wird an VCC des Sensors angeschlossen<\/li>\n<li>Arduino GND an Infrarotsensor GND<\/li>\n<li>D wird (hier in meinem Code) auf Digital Pin 11 gelegt<\/li>\n<\/ul>\n<p>Die folgenden Software-Komponenten werden benutzt:<\/p>\n<ul>\n<li>IDE von Arduino CC<\/li>\n<li>Infrarot-Bibliothek: IRremote.h<\/li>\n<\/ul>\n<p><a href=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"476\" data-permalink=\"https:\/\/www.capri-soft.de\/blog\/?attachment_id=476\" data-orig-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?fit=3648%2C2736&amp;ssl=1\" data-orig-size=\"3648,2736\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-FS62&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1313170893&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;5.5&quot;,&quot;iso&quot;:&quot;800&quot;,&quot;shutter_speed&quot;:&quot;0.1&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Arduino Roboter\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?fit=474%2C356&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?resize=300%2C225&#038;ssl=1\" alt=\"\" title=\"Arduino Roboter\" width=\"300\" height=\"225\" class=\"alignnone size-medium wp-image-476\" srcset=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?w=948&amp;ssl=1 948w, https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2011\/08\/P1000992.jpg?w=1422&amp;ssl=1 1422w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h3>Verdrahtung des Roboters (Projekt 2)<\/h3>\n<p>Infrarotsensor: <\/p>\n<ul>\n<li>Arduino 5V mit IR Ranger Sensor roter Draht verbinden<\/li>\n<li>Arduino GND mit IR Ranger Sensor schwarzer Draht verbinden<\/li>\n<li>Arduino A2 analoger Eingang mit gr\u00fcnem Draht verbinden<\/li>\n<\/ul>\n<p>Die folgenden Software-Komponenten werden benutzt:<\/p>\n<ul>\n<li>IDE von Arduino CC<\/li>\n<\/ul>\n<h3>Mein Code (Projekt 1)<\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n#include &lt;IRremote.h&gt; \/\/ use the library\r\n\r\nint E1 = 6; \/\/M1 Speed Control\r\nint E2 = 5; \/\/M2 Speed Control\r\nint M1 = 8; \/\/M1 Direction Control\r\nint M2 = 7; \/\/M2 Direction Control\r\n\r\nint receiver = 11; \/\/ pin 1 of IR receiver to Arduino digital pin 11\r\n\r\nIRrecv irrecv(receiver); \/\/ create instance of &#039;irrecv&#039;\r\n\r\ndecode_results results;\r\n\r\nvoid setup()\r\n{\r\n  int i;\r\n  for(i=5;i&lt;=8;i++)\r\n  pinMode(i, OUTPUT);  \r\n  Serial.begin(9600); \/\/ for serial monitor output\r\n  irrecv.enableIRIn(); \/\/ Start the receiver\r\n}\r\n\r\nvoid loop()\r\n\r\n{\r\n\r\n  if (irrecv.decode(&amp;results)) \/\/ have we received an IR signal?\r\n  {\r\n\r\n    Serial.println(results.value, HEX); \/\/ display it on serial monitor in hexadecimal\r\n    \r\n    int leftspeed = 255; \/\/255 is maximum speed\r\n    int rightspeed = 255;    \r\n    switch(results.value)\r\n    {\r\n      case 0x802:\r\n      {\r\n        forward (leftspeed,rightspeed);\r\n      }\r\n      break;\r\n      case 0x804:\r\n      {\r\n        left (leftspeed,rightspeed);\r\n      }\r\n      break;    \r\n      case 0x806:\r\n      {\r\n        right (leftspeed,rightspeed);\r\n      }\r\n      break;    \r\n      case 0x808:\r\n      {\r\n        reverse (leftspeed,rightspeed);\r\n      }\r\n      break;      \r\n      default:\r\n        stop();\r\n      break;\r\n    }\r\n\r\n    irrecv.resume(); \/\/ receive the next value\r\n\r\n  }  \/\/ Your loop can do other things while waiting for an IR command\r\n\r\n}\r\n\r\nvoid stop(void) \/\/Stop\r\n{\r\n  digitalWrite(E1,LOW);\r\n  digitalWrite(E2,LOW);\r\n}\r\nvoid forward(char a,char b)\r\n{\r\n  analogWrite (E1,a);\r\n  digitalWrite(M1,LOW);\r\n  analogWrite (E2,b);\r\n  digitalWrite(M2,LOW);\r\n}\r\nvoid reverse (char a,char b)\r\n{\r\n  analogWrite (E1,a);\r\n  digitalWrite(M1,HIGH);\r\n  analogWrite (E2,b);\r\n  digitalWrite(M2,HIGH);\r\n}\r\n\r\nvoid left (char a,char b)\r\n{\r\n  analogWrite (E1,a);\r\n  digitalWrite(M1,HIGH);\r\n  analogWrite (E2,b);\r\n  digitalWrite(M2,LOW);\r\n}\r\n\r\nvoid right (char a,char b)\r\n{\r\n  analogWrite (E1,a);\r\n  digitalWrite(M1,LOW);\r\n  analogWrite (E2,b);\r\n  digitalWrite(M2,HIGH);\r\n}\r\n&amp;#91;\/javascript&amp;#93;\r\n\r\n&lt;h3&gt;Mein Code (Projekt 2)&lt;\/h3&gt;\r\n&#x5B;javascript]\r\n\/\/ example 32.1 - IR receiver code repeater\r\n\r\n\/\/ http:\/\/tronixstuff.com\/tutorials &gt; chapter 32\r\n\r\n\/\/ based on code by Ken Shirriff - http:\/\/arcfn.com\r\n\r\nint E1 = 6; \/\/M1 Speed Control\r\nint E2 = 5; \/\/M2 Speed Control\r\nint M1 = 8; \/\/M1 Direction Control\r\nint M2 = 7; \/\/M2 Direction Control\r\n\r\nint irReader = 3;    \/\/ the analog input pin for the ir reader\r\nint irVal = 0;       \/\/ stores value from Ir reader\r\n\r\nvoid setup()\r\n{\r\n  int i;\r\n  for(i=5;i&lt;=8;i++)\r\n  pinMode(i, OUTPUT);  \r\n  Serial.begin(9600); \/\/ for serial monitor output\r\n}\r\n\r\nvoid loop()\r\n\r\n{\r\n  int leftspeed = 255; \/\/255 is maximum speed\r\n  int rightspeed = 255;    \r\n  irVal = analogRead(irReader);    \/\/ read the value from the ir sensor\r\n  Serial.println(irVal);       \/\/ sends ir val to computer  \r\n\r\n  if (irVal&gt;210) \/\/ have we received an IR signal?\r\n  {\r\n        left (leftspeed,rightspeed);\r\n        delay(500);\r\n  }\r\n  else\r\n  {\r\n        forward (leftspeed,rightspeed);\r\n  }\r\n}\r\n\r\nvoid stop(void) \/\/Stop\r\n{\r\ndigitalWrite(E1,LOW);\r\ndigitalWrite(E2,LOW);\r\n}\r\nvoid forward(char a,char b)\r\n{\r\nanalogWrite (E1,a);\r\ndigitalWrite(M1,LOW);\r\nanalogWrite (E2,b);\r\ndigitalWrite(M2,LOW);\r\n}\r\nvoid reverse (char a,char b)\r\n{\r\nanalogWrite (E1,a);\r\ndigitalWrite(M1,HIGH);\r\nanalogWrite (E2,b);\r\ndigitalWrite(M2,HIGH);\r\n}\r\nvoid left (char a,char b)\r\n{\r\nanalogWrite (E1,a);\r\ndigitalWrite(M1,HIGH);\r\nanalogWrite (E2,b);\r\ndigitalWrite(M2,LOW);\r\n}\r\nvoid right (char a,char b)\r\n{\r\nanalogWrite (E1,a);\r\ndigitalWrite(M1,LOW);\r\nanalogWrite (E2,b);\r\ndigitalWrite(M2,HIGH);\r\n}\r\n<\/pre>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D470&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px;margin-top:5px;\"><\/iframe>","protected":false},"excerpt":{"rendered":"<p>Aufgabenstellung F\u00fcr die Steuerung kabelloser Ger\u00e4te (wie z.B. Elektromotoren) wird eine programmierbare, batteriebetriebene L\u00f6sung gesucht, die Eingabewerte von Sensoren annehmen und verarbeiten kann. Ansatz Durch die Verwendung des programmierbaren Arduino-Boards (arduino.cc) k\u00f6nnen Motoren mit niedriger Spannung bis zu 5 Volt betrieben werden. L\u00f6sung Projekt 1: Infrarotsensor Projekt 2: Entfernungsmesser Zusammenstellung des Roboters (Projekt 1) Die &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=470\" class=\"more-link\"><span class=\"screen-reader-text\">Projektvorstellung: Microcontrollerbasierter Roboter mit Infrarotsensor (1) und -entfernungsmesser (2)<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18],"tags":[],"class_list":["post-470","post","type-post","status-publish","format-standard","hentry","category-mikrocontroller"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-7A","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=470"}],"version-history":[{"count":6,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/470\/revisions"}],"predecessor-version":[{"id":473,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/470\/revisions\/473"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}