Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; AntiBotCaptcha has a deprecated constructor in /homepages/8/d680172117/htdocs/QA/qa-plugin/q2a-captcha-antibot-master/AntiBotCaptcha.php on line 22
Ok I'm adapting your menu with voice to run a multifunction Star Wars gun - Electronoobs Q&A

Welcome to Electronoobs Q&A, where you can ask questions and receive answers from other members of the community.


PCBWay Ad

Categories


+1 vote
I got a some of it to work but it's not seeing the rotary push. I tried to just edit in but I must be missing something.

here is the first part of the code:

/*

  Menu with voice and rotary encoder for BMG-1 with sound and lights

 */

 

//Inport the libraries

#include <DFMiniMp3.h>

//LCD config

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

////////////////////Serial prints for the DFplayer/////////////////////////////

class Mp3Notify

{

public:

  static void OnError(uint16_t errorCode)

  {

    // see DfMp3_Error for code meaning

    Serial.println();

    Serial.print("Com Error ");

    Serial.println(errorCode);

  }

  static void OnPlayFinished(uint16_t globalTrack)

  {

    Serial.println();

    Serial.print("Play finished for #");

    Serial.println(globalTrack);   

  }

  static void OnCardOnline(uint16_t code)

  {

    Serial.println();

    Serial.print("Card online ");

    Serial.println(code);     

  }

  static void OnCardInserted(uint16_t code)

  {

    Serial.println();

    Serial.print("Card inserted ");

    Serial.println(code);

  }

  static void OnCardRemoved(uint16_t code)

  {

    Serial.println();

    Serial.print("Card removed ");

    Serial.println(code);  

  }

};

DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial);

/////////////////////////////////////////////////////////

//Vectors for arrow and mandosybol

uint8_t arrow[8] = {0x0, 0x04 ,0x06, 0x1f, 0x06, 0x04, 0x00, 0x00};

uint8_t Mandotl[8] = {0x0D,0x07,0x09,0x05,0x03,0x03,0x0D,0x09};

uint8_t Mandotr[8] = {0x1E,0x1C,0x12,0x14,0x18,0x18,0x16,0x12};

uint8_t Mandobl[8] = {0x12,0x13,0x09,0x01,0x01,0x01,0x01,0x00};

uint8_t Mandobr[8] = {0x09,0x19,0x12,0x10,0x10,0x10,0x10,0x00};

//Variables for the menu encoder

int counter = 0;

int page=1;

int Ready=1;

int submenu=0;

int last_counter = 0;

bool clk_State;

bool Last_State;

bool dt_State;  

int pushed = 0;

//The pin for the push button

#define push 10

//trigger and leds

int buttonpin = 2;  // trigger

int ledpin1 = 3;    //VES-700 Pulse Rifle

int ledpin2 = 4;    //DLT-19 Heavy Blaster

int ledpin3 = 5;    //Ion Cannon

  

void setup() {

  pinMode(ledpin1, OUTPUT); //VES-700 Pulse Rifle

  pinMode(ledpin2, OUTPUT); //DLT-19 Heavy Blaster

  pinMode(ledpin3, OUTPUT); //Ion Cannon

  pinMode(buttonpin, INPUT); //Trigger

  pinMode(push,INPUT);       //Define the pin on rotary switch as input

  

  lcd.init();                 //Init the LCD

  lcd.backlight();            //Activate backlight

  lcd.createChar(1, arrow);   //Create the arrow symbol

  lcd.createChar(2, Mandotl); //Create Mando top left symbol

  lcd.createChar(3, Mandotr); //Create Mando top right symbol

  lcd.createChar(4, Mandobl); //Create Mando bottom left symbol

  lcd.createChar(5, Mandobr); //Create Mando bottom right symbol

  lcd.home();                 //Home the LCD

  

  PCICR |= (1 << PCIE0);    //enable PCMSK0 scan                                                 

  PCMSK0 |= (1 << PCINT0);  //Set pin D8 trigger an interrupt on state change.

  PCMSK0 |= (1 << PCINT1);  //Set pin D9 trigger an interrupt on state change.  

  DDRB &= B11111100;        //8, 9 as input for the encoder clock and data pins

  Last_State =   (PINB & B00000001); //pin 8 state (clock pin)?

   //Prepare the DFplayer module comunication and settings  

  Serial.begin(115200);  

  mp3.begin();

  uint16_t volume = mp3.getVolume();

  mp3.setVolume(20);  

  uint16_t count = mp3.getTotalTrackCount();

  //Print the initial text. Delete these lines if you don't want that

  lcd.clear();

  lcd.setCursor(0,0);

  lcd.write(2);

  lcd.write(3);

  lcd.print("Big Mandalorian");

  lcd.setCursor(0,1);

  lcd.write(4);

  lcd.write(5);

  lcd.print("     Gun-1     ");

  mp3.playMp3FolderTrack(0);  //online

  delay(6000);

  //Print the first page menu.

  lcd.clear();

  lcd.setCursor(0,0);

  lcd.write(1);  

  lcd.print("Pulse Rifle");

  lcd.setCursor(0,1);  

  lcd.print(" Heavy Blaster");

}

