Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
themeConfluence
void setup()
{
  pinMode(6, OUTPUT);
}
 
void loop()
{
  analogWrite(6, speed);
  delay(10); 
}
/* speed is between 0 and 255 depending on the desired speed / power */]] ></ac:plain-text-body></ac:structured-macro><h3>Bidirectional Control</h3><p><strong><ac:image ac:height="250"><ri:attachment ri:filename="image2019-12-28_18-35-2.png" /></ac:image></strong></p><ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="bc9bf6fb-2d06-4970-a24e-1df4b8108b2f"><ac:parameter ac:name="language">cpp</ac:parameter><ac:parameter ac:name="theme">Confluence</ac:parameter><ac:plain-text-body><![CDATA[void setup()
{
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
}
 
void loop()
{
  analogWrite(5, dir2speed);
  analogWrite(6, dir1speed);
  delay(10);
}
/*dir1speed and dir2speed should be between 0 and 255. Effective speed will be (dir1speed-dir2speed). 
For rotation in direction 1, dir1speed is set to the desired speed and dir2speed is set to 0 (and vice versa) */]] ></ac:plain-text-body></ac:structured-macro><h3>DC Motor with Battery</h3><p><strong><ac:image ac:height="250"><ri:attachment ri:filename="image2019-12-28_18-36-12.png" /></ac:image></strong></p><ul><li>It is better to power the motor directly from the battery rather than the 5V terminal of the Arduino.</li><li>The Arduino 5V pin might not be able to give sufficient current.</li><li>Pin 8 of L293D is connected directly to the +ve of the battery.</li><li>Here, Arduino board is purely a controller for the motor, and does not power it.</li><li>The -ve of the battery and GND of the Arduino have to be connected together.</li><li>The battery can also power the Arduino, allowing it to operate without the USB connection to the computer. Simply connect the +ve of the battery to Vin.<ul><li>Omit this connection when Arduino is connected to computer via the USB cable. Note that the GND and the -ve of the battery should be connected in any case.</li></ul></li></ul><p><brul><h3>Screencast</h3><p><ac:structured-macro ac:name="widget" ac:schema-version="1" ac:macro-id="68672be6-2cb9-47e3-8fcf-b365b2f0d95e"><ac:parameter ac:name="url"><ri:url ri:value="http://youtube.com/watch?v=pIoBLng4Yno" /></ac:parameter></ac:structured-macro></p><p><br /></p>