1

So I have the following connected and the programming works fine when connect by USB

The Parts

  • 1 Arduino UNO
  • 1 Laser Module (KEYS)
  • 1 Rocker Switch Module (Standard 3 PIN)
  • 2 Variation Motors (KEYS)
  • 1 Speaker Module (BIG SPEAKER MODULE)
  • 2 Push Button Modules (Standard 3 PIN)
  • 1 SD Card Reader Module (Generic)
  • 1 3V 1800 amh Battery

The Problem 1 I want to make an On/Off Switch but it doesn't work.

Battery Powers The Arduino Like This: (WORKS)

https://postimg.cc/JHmTwFKc

Battery Powers The Arduino Like This: (NOT WORKING)

https://postimg.cc/V0RKzFVy

PROBLEM 1: Why doesn't this work when it does for the Nano I have here:

https://postimg.cc/SnXHfwPJ

Secondly Here are some pictures of the setup I have

Battery - Rocker

https://postimg.cc/KK6qfjMW

Rocker - Arduino

https://postimg.cc/hXH6y2FM

https://postimg.cc/4HJrvnCg

Wide View Of Project

https://postimg.cc/3WY5Qfkc

The Problem 2 I need advice on what size battery to use the project for 1-2 hours I think I need (5v,7v,9v) but would like some help with which would be best suited or any suggestions you have

What I think it is but need help

  1. The Wiring is wrong (but I have tested it all and its working fine)
  2. The Rocker Module is passing 3V to the UNO (Not enough Power)
  3. The Battery is not powerful enough (I need a bigger battery)
  4. NOOB Problems as its my first project

What I need help with

  1. What battery to use?
  2. Making the On/Off switch work

Thanks for the HELP!!!