//Void for the DFplayer to play sounds

void waitMilliseconds(uint16_t msWait)

{

  uint32_t start = millis();  

  while ((millis() - start) < msWait)

  {

    mp3.loop(); // calling mp3.loop() periodically allows for notifications to be handled without interrupts

    delay(1);

    }

  }

void loop() {

  

  if((last_counter > counter) || (last_counter < counter)  || pushed) //Only print on the LCD when a step is detected or the button is pushed.

  {

    Ready=1;

    //First page of the menu

    if(submenu == 0)

    {  

      if(0 <= counter && counter < 5)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Pulse Rifle");

        lcd.setCursor(0,1);  

        lcd.print(" Heavy Blaster");

        page=1;

        if(pushed)

        {

          mp3.playMp3FolderTrack(1); //VES-700 Pulse Rifle

          pushed=0;

        }

      }

    

      if(5 < counter && counter < 10)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Pulse Rifle");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Heavy Blaster");

        page=2;

        if(pushed)

        {

          mp3.playMp3FolderTrack(2); //DLT-19 Heavy Blaster  

          pushed=0;

        }     

      }

      

      if(10 < counter && counter < 15)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Ion Cannon");

        lcd.setCursor(0,1);  

        lcd.print(" Flame Thrower");

        page=3;

        if(pushed)

        {

          mp3.playMp3FolderTrack(3); //Ion Cannon  

          pushed=0;

        }       

      }

    

      if(15 < counter && counter < 20)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Ion Cannon");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Flame Thrower");

        page=4;

        if(pushed)

        {

          mp3.playMp3FolderTrack(4); //Flame Thrower  

          pushed=0;

        }

      }  

        if(20 < counter && counter < 25)

        {

          lcd.clear();

          lcd.setCursor(0,0);

          lcd.write(1);

          lcd.print("Help Desk");

          page=5;

          if(pushed)

          {

            mp3.playMp3FolderTrack(5); //Help Desk  

            pushed=0;

          }  

       }

    }//submenu = 0;

    //Second page of the menu

    if(submenu == 1)

      {  

        if(0 <= counter && counter < 5)

        {

          lcd.clear();

          lcd.setCursor(0,0);

          lcd.write(1);  

          lcd.print("Pulse Rifle");

          lcd.setCursor(0,1);  

          lcd.print(" Back");

          page=1;

          pushed=0;    

        }

      

        if(5 < counter && counter < 10)

        {

          lcd.clear();

          lcd.setCursor(0,0);

          lcd.print(" Pulse Rifle");

          lcd.setCursor(0,1);

          lcd.write(1);   

          lcd.print("Back");

          page=2;

          pushed=0;      

        }

      

    

      }//submenu = 1;
asked by (200 points)

2 Answers

0 votes
Here is some more:

    //Third page of the menu

    if(submenu == 2)

    {  

      if(0 <= counter && counter < 5)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Heavy Blaster");

        lcd.setCursor(0,1);  

        lcd.print(" Back");

        page=3;

        pushed=0;    

      }

    

      if(5 < counter && counter < 10)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Heavy Blaster");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Back");

        page=4;

        pushed=0;      

      }

    

      

    }//submenu = 2;

    //Forth page of the menu

    if(submenu == 3)

    {  

      if(0 <= counter && counter < 5)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Ion Cannon");

        lcd.setCursor(0,1);  

        lcd.print(" Back");

        page=5;

        pushed=0;    

      }

    

      if(5 < counter && counter < 10)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Ion Cannon");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Back");

        page=6;

        pushed=0;      

      }    

    }//submenu = 3;

  

  

    if(submenu == 4)

    {  

      if(0 <= counter && counter < 5)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Flamethrower");

        lcd.setCursor(0,1);  

        lcd.print(" Back");

        page=7;

        pushed=0;    

      }

    

      if(5 < counter && counter < 10)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Flamethrower");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Back");

        page=8;

        pushed=0;      

      }

    

    

    }//submenu = 4;

    if(submenu == 5)

    {  

      if(0 <= counter && counter < 5)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.write(1);  

        lcd.print("Help Desk");

        lcd.setCursor(0,1);  

        lcd.print(" Back");

        page=9;

        pushed=0;    

      }

    

      if(5 < counter && counter < 10)

      {

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print(" Help Desk");

        lcd.setCursor(0,1);

        lcd.write(1);   

        lcd.print("Back");

        page=10;

        pushed=0;      

      }

    

    

    }//submenu = 5;

  

  }//end of the MENU prints on the LCD

  last_counter = counter; //Save the value of the last state

  //Now we detect when we push the button

  if(digitalRead(push)) // rotary button

  {

    if(submenu == 1)

    {    

       if(page==1)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(6);  // Play Ves-700 Pulse Rifle engaged

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Pulse Rifle On");

       }

       if(page==2)

       {

        submenu=0;

        counter=0;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(15);  //

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Going back");

        lcd.setCursor(0,1);  

        lcd.print("      Wait      ");

        delay(4000);

       }

       if(page==3)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(8);  // Play DLT-19 Heavy Blaster Rifle engaged

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Heavy Blaster On");

       }

       if(page==4)

       {

        submenu=0;

        counter=0;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(15);  //

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Going back");

        lcd.setCursor(0,1);  

        lcd.print("      Wait      ");

        delay(4000);

       }

      if(page==5)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(10);  // Play Ion Cannon engaged

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Ion Cannon On");

       }

       if(page==6)

       {

        submenu=0;

        counter=0;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(15);  //

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Going back");

        lcd.setCursor(0,1);  

        lcd.print("      Wait      ");

        delay(4000);

       }
