Menu not defined error

hi all im really sorry to ask such a novice question but im stuck. i have a code error that keeps coming up and im not sure how to go about fixing it. the error is menu isnt declared in this scope. here is the section of code that has the error

char menu();

  *menuOption = menu( Serial.println("\nWhich component would you like to test?"));*
  Serial.println(F("(1) NRF24L01 - 2.4G Wireless Transceiver Module"));
  Serial.println(F("(2) Momentary Push Button - Panel Mount (Red) #1"));
  Serial.println(F("(3) Momentary Push Button - Panel Mount (Red) #2"));
  Serial.println(F("(4) Momentary Push Button - Panel Mount (Red) #3"));
  Serial.println(F("(5) Momentary Push Button - Panel Mount (Red) #4"));
  Serial.println(F("(menu) send anything else or press on board reset button\n"));
  while (!Serial.available());

cheers
lucas

Plese post the FULL CODE, use the </> tag above to enclose your code.

Where's the rest of the code?

sorry guys like i say novice af


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <CFPushButton.h>
#include "Arduino.h"
#include "Button.h"


// Pin Definitions
#define NRF24L01_PIN_CE  2
#define NRF24L01_PIN_CS 10
#define PUSHBUTTONMOMENTARY_1_PIN_2 3
#define PUSHBUTTONMOMENTARY_2_PIN_2 4
#define PUSHBUTTONMOMENTARY_3_PIN_2 5
#define PUSHBUTTONMOMENTARY_4_PIN_2 6


