Template For Activity 6 (Joystik Shield)
Template For Activity 6 (Joystik Shield)
Evaluation Criteria:
1. Connections as per task given,
2. Code for Arduino for the Task.
3. Successful execution of the activities.
Team
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#define CE_PIN 9
#define CSN_PIN 10
void setup(){
for(int i; i <7 ; i++)
{
pinMode(buttons[i],INPUT);
digitalWrite(buttons[i],HIGH);
}
Serial.begin(9600);
radio.begin();
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");
}
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning
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));
delay(100);
Serial.println("Right Button Pressed");
}
Serial.print("\n X = "),Serial.print(analogRead(x_axis)),Serial.print(" \n Y = "),
Serial.print(analogRead(y_axis));
Serial.print(" ");
delay(1000);
}
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#define CE_PIN 9
#define CSN_PIN 10
void setup(){
for(int i; i <7 ; i++)
{
pinMode(buttons[i],INPUT);
digitalWrite(buttons[i],HIGH);
}
Serial.begin(9600);
radio.begin();
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)
{
K J Somaiya College of Engineering
A Constituent College of Somaiya Vidyavihar University
Course: Introduction to Project Based Learning
char msg[]="right";
radio.write(&msg,sizeof(msg));
delay(100);
Serial.println("Right Button Pressed");
}
Serial.print("\n X = "),Serial.print(analogRead(x_axis)),Serial.print(" \n Y = "),
Serial.print(analogRead(y_axis));
Serial.print(" ");
delay(1000);
}
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);
void loop()
{
fwdrev();
speed();
https://drive.google.com/drive/folders/1sSuwztYuAyTUMetF6xK-EjHFtSvvhKvx?
usp=sharing