0% found this document useful (0 votes)
20 views7 pages

Arduino Joystick and Motor Control Guide

The document provides instructions for an Arduino activity using a joystick shield and motors. It includes code snippets to control LEDs and motors using the joystick shield. It also provides evaluation criteria and details the roles of team members who completed the wiring and coding. Observations from the activity note it offered hands-on exploration of analog input/digital output and potential applications in robotics and interactive art.

Uploaded by

krashish19504
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

Arduino Joystick and Motor Control Guide

The document provides instructions for an Arduino activity using a joystick shield and motors. It includes code snippets to control LEDs and motors using the joystick shield. It also provides evaluation criteria and details the roles of team members who completed the wiring and coding. Observations from the activity note it offered hands-on exploration of analog input/digital output and potential applications in robotics and interactive art.

Uploaded by

krashish19504
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

K J Somaiya College of Engineering

A Constituent College of Somaiya Vidyavihar University


Course: Introduction to Project Based Learning

Template for Arduino and Joystick Shield and Motor Activity


Statement Given:
Task A:
Using Joystick Shield
a) Test Up , Down , Left , Right Buttons with LED output
b) Test 2-Axis joystick values with Intensity of LED
Task B:
a) Control Positioning of Servo Motor changing from 20 to 180 degree and Vice Versa
Try changing values
b) Try Running DC Motor in Forward and Reverse Direction
Control Speed of DC Motor

Evaluation Criteria:
1. Connections as per task given,
2. Code for Arduino for the Task.
3. Successful execution of the activities.

Performance-15 Marks : Joystick tasks = 5 marks , Servo Motor : 5 marks DC Motor


using TinkerCAD = 5 marks
Submission-10 Marks

Team

Sr No Roll No Name Work Done

1 16010123081 Aryan Karanjkar Wiring

2 16010123082 Aryan Indra Coding

3 16010123083 Aryan Reshamwala Wiring

4 16010123084 Ashish Kumar Coding

5 16010123085 Ashvatth joshi Wiring

Fill your details as per following points


● Code for the task given
● Photo and Video of Actual implementation
● Observations , reflection on activity
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

Code For Joystick Shield:


include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#define CE_PIN 9
#define CSN_PIN 10
int up_button = 2; // Boton Amarillo - A
int down_button = 4; // Boton Amarillo - C
int left_button = 5; // Boton Azul - D
int right_button = 3; // Boton Azul - B
int start_button = 6; // Boton F
int select_button = 7; // Boton E
int analog_button = 8; //
int x_axis = A0;

int y_axis = A1;


