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);
      }
      Serial.begin(9600);
      radio.begin();
                    K J Somaiya College of Engineering
               A Constituent College of Somaiya Vidyavihar University
                   Course: Introduction to Project Based Learning
radio.openWritingPipe(pipe);
}
void loop(){
if(digitalRead(up_button)==LOW)
{
char msg[]="up";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("UP Button Pressed");
}
if(digitalRead(down_button)==LOW)
{
char msg[]="down";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Down Button Pressed");
}
if(digitalRead(left_button)==LOW)
{
char msg[]="left";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Left Button Pressed");
}
if(digitalRead(right_button)==LOW)
{
char msg[]="right";
radio.write(&msg,sizeof(msg));
                    K J Somaiya College of Engineering
               A Constituent College of Somaiya Vidyavihar University
                   Course: Introduction to Project Based Learning
delay(100);
Serial.println("Right Button Pressed");
}
if(digitalRead(start_button)==LOW)
{
char msg[]="start";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Start Button Pressed");
}
if(digitalRead(select_button)==LOW)
{
char msg[]="select";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Select Button Pressed");
}
if(digitalRead(analog_button)==LOW)
{
char msg[]="analgobut";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Analog Button Pressed");
}
Serial.print("\n X =
"),Serial.print(analogRead(x_axis)),Serial.print(" \n Y = "),
Serial.print(analogRead(y_axis));
Serial.print(" ");
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() {
      servo.attach(5);
      servo.write(angle);
      void loop()
      // scan from 0 to 180 degrees
      for(angle = 20; angle < 130; angle++)
      servo.write(angle);
      delay(15);
      // now scan back from 180 to 0 degrees
      for(angle = 130; angle > 10; angle--)
      servo.write(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: https://drive.google.com/drive/folders/1Vs8UZ5On0mQg-
7dKtQs0wKUKWbEMWMSl?usp=sharing