BONUS Here is the code used:

    #include <pcmConfig.h>
    #include <pcmRF.h>
    #include <TMRpcm.h>
    
    #include <SPI.h>
    #include <SD.h>
    
    
    
    //SD card pin
    #define SD_ChipSelectPin 10
    //soundplayer object
    TMRpcm tmrpcm;
    
    
    int led = 13;
    //pin numbers
    int buttonpin = 3;
    int lazerpin = 4;
    int buttonpin2 = 5;
    int motorPin = 6;
    int motorPin2 = 7;
    
    //other values
    int t = 0;
    int val;
    int val2;
    int ammoUsed = 0;
    int prestate = 0;
    int prestate2 = 1;
    int canReload = 0;
    
    void setup()
    {
      //pin modes
      pinMode(led, OUTPUT);
      pinMode(lazerpin, OUTPUT);
      pinMode(buttonpin, INPUT);
      pinMode(buttonpin2, INPUT);
      pinMode(motorPin, OUTPUT);
      pinMode(motorPin2, OUTPUT);
    
      Serial.begin(9600);
      if (!SD.begin(SD_ChipSelectPin))
      {
        return;
      }
      else {
        //setup sound
        tmrpcm.speakerPin = 9;
        tmrpcm.quality(1);
        tmrpcm.setVolume(5);
        //play setup sound (user knows the gun is ready)
        playSound(0);
        tmrpcm.disable();
        tmrpcm.stopPlayback();
      }
    }
    
    //method to call sounds depending on the input
    void playSound(int t) {
      tmrpcm.disable();
      tmrpcm.stopPlayback();
    
      if (t == 0) {
        tmrpcm.setVolume(5);
        tmrpcm.play("0.wav");
        delay(2980); //time of clip
      }
      else if (t == 1) {
        tmrpcm.setVolume(6);
        tmrpcm.play("1.wav");
        delay(660); //time of clip
      }
      else if (t == 2) {
        tmrpcm.setVolume(5);
        tmrpcm.play("2.wav");
        delay(950); //time of clip
      }
      else if (t == 3) {
        tmrpcm.setVolume(6);
        tmrpcm.play("3.wav");
        delay(620); //time of clip
      }
      else if (t == 4) {
        tmrpcm.setVolume(5);
        tmrpcm.play("4.wav");
        delay(660); //time of clip
      }
    
      tmrpcm.disable();
      tmrpcm.stopPlayback();
    
      return;
    }
    void loop()
    {
      val = digitalRead(buttonpin); // check the state of the button
      val2 = digitalRead(buttonpin2); // check the state of the button
    
      //reload gun
      if (val2 == HIGH && prestate2 == 0 && canReload == 1)
      {
        //reset ammo and play sound with vibrate
        ammoUsed = 0;
        canReload = 0;
        digitalWrite(motorPin, HIGH); //vibrate
        digitalWrite(motorPin2, HIGH); //vibrate
        playSound(3);
        digitalWrite(motorPin, LOW);  //stop vibrating
        digitalWrite(motorPin2, LOW);  //stop vibrating
        prestate2 = 1;
    
      }
      else if (val2 == LOW)
      {
        //reload let go
        prestate2 = 0;
      }
    
    
      //Shooting the gun 1-4 normal. 5 is louder and longer.
      if (val == LOW) // if button is pressed, turn LED on
      {
        digitalWrite(lazerpin, LOW);
        digitalWrite(led, LOW);
        prestate = 0;
      }
      else if (val == HIGH && prestate == 0)
      {
        if (ammoUsed != 5)
        {
          ammoUsed ++;
    
          if (ammoUsed > 0) {
            canReload = 1;
          }
          else {
            canReload = 0;
          }
    
    
          //turn on lazer and virbate
          digitalWrite(lazerpin, HIGH);
          digitalWrite(led, HIGH);
          digitalWrite(motorPin, HIGH); //vibrate
          digitalWrite(motorPin2, HIGH); //vibrate
    
          //play sound
          if (ammoUsed == 5) {
            playSound(2);
          }
          else {
            playSound(1);
          }
          //after sound lazer and vibrate turn off
          digitalWrite(motorPin, LOW);  //stop vibrating
          digitalWrite(motorPin2, LOW);  //stop vibrating
          digitalWrite(lazerpin, LOW);
          digitalWrite(led, LOW);
    
          prestate = 1;
        }
        else {
          //no ammo just vibrate and play sound with no lazer
          digitalWrite(motorPin, HIGH); //vibrate
          digitalWrite(motorPin2, HIGH); //vibrate
          playSound(4);
          canReload = 1;
          digitalWrite(motorPin, LOW);  //stop vibrating
          digitalWrite(motorPin2, LOW);  //stop vibrating
          prestate = 1;
    
        }
      }
    
    }
4
  • Please link to the switch product, that you used. An image is not enough here. We beed to know, how the board uses the switch. Is it just a breakout board for the 3 switch pins or are there other electronics on it? Also please put the images directly in the question, not on an external site. And some of the images are not in focus or rather dark. Please provide good in-focus pictures, so that we can actually see something in them – chrisl May 8 at 20:42
  • Good starting project, You need to understand how a switch works, your first does not work you short the battery, draining it very fast. You need only two connections to the switch. Run ground to ground, battery to center pin and arduino to NO pin. Let us know if that works. You can view a few basic electronics tutorials, that will help. Remember we all started the same place you are. Most important have fun! – Gil May 9 at 3:05
  • geekbuying.com/item/… this is the rocker – Davinco May 10 at 8:39
  • can confirm its definitly the 2 mode rocker that is wrong.......... as i have just tried it with a push switch to test it. and works fine haha. I tried what you said and the rocker switch does work either (SIG/VCC/GND) connect battery to VCC and SIG to arduino still nothing – Davinco May 10 at 8:47
1

So here is the deal (I Kinda Solved It) so I took apart a 9V battery pack with a flip switch in it..... soldered some wired to it and now it works perfectly...... haha

but I would still like the know the reason why the rocker switch module doesn't work.

the only thing I can think of is the Voltage or Amp passed from the Switch Module isn't enough to power the board (as I tried 3 different rocker switches and all acted the same)

Thanks for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.