Jatinpatel
Published © GPL3+

Remote Controlled Cannon Using Arduino

This video will show how to make remote-controlled canon and how not to make canon. We're using RF module with Arduino.

BeginnerShowcase (no instructions)3,347
Remote Controlled Cannon Using Arduino

Things used in this project

Hardware components

SparkFun Transceiver Breakout - nRF24L01+
SparkFun Transceiver Breakout - nRF24L01+
×2
9V battery (generic)
9V battery (generic)
×2
Arduino UNO
Arduino UNO
×2
Switch Actuator, Head for spring return push-button
Switch Actuator, Head for spring return push-button
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Arduino Transmitter and receiver

Code

Arduino Receiver

Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7,8);
int LED1 = 3;
const int buzzer = 2;
const byte address[6] = "00001";
int msg[1];

void setup() {
  // put your setup code here, to run once:
  pinMode(buzzer, OUTPUT);
   Serial.begin(115200);
  delay(1000);
  radio.begin();
  radio.openReadingPipe(0,address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
  pinMode(LED1, OUTPUT);
}

void loop() {
  
  
  if (radio.available()) {
    radio.read(msg, 1);
    String transData = String(msg[0]);
    Serial.print(transData);
    if (transData == "1") {
      digitalWrite(LED1, HIGH);
     } else if (transData == "0") {
      digitalWrite(LED1, LOW);    
     }
  } else {
//    Serial.print("\n Radio not available");
  }
}

Arduino Transmitter

Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7,8);

const byte address[6] = "00001";
int buttonPIN = 3;
int pVal = 1;
int msg[1];

void setup() {
  Serial.begin(115200);
  pinMode(buttonPIN, INPUT);
  delay(1000);
  
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.stopListening();
}

void loop() {
  int val = digitalRead(buttonPIN);
  if (val != pVal) {
      msg[0] = val ? 1 : 0;
      radio.write(msg, 1);
      Serial.println("data sent---");
      Serial.println(val); 
      pVal = val;
   }
 
//  const char text[] = "nrftest";
//  radio.write(&text, sizeof(text));
  
//  delay(200);
}

Credits

Jatinpatel

Jatinpatel

0 projects • 0 followers

Comments