Harsh Dethe
Published © CC BY-NC-SA

Nano Robot Controller and How to Use It

In this article we shall see what a robot controller is, what is it used for and how to get started with the Nano Robot controller.

IntermediateProtip1 hour2,389
Nano Robot Controller and How to Use It

Things used in this project

Hardware components

Arduino Nano
×1
Nano Robot Controller Board
×1
2WD Robot Chassis
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Screw Driver Set

Story

Read more

Code

Code snippet #1

Plain text
int ENA = 3;
int ENB = 5;
int IN1 = 2;
int IN2 = 4;
int IN3 = 7;
int IN4 = 8;

Code snippet #2

Plain text
void setup()
{
  Serial.begin(9600);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

Code snippet #3

Plain text
void front()
{
  Serial.println("FORWARD");
  analogWrite(ENA, 75); //PWM 0-255
  analogWrite(ENB, 75); //PWM 0-255
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

Code snippet #4

Plain text
void left()
{
  Serial.println("LEFT");
  analogWrite(ENA, 50);
  analogWrite(ENB, 50);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

Code snippet #5

Plain text
void right()
{
  Serial.println("RIGHT");
  analogWrite(ENA, 50);
  analogWrite(ENB, 50);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Code snippet #6

Plain text
void back()
{
  Serial.println("BACKWARD");
  analogWrite(ENA, 75);
  analogWrite(ENB, 75);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

Code snippet #7

Plain text
void stops()
{
  Serial.println("STOP");
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Code snippet #8

Plain text
void loop()
{
  front();
  delay(1000);
  left();
  delay(1000);
  front();
  delay(1000);
  right();
  delay(1000);
  front();
  delay(1000);
  stops();
  delay(1000);
  back();
  delay(1000);
}

Credits

Harsh Dethe

Harsh Dethe

30 projects • 70 followers
Electronics hobbyist, AI Enthusiast. I like to play with technology.

Comments