controlling a dc motor with an arduino uno


Posted on Feb 6, 2014

Control a small DC motor through this H-bridge with an Arduino Uno, but I have never programmed one of these controllers before. I need the motor to rotate in different directions when I press left and right on a keyboard. So far I have this code: // Right Motor /* Adjust these values for your servo and setup, if necessary */ int re


controlling a dc motor with an arduino uno
Click here to download the full size of the above Circuit.

sistor1 = 3; int resistor2 = 5; int resistor3 = 6; int resistor4 = 10; int moveServo; void setup() { Serial. begin(9600); pinMode(resistor1, OUTPUT); // Set servo pin as an output pin pinMode(resistor2, OUTPUT); pinMode(resistor3, OUTPUT); pinMode(resistor4, OUTPUT); } void loop() { // Wait for serial input if (Serial. available() > 0) { // Read the incoming byte: moveServo = Serial. read(); // ASCII left = 37, up = 38, right = 39, down = 40 if (moveServo = 37) { digitalWrite(resistor4, HIGH); digitalWrite(resistor1, HIGH); } }




Leave Comment

characters left:

Related Circuits

  • New Circuits

    .

     


    Popular Circuits

    IrDA Interface
    Basic Controls of a CRO
    Emitter-Coupled LC Oscillator
    Voltage Controlled PWM Generator
    Tuning circuit composed by the TA7335P



    Top