answered by (200 points)
Here is the rest:

       if(page==7)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(12);  // Play Flame Thrower Tank Empty

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Flamethrower N/A");

       }

      if(page==8)

       {

        submenu=0;

        counter=0;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(15);  //

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Going back");

        lcd.setCursor(0,1);  

        lcd.print("      Wait      ");

        delay(4000);

       }

      if(page==9)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(13);  // Play Calling Help Desk

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Calling Help Desk");

       }

       if(page==10)

       {

        submenu=0;

        counter=0;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(15);  //

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Going back");

        lcd.setCursor(0,1);  

        lcd.print("      Wait      ");

        delay(4000);

       }

    

      

     }

    }

    //end of submenu 1

  //Now we detect when we pull the trigger

  if(digitalRead(buttonpin)) // Trigger

  {

    if(submenu == 1)

    {    

       if(page==1)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(7);  // Play Ves-700 Pulse Rifle FX 4 shot

        digitalWrite(ledpin1, HIGH);

        delay(25);              

        digitalWrite(ledpin1, LOW);    

        delay(25);  

        digitalWrite(ledpin1, HIGH);

        delay(25);              

        digitalWrite(ledpin1, LOW);    

        delay(25);

        digitalWrite(ledpin1, HIGH);

        delay(25);              

        digitalWrite(ledpin1, LOW);    

        delay(25);

        digitalWrite(ledpin1, HIGH);

        delay(25);              

        digitalWrite(ledpin1, LOW);    

        delay(25);            

       }

       if(page==3)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(9);  // Play DLT-19 Heavy Blaster Rifle FX 3 shot

        digitalWrite(ledpin2, HIGH);

        delay(25);              

        digitalWrite(ledpin2, LOW);    

        delay(25);

        digitalWrite(ledpin2, HIGH);

        delay(25);              

        digitalWrite(ledpin2, LOW);    

        delay(25);

        digitalWrite(ledpin2, HIGH);

        delay(25);              

        digitalWrite(ledpin2, LOW);    

        delay(25);

       }

       if(page==5)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(11);  // Play Ion Cannon FX 1 shot

        digitalWrite(ledpin2, HIGH);

        delay(500);              

        digitalWrite(ledpin2, LOW);    

        delay(500);

       }

     

       if(page==7)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(12);  // Play Flame Thrower Tank Empty

        lcd.clear();

        lcd.setCursor(0,0);

        lcd.print("Flamethrower N/A");

       }

      if(page==9)

       {

        submenu=0;

        counter=1;

        pushed=0;

        Ready=0;

        mp3.playMp3FolderTrack(14);  // Play Help Desk message full

        

       }

    

    }

    

  }

    //end of submenu 1

  //Add limit for the counter. Each line of the menu has 5 points. Since my menu has 5 lines the maximum counter will be from 0 to 25

  //If you add more lines for the menu, increase this value

  if(counter > 25)

  {

    counter=25;

  }

  if(counter < 0)

  {

    counter=0;

  }

  }//end void

//Interruption vector

ISR(PCINT0_vect){

  

  clk_State =   (PINB & B00000001); //pin 8 state, clock pin?

  dt_State  =   (PINB & B00000010);

  if (clk_State != Last_State){     

     // If the data state is different to the clock state, that means the encoder is rotating clockwise

     if (dt_State != clk_State) {

       counter ++;

     }

     else {

       counter --;

     }

   }

   Last_State = clk_State; // Updates the previous state of the data with the current state

  

}
0 votes

I would say some sort of adidas outlet grants nike roshe run programmes must have to destroy silos

12 nike shox clearance juillet cheap nike basketball shoes 1998. L. a. cheap nike running shoes people nike outlet from christian louboutin sneakers spain s'apprte disputer sa premire climax pour Coupe jordan 13 du cheap nike running shoes monvisage au canada goose mens uk Brsil nike roshe run Ronaldo. nike store Ballon d'Or durante cheap nikes titre, beats by dre on sale Il Fenemeno se Michael Kors Online 'vrrle red bottom shoes for women rrtre au sommet environnant nike store les toddler craft et air max cl. a.ire comptition sa cheap christian louboutin csse. Some people labeled canada goose mens 'Clarity,Or the actual cheap nike air max woman's dozing red bottoms sneakers styles cheap nike air max cause adidas store a nike outlet store considerable

answered ago by (860 points)
...