RF24 radio(2, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);

  // Global variables and defines

  // object initialization
  Button pushButtonMomentary_1(PUSHBUTTONMOMENTARY_1_PIN_2);
  Button pushButtonMomentary_2(PUSHBUTTONMOMENTARY_2_PIN_2);
  Button pushButtonMomentary_3(PUSHBUTTONMOMENTARY_3_PIN_2);
  Button pushButtonMomentary_4(PUSHBUTTONMOMENTARY_4_PIN_2);


  // define vars for testing menu
  const int timeout = 10000;       //define timeout of 10 sec
  char menuOption = 0;
  long time0;

  {

    Serial.begin(9600);
    while (!Serial) ; // wait for serial port to connect. Needed for native USB
    Serial.println("start");
    pushButtonMomentary_1.init();
    pushButtonMomentary_2.init();
    pushButtonMomentary_3.init();
    pushButtonMomentary_4.init();

    if (menuOption == '1')
    {
      // Disclaimer: The NRF24L01 - 2.4G Wireless Transceiver Module is in testing and/or doesn't have code, therefore it may be buggy. Please be kind and report any bugs you may find.
    }
    else if (menuOption == '2') {
      // Momentary Push Button - Panel Mount (Red) #1 - Test Code
      //Read pushbutton state.
      //if button is pressed function will return HIGH (1). if not function will return LOW (0).
      //for debounce funtionality try also pushButtonMomentary_1.onPress(), .onRelease() and .onChange().
      //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
      bool pushButtonMomentary_1Val = pushButtonMomentary_1.read();
      Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_1Val);
    }
    else if (menuOption == '3') {
      // Momentary Push Button - Panel Mount (Red) #2 - Test Code
      //Read pushbutton state.
      //if button is pressed function will return HIGH (1). if not function will return LOW (0).
      //for debounce funtionality try also pushButtonMomentary_2.onPress(), .onRelease() and .onChange().
      //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
      bool pushButtonMomentary_2Val = pushButtonMomentary_2.read();
      Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_2Val);
    }
    else if (menuOption == '4') {
      // Momentary Push Button - Panel Mount (Red) #3 - Test Code
      //Read pushbutton state.
      //if button is pressed function will return HIGH (1). if not function will return LOW (0).
      //for debounce funtionality try also pushButtonMomentary_3.onPress(), .onRelease() and .onChange().
      //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
      bool pushButtonMomentary_3Val = pushButtonMomentary_3.read();
      Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_3Val);
    }
    else if (menuOption == '5') {
      // Momentary Push Button - Panel Mount (Red) #4 - Test Code
      //Read pushbutton state.
      //if button is pressed function will return HIGH (1). if not function will return LOW (0).
      //for debounce funtionality try also pushButtonMomentary_4.onPress(), .onRelease() and .onChange().
      //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
      bool pushButtonMomentary_4Val = pushButtonMomentary_4.read();
      Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_4Val);
    }

    if (millis() - time0 > timeout)

   

    
 
 char menu();

  

      menuOption = menu( Serial.println("\nWhich component would you like to test?"));
      Serial.println(F("(1) NRF24L01 - 2.4G Wireless Transceiver Module"));
      Serial.println(F("(2) Momentary Push Button - Panel Mount (Red) #1"));
      Serial.println(F("(3) Momentary Push Button - Panel Mount (Red) #2"));
      Serial.println(F("(4) Momentary Push Button - Panel Mount (Red) #3"));
      Serial.println(F("(5) Momentary Push Button - Panel Mount (Red) #4"));
      Serial.println(F("(menu) send anything else or press on board reset button\n"));
      while (!Serial.available());

   
    

  }
  // Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
  void setup()

  // Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
  void loop()



  if (menuOption == '1')
  {
    // Disclaimer: The NRF24L01 - 2.4G Wireless Transceiver Module is in testing and/or doesn't have code, therefore it may be buggy. Please be kind and report any bugs you may find.
  }
  else if (menuOption == '2') {
    // Momentary Push Button - Panel Mount (Red) #1 - Test Code
    //Read pushbutton state.
    //if button is pressed function will return HIGH (1). if not function will return LOW (0).
    //for debounce funtionality try also pushButtonMomentary_1.onPress(), .onRelease() and .onChange().
    //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
    bool pushButtonMomentary_1Val = pushButtonMomentary_1.read();
    Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_1Val);
  }
  else if (menuOption == '3') {
    // Momentary Push Button - Panel Mount (Red) #2 - Test Code
    //Read pushbutton state.
    //if button is pressed function will return HIGH (1). if not function will return LOW (0).
    //for debounce funtionality try also pushButtonMomentary_2.onPress(), .onRelease() and .onChange().
    //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
    bool pushButtonMomentary_2Val = pushButtonMomentary_2.read();
    Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_2Val);
  }
  else if (menuOption == '4') {
    // Momentary Push Button - Panel Mount (Red) #3 - Test Code
    //Read pushbutton state.
    //if button is pressed function will return HIGH (1). if not function will return LOW (0).
    //for debounce funtionality try also pushButtonMomentary_3.onPress(), .onRelease() and .onChange().
    //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
    bool pushButtonMomentary_3Val = pushButtonMomentary_3.read();
    Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_3Val);
  }
  else if (menuOption == '5') {
    // Momentary Push Button - Panel Mount (Red) #4 - Test Code
    //Read pushbutton state.
    //if button is pressed function will return HIGH (1). if not function will return LOW (0).
    //for debounce funtionality try also pushButtonMomentary_4.onPress(), .onRelease() and .onChange().
    //if debounce is not working properly try changing 'debounceDelay' variable in Button.h
    bool pushButtonMomentary_4Val = pushButtonMomentary_4.read();
    Serial.print(F("Val: ")); Serial.println(pushButtonMomentary_4Val);
  }

  if (millis() - time0 > timeout)


    //* Menu function for selecting the components to be tested
    //* Follow serial monitor for instrcutions
  {
    char menu();

    menuOption = menu( Serial.println (F)("\nWhich component would you like to test?"));
    Serial.println(F))("(2) Momentary Push Button - Panel Mount (Red) #1"));
    Serial.println(F)("(3) Momentary Push Button - Panel Mount (Red) #2"));
    Serial.println(F)("(4) Momentary Push Button - Panel Mount (Red) #3"));
    Serial.println(F)("(5) Momentary Push Button - Panel Mount (Red) #4"));
    Serial.println(F)("(menu) send anything else or press on board reset button\n"));
    while (!Serial.available());
  }

}



// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()


Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) NRF24L01 - 2.4G Wireless Transceiver Module"));
Serial.println(F("(2) Momentary Push Button - Panel Mount (Red) #1"));
Serial.println(F("(3) Momentary Push Button - Panel Mount (Red) #2"));
Serial.println(F("(4) Momentary Push Button - Panel Mount (Red) #3"));
Serial.println(F("(5) Momentary Push Button - Panel Mount (Red) #4"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());

// Read data from serial monitor if received
while (Serial.available())
{
  char c = Serial.read();
  if (isAlphaNumeric(c))
  {

    if (c == '1')
      Serial.println(F("Now Testing NRF24L01 - 2.4G Wireless Transceiver Module - note that this component doesn't have a test code"));
    else if (c == '2')
      Serial.println(F("Now Testing Momentary Push Button - Panel Mount (Red) #1"));
    else if (c == '3')
      Serial.println(F("Now Testing Momentary Push Button - Panel Mount (Red) #2"));
    else if (c == '4')
      Serial.println(F("Now Testing Momentary Push Button - Panel Mount (Red) #3"));
    else if (c == '5')
      Serial.println(F("Now Testing Momentary Push Button - Panel Mount (Red) #4"));
    else
    {
      Serial.println(F("illegal input!"));
      return 0;
    }
    time0 = millis();
    return c;
  }
}
}
}

That code is a train wreck.

Chuck it in the bin - it's illegible.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.