int buttons[]={up_button, down_button,left_button,
right_button,start_button,select_button,analog_button};
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN,CSN_PIN);
char msg[20] = "";
void setup(){
for(int i; i <7 ; i++)
{
pinMode(buttons[i],INPUT);
digitalWrite(buttons[i],HIGH);
}
[Link](9600);
[Link]();
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

[Link](pipe);
}
void loop(){
if(digitalRead(up_button)==LOW)
{
char msg[]="up";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("UP Button Pressed");
}
if(digitalRead(down_button)==LOW)
{
char msg[]="down";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("Down Button Pressed");
}
if(digitalRead(left_button)==LOW)
{
char msg[]="left";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("Left Button Pressed");
}
if(digitalRead(right_button)==LOW)
{

char msg[]="right";
[Link](&msg,sizeof(msg));
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

delay(100);
[Link]("Right Button Pressed");
}
if(digitalRead(start_button)==LOW)
{
char msg[]="start";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("Start Button Pressed");
}
if(digitalRead(select_button)==LOW)
{
char msg[]="select";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("Select Button Pressed");
}
if(digitalRead(analog_button)==LOW)
{
char msg[]="analgobut";
[Link](&msg,sizeof(msg));
delay(100);
[Link]("Analog Button Pressed");
}
[Link]("\n X =
"),[Link](analogRead(x_axis)),[Link](" \n Y = "),
[Link](analogRead(y_axis));
[Link](" ");
delay(1000);
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

Code for Controlling Motors:

#include <Servo.h>

Servo servo;

int angle = 10;

void setup() {

[Link](5);

[Link](angle);

void loop()

// scan from 0 to 180 degrees

for(angle = 20; angle < 130; angle++)

[Link](angle);

delay(15);

// now scan back from 180 to 0 degrees

for(angle = 130; angle > 10; angle--)

[Link](angle);

delay(15);

}
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

Code for Motor Speed Control:

void setup()

pinMode(11, OUTPUT);// En of Motor 1

pinMode(7,OUTPUT); // In1 of Motor 1

pinMode(6,OUTPUT);// In 2 of Motor 1

void fwdrev() // function reverses direction of motor

digitalWrite(7,LOW);// In1 = 0, FWD

digitalWrite(6,HIGH);//In2 =1

digitalWrite(11,HIGH);

delay(5000); // Wait for 5 second(s)

digitalWrite(7, LOW);// In1 = 0, Stop

digitalWrite(6,LOW);// In2 = 0

delay(5000); // Wait for 1000 millisecond(s)

digitalWrite(7, HIGH);//In1 =1, REV

digitalWrite(6,LOW);//In2 =0

delay(5000);

digitalWrite(7, LOW);// In1 = 0, Stop

digitalWrite(6,LOW);// In2 = 0
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning

void speed () // function for 2 speed settings of DC Motor

digitalWrite(7, LOW);

digitalWrite(6,HIGH);

analogWrite(11,50); // Slow Speed

delay(25000); // Wait for 1000 millisecond(s)

analogWrite(11,200);// High Speed

digitalWrite(7, LOW);

digitalWrite(6,HIGH);

delay(25000); // Wait for 1000 millisecond(s)

void loop()

fwdrev();

speed();

OBSERVATIONS:

Engaging with the Arduino joystick shield activity offered a hands-on exploration of analog
input and digital output. It provided insights into microcontroller programming and sparked
curiosity about potential applications in robotics and interactive art. Overall, it was an
insightful and inspiring experience. It was a very fun and interesting activity.

Drive link with videos: [Link]


7dKtQs0wKUKWbEMWMSl?usp=sharing

Common questions

Powered by AI

Students may face challenges such as wiring misconfigurations, code bugs causing incorrect joystick or motor responses, or unexpected hardware failures. Addressing these requires systematic troubleshooting: verifying circuit connections against schematics, employing debugging techniques in code using Serial Monitor, and conducting hardware checks. Peer collaboration and consulting online resources or documentation can provide solutions and additional insights to resolve such issues effectively .

This project facilitates deeper understanding of electronics, programming, and mechanical control systems by offering hands-on experience with contemporary tools and technologies. It helps students apply theoretical knowledge in a practical context, which enhances critical thinking and problem-solving abilities. Furthermore, it sparks curiosity and creativity by introducing students to applications in robotics and automates processes, encouraging exploration of interdisciplinary solutions and promoting teamwork dynamics .

Analog input and digital output mechanisms are foundational in diverse applications such as interactive consumer electronics, robotics, and automation. For instance, analog joysticks can control robotic arms with precision in industrial automation, while digital outputs manage response systems in user interfaces like game controllers. These mechanisms are vital in developing smart devices where sensor data guides automated responses, exemplifying engineering solutions to enhance efficiency in various technological domains .

The existing DC motor speed control code, which uses analogWrite to set speed levels, can be enhanced by implementing an algorithm for gradual speed increase and decrease to avoid abrupt changes. This could be done by incrementing the PWM values in small steps within a loop. Additionally, implementing sensor feedback to dynamically adjust speeds or incorporating additional user input for real-time speed adjustments via buttons or a potentiometer can offer enhanced functionality and responsiveness .

The Arduino code leverages pinMode to configure button pins as INPUT and uses digitalWrite to set them HIGH, ensuring they are ready for input reading. The code then uses digitalRead to detect button presses, sending corresponding signals through the radio.write function. Analog values from the joystick's axes are read using analogRead, which can be mapped to control LED intensity by employing PWM on an LED-connected pin. This illustrates principles of reading input, conditionally executing commands, and signal transmission through integrated libraries like RF24 .

Teamwork in the project is structured through the division of tasks such as wiring and coding among team members, fostering collaboration. This division aligns with individual skill sets, promoting responsibility and participation. Such a structured approach enhances learning outcomes by simulating real-world team dynamics, which are crucial in engineering professions. It builds communication, coordination, and project management skills, vital for successful career prospects in collaborative environments .

The RF24 library facilitates wireless communication by enabling the Arduino to send and receive data through an RF module. In this project, it sends joystick position data wirelessly, demonstrating principles of remote control and communication. This capability is crucial for Internet of Things (IoT) applications, where devices communicate wirelessly to perform tasks or collect data, enabling automation and enhanced connectivity in smart systems .

Controlling a servo motor's positioning from 20 to 180 degrees offers practical insights into PWM (Pulse Width Modulation) use, fundamental in microcontroller programming for motor control. It demonstrates how digital signals are modulated to achieve analog-like control over hardware components, solidifying understanding of coding loops, angle increment management, and time delays. Such tasks integrate theoretical programming concepts with hands-on applications, bridging the gap between theory and practice in educational settings .

The servo motor control involves attaching the servo to a pin and instructing it to move between specified angles using the servo.write(angle) function. Scanning from 20 to 130 degrees facilitates motion control applications where precise angular positioning is essential, simulating scenarios like robotic arm movements or actuator adjustments. This process allows students to comprehend servo mechanics and programmatically achieve desired angular displacement for practical applications .

The evaluation criteria comprise three main components: (1) Connections as per task requirements, (2) Appropriate coding for Arduino to accomplish the task, and (3) Successful execution of the activities. Performance is assessed out of 15 marks, divided into Joystick tasks (5 marks), Servo Motor activities (5 marks), and DC Motor operations using TinkerCAD (5 marks).

You might also like