Skip to content

A very simple library to help you independently control motors more easily

License

Notifications You must be signed in to change notification settings

astianmuchui/Arduino-Motor-Control-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Motor Control Library

Introduction

This is a small library for motor control in arduino. It makes it easier to control motors independently.

Usage

  • Include the header file.
#include <Arduino.h>
#include <Motor.h>
  • Create the L298N Object for each motor

Arguments for initialization

// Instantiate object
Motor MyMotor(uint8_t enablePin,uint8_t input1,uint8_t input2);
#include <Arduino.h>
#include <Motor.h>
// The params have been discussed above
Motor rightMotor(19,14,5);
Motor leftMotor(12,13,16);
  • Call methods
#include <Arduino.h>
#include <Motor.h>

// Create Object
Motor rightMotor(19,14,5);
Motor leftMotor(12,13,16);

void setup() {
  // Setup is not required.
 //Pinmode is already set
}

void loop() {
  // Param -> speed
    rightMotor.forward(50);
    leftMotor.backward(50);
    delay(500);
    rightMotor.off();
    leftMotor.off();
}