<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Random Motor Arduino code</title><link>https://community.element14.com/products/arduino/w/documents/16971/random-motor-arduino-code</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Random Motor Arduino code</title><link>https://community.element14.com/products/arduino/w/documents/16971/random-motor-arduino-code</link><pubDate>Fri, 08 Oct 2021 07:51:39 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:9b3968ff-0813-4502-94da-2b5e0765a65c</guid><dc:creator>goldenshuttle</dc:creator><comments>https://community.element14.com/products/arduino/w/documents/16971/random-motor-arduino-code#comments</comments><description>Current Revision posted to Documents by goldenshuttle on 10/8/2021 7:51:39 AM&lt;br /&gt;
&lt;p style="margin:0;"&gt;Hi this code is 2 motors; each moves forward for 1 second..then it stops for a random duration of 0.5 to 3 seconds&lt;/p&gt;&lt;p style="margin:0;"&gt;Not sure if it works; I will try it soon...any comments please reply&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;// 2 motors move for 1 sec and then stop for randomly 0.5-3 seconds.&lt;/p&gt;&lt;p style="margin:0;"&gt;int MotPin1 = 9; // select pin 9 for Motor1&lt;/p&gt;&lt;p style="margin:0;"&gt;int MotPin2 = 10; // select pin 10 for Motor2&lt;/p&gt;&lt;p style="margin:0;"&gt;void setup () {&lt;/p&gt;&lt;p style="margin:0;"&gt;pinMode(MotPin1, OUTPUT); // MotPin1 should be output&lt;/p&gt;&lt;p style="margin:0;"&gt;pinMode(MotPin2, OUTPUT); // MotPin2 should be output&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;void loop () {&lt;/p&gt;&lt;p style="margin:0;"&gt;digitalWrite(MotPin1, 1); // Motor1 ON&lt;/p&gt;&lt;p style="margin:0;"&gt;delay(1000)&lt;/p&gt;&lt;p style="margin:0;"&gt;digitalWrite(MotPin1, 0); // Motor1 OFF&lt;/p&gt;&lt;p style="margin:0;"&gt;delay(random(500,3000)); // delay for random time&lt;/p&gt;&lt;p style="margin:0;"&gt;digitalWrite(MotPin2, 1); // Motor2 ON&lt;/p&gt;&lt;p style="margin:0;"&gt;delay(1000)&lt;/p&gt;&lt;p style="margin:0;"&gt;digitalWrite(MotPin2, 0); // Motor2 OFF&lt;/p&gt;&lt;p style="margin:0;"&gt;delay(random(500,3000)); // delay for random time&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: sketch, motors, motion, random, code, arduino&lt;/div&gt;
</description></item></channel></rss>