Project tutorial
Fun Projects With Elegoo Uno R3 Super Start Kit - Joystick

Fun Projects With Elegoo Uno R3 Super Start Kit - Joystick © CC BY

This project shows the method control the speed and direction of DC motor with a joystick module using Arduino.

  • 1,329 views
  • 0 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

Introduction

The objective of this project is to apply the joystick control to the DC motor which has a lot of real-world application.

Parts List

There are many Arduino learning kit on the market with various flavors. In this tutorial I used the Elegoo Uno R3 Super Start kit from Amazon. The kit has a cloned Arduino Uno 3 which is very similar to the original Uno, as well as a good collection of common components and a comprehensive manual with 24 fun Arduino projects with sketches.

  • Arduino Uno R3 board
  • L293D
  • DC Motor
  • Joystick Module
  • Breadboard with DC power supply
  • Jumper Wires

Schematics and Sketch

Refer to the documentation supplied with the Elegoo kit for a detailed explanation functional diagram for the L293D IC and the joystick. In particular:

  • Lesson 12 Analog Joystick Module
  • Lesson 21 DC Motors

Code

Joystic_Control.inoArduino
//www.elegoo.com
//2018.8.20
/*
  This example use the Y-axle of joystick to control the DC Motor
*/

const int Y_pin = 1; // analog pin connected to Y output

#define ENABLE 5
#define DIRA 3
#define DIRB 4

int i;
 
void setup() {
  //---set pin direction
  pinMode(ENABLE,OUTPUT);
  pinMode(DIRA,OUTPUT);
  pinMode(DIRB,OUTPUT);
  Serial.begin(9600);
}

void loop() {
    long y;
  y = analogRead(Y_pin);
  Serial.print("val=");
  Serial.println(y);
  if(y == 0){
    analogWrite(ENABLE,255); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }
  if(y>0&&y<100){
    analogWrite(ENABLE,200); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }
  if(y>100&&y<250){
    analogWrite(ENABLE,180); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }
  if(y>250&&y<400){
    analogWrite(ENABLE,128); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }
  if(y>400&&y<500){
    analogWrite(ENABLE,80); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }    
  if(y>500&&y<600){
    analogWrite(ENABLE,0); 
    digitalWrite(DIRA,LOW); //one way
    digitalWrite(DIRB,HIGH);
    }
  if(y == 1023){
    analogWrite(ENABLE,255); 
    digitalWrite(DIRA,HIGH); //revers
    digitalWrite(DIRB,LOW);
    }
  if(y>923&&y<1023){
    analogWrite(ENABLE,200); 
    digitalWrite(DIRA,HIGH); //revers
    digitalWrite(DIRB,LOW);
    }
  if(y>800&&y<923){
    analogWrite(ENABLE,180); 
    digitalWrite(DIRA,HIGH); //revers
    digitalWrite(DIRB,LOW);
    }
  if(y>700&&y<800){
    analogWrite(ENABLE,128); 
    digitalWrite(DIRA,HIGH); //revers
    digitalWrite(DIRB,LOW);
    }
  if(y>600&&y<700){
    analogWrite(ENABLE,80); 
    digitalWrite(DIRA,HIGH); //revers
    digitalWrite(DIRB,LOW);
    }    
}
   

Schematics

Schematics
Fpdxl1qjl47hdbl large b6jqc4k1cn

Comments

Similar projects you might like

Pranked! Moving Tissue Box | Circuito.io

Project tutorial by Arduino “having11” Guy

  • 4,796 views
  • 1 comment
  • 20 respects

Bluetooth-Controlled Car

Project tutorial by Yogeshmodi

  • 27,964 views
  • 3 comments
  • 39 respects

Arduino Simple "Camera Slider" Electronics

Project tutorial by Ian Cumming

  • 7,210 views
  • 3 comments
  • 18 respects

Guitar Speed Pick and Stomp Pedal!

Project tutorial by marc_uberstein

  • 5,088 views
  • 8 comments
  • 30 respects

Arduino 4WD RC Car

Project tutorial by Andriy Baranov

  • 13,201 views
  • 3 comments
  • 44 respects

Robotic Car controlledover Bluetooth with Obstacle Avoidance

Project showcase by S.Ranjith Reddy

  • 9,582 views
  • 5 comments
  • 17 respects
Add projectSign up / Login