{"id":46,"date":"2013-11-06T08:29:02","date_gmt":"2013-11-06T08:29:02","guid":{"rendered":"http:\/\/dronesonen.hibu.no\/?p=46"},"modified":"2013-11-06T13:24:25","modified_gmt":"2013-11-06T13:24:25","slug":"kode-til-bruk-pa-tekologidagene","status":"publish","type":"post","link":"https:\/\/dronesonen.usn.no\/?p=46","title":{"rendered":"Kode til bruk p\u00e5 tekologidagene"},"content":{"rendered":"<p><strong>Dette er testkode for motor delen<\/strong><\/p>\n<p>const int MotorA_IA = 2;<br \/>\nconst int MotorA_IB = 3; \/\/PWM<br \/>\nconst int MotorB_IA = 4;<br \/>\nconst int MotorB_IB = 5; \/\/PWM<\/p>\n<p>const int Motor2A_IA = 44;<br \/>\nconst int Motor2A_IB = 45; \/\/PWM<br \/>\nconst int Motor2B_IA = 47;<br \/>\nconst int Motor2B_IB = 46;\/\/PWM<\/p>\n<p>const int KOMMUNIKASJON= 12;<\/p>\n<p>const int MOTOR1 = 1;<br \/>\nconst int MOTOR2 = 2;<br \/>\nconst int MOTOR3 = 3;<br \/>\nconst int MOTOR4 = 4;<\/p>\n<p>void drive(int Motor,int Speed)<br \/>\n{<br \/>\nint MotorPinA = MotorA_IA;<br \/>\nint MotorPinB = MotorA_IB;<\/p>\n<p>if (Speed &gt; 255 || Speed &lt; -255)<br \/>\nSpeed = 0;<\/p>\n<p>Speed *= -1;<\/p>\n<p>switch (Motor)<br \/>\n{<br \/>\ncase MOTOR1:<br \/>\nMotorPinA = MotorA_IA;<br \/>\nMotorPinB = MotorA_IB;<br \/>\nbreak;<br \/>\ncase MOTOR2:<br \/>\nMotorPinA = MotorB_IA;<br \/>\nMotorPinB = MotorB_IB;<br \/>\nbreak;<br \/>\ncase MOTOR3:<br \/>\nMotorPinA = Motor2A_IA;<br \/>\nMotorPinB = Motor2A_IB;<br \/>\nbreak;<br \/>\ncase MOTOR4:<br \/>\nMotorPinA = Motor2B_IA;<br \/>\nMotorPinB = Motor2B_IB;<br \/>\nbreak;<br \/>\n}<\/p>\n<p>if (Speed &gt;= 0)<br \/>\n{<br \/>\ndigitalWrite(MotorPinA, 0);<br \/>\nanalogWrite(MotorPinB, Speed);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ndigitalWrite(MotorPinA, 1);<br \/>\nanalogWrite(MotorPinB, 255+Speed);<br \/>\n}<br \/>\n}<\/p>\n<p>void setup()<br \/>\n{<br \/>\nSerial.begin(9600);<br \/>\npinMode(MotorA_IA, OUTPUT);<br \/>\npinMode(MotorA_IB, OUTPUT);<br \/>\npinMode(MotorB_IA, OUTPUT);<br \/>\npinMode(MotorB_IB, OUTPUT);<br \/>\npinMode(Motor2A_IA, OUTPUT);<br \/>\npinMode(Motor2A_IB, OUTPUT);<br \/>\npinMode(Motor2B_IA, OUTPUT);<br \/>\npinMode(Motor2B_IA, OUTPUT);<\/p>\n<p>pinMode(KOMMUNIKASJON, OUTPUT);<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<\/p>\n<p>\/\/Her skal koden deres st\u00e5<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dette er testkode for motor delen const int MotorA_IA = 2; const int MotorA_IB = 3; \/\/PWM const int MotorB_IA = 4; const int MotorB_IB = 5; \/\/PWM const int Motor2A_IA = 44; const int Motor2A_IB = 45; \/\/PWM const int Motor2B_IA = 47; const int Motor2B_IB = 46;\/\/PWM const int KOMMUNIKASJON= 12; const int [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":4,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}