A quick one for the sharp eyed. A function definition not allowed before {

A quick one for the sharp eyed. I’ve been starring at the screen for too long and cannot see the problem.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons

int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

int read_LCD_buttons() {              // read the buttons
  adc_key_in = analogRead(0);       // read the value from the sensor

  if (adc_key_in > 1000) return btnNONE;

  if (adc_key_in < 50)   return btnRIGHT;
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;

  return btnNONE;                // when all others fail, return this.

#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

  // Singleton instance of the radio driver
  RH_NRF24 driver;
  // RH_NRF24 driver(8, 7);   // For RFM73 on Anarduino Mini

  // Class to manage message delivery and receipt, using the driver declared above
  RHReliableDatagram manager(driver, CLIENT_ADDRESS);


  void setup() {

    lcd.begin(16, 2);
    lcd.setCursor(3, 0);
    lcd.print("Lava Valley");
    lcd.setCursor(5, 1);
    lcd.print("Produce");
    delay(3000);
    lcd.clear();
    lcd.print("Seedr Controller");
    lcd.setCursor(1, 1);
    lcd.print("by Chris Dalby");
    delay(5000);
    lcd.clear();
    lcd.print("Set RPM");
    Serial.begin(9600);
    if (!manager.init())
      Serial.println("init failed");
    // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm

  }

  void loop()
  {
    listenForServer();
    displayRpm();
    readButtons();
    adjRequiredRpm();
    displayRequiredRpm();
    setStartStop();
    sendDatatoServer();//Send RequiredRpm & Start/Stop to Server.

  }

  void listenForServer() {
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    }

  void displayRpm() {
    Serial.println((char*)buf);
  }

  void readButtons() {

  }

  void adjRequiredRpm() {

  }

  void displayRequiredRpm() {

  }

  void setStartStop() {

  }

  void sendDatatoServer()  {
    char msg[4];
    itoa(data, msg, 10);

    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
  }
Arduino: 1.6.7 (Linux), Board: "Arduino/Genuino Uno"

In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RadioHead.h:731:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHGenericDriver.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHDatagram.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHReliableDatagram.h:10,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:30:
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h: In function 'int read_LCD_buttons()':
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:313:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::initialized' [-fpermissive]
   static uint8_t initialized;
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:314:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptMode' [-fpermissive]
   static uint8_t interruptMode; // 0=none, 1=mask, 2=global
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:315:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptMask' [-fpermissive]
   static uint8_t interruptMask; // which interrupts to mask
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:316:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptSave' [-fpermissive]
   static uint8_t interruptSave; // temp storage, to restore state
                  ^
In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RadioHead.h:836:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHGenericDriver.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHDatagram.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHReliableDatagram.h:10,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:30:
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:43:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:49:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:55:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:62:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:69:1: error: a function-definition is not allowed here before '{' token
 {
 ^
In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHNRFSPIDriver.h:10:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RH_NRF24.h:11,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:31:
/home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHHardwareSPI.h:65:22: error: 'read_LCD_buttons()::RHHardwareSPI hardware_spi', declared using local type 'read_LCD_buttons()::RHHardwareSPI', is used but never defined [-fpermissive]
 extern RHHardwareSPI hardware_spi;
                      ^
wireless_seeder_controller_client:45: error: a function-definition is not allowed here before '{' token
   void setup() {
                ^
wireless_seeder_controller_client:68: error: a function-definition is not allowed here before '{' token
   {
   ^
wireless_seeder_controller_client:79: error: a function-definition is not allowed here before '{' token
   void listenForServer() {
                          ^
wireless_seeder_controller_client:85: error: a function-definition is not allowed here before '{' token
   void displayRpm() {
                     ^
wireless_seeder_controller_client:89: error: a function-definition is not allowed here before '{' token
   void readButtons() {
                      ^
wireless_seeder_controller_client:93: error: a function-definition is not allowed here before '{' token
   void adjRequiredRpm() {
                         ^
wireless_seeder_controller_client:97: error: a function-definition is not allowed here before '{' token
   void displayRequiredRpm() {
                             ^
wireless_seeder_controller_client:101: error: a function-definition is not allowed here before '{' token
   void setStartStop() {
                       ^
wireless_seeder_controller_client:105: error: a function-definition is not allowed here before '{' token
   void sendDatatoServer()  {
                            ^
wireless_seeder_controller_client:111: error: expected '}' at end of input
   }
   ^
exit status 1
a function-definition is not allowed here before '{' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Take a close look at the "if" statement here. Is that supposed to be a '{' and not a '}'

  void listenForServer() {
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    }

SurferTim:
Take a close look at the “if” statement here. Is that supposed to be a ‘{’ and not a ‘}’

  void listenForServer() {

uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    }

That’s one down, thanks. Still getting error:

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons

int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

int read_LCD_buttons() {              // read the buttons
  adc_key_in = analogRead(0);       // read the value from the sensor

  if (adc_key_in > 1000) return btnNONE;

  if (adc_key_in < 50)   return btnRIGHT;
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;

  return btnNONE;                // when all others fail, return this.

#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

  // Singleton instance of the radio driver
  RH_NRF24 driver;
  // RH_NRF24 driver(8, 7);   // For RFM73 on Anarduino Mini

  // Class to manage message delivery and receipt, using the driver declared above
  RHReliableDatagram manager(driver, CLIENT_ADDRESS);


  void setup() {

    lcd.begin(16, 2);
    lcd.setCursor(3, 0);
    lcd.print("Lava Valley");
    lcd.setCursor(5, 1);
    lcd.print("Produce");
    delay(3000);
    lcd.clear();
    lcd.print("Seedr Controller");
    lcd.setCursor(1, 1);
    lcd.print("by Chris Dalby");
    delay(5000);
    lcd.clear();
    lcd.print("Set RPM");
    Serial.begin(9600);
    if (!manager.init())
      Serial.println("init failed");
    // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm

  }

  void loop()
  {
    listenForServer();
    displayRpm();
    readButtons();
    adjRequiredRpm();
    displayRequiredRpm();
    setStartStop();
    sendDatatoServer();//Send RequiredRpm & Start/Stop to Server.

  }

  void listenForServer() {
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.println((char*)buf);
    }
      }
    
    

  void displayRpm() {
    
  }

  void readButtons() {

  }

  void adjRequiredRpm() {

  }

  void displayRequiredRpm() {

  }

  void setStartStop() {

  }

  void sendDatatoServer()  {
    char msg[4];
    itoa(data, msg, 10);

    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
  }
Arduino: 1.6.7 (Linux), Board: "Arduino/Genuino Uno"

In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RadioHead.h:731:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHGenericDriver.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHDatagram.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHReliableDatagram.h:10,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:30:
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h: In function 'int read_LCD_buttons()':
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:313:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::initialized' [-fpermissive]
   static uint8_t initialized;
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:314:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptMode' [-fpermissive]
   static uint8_t interruptMode; // 0=none, 1=mask, 2=global
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:315:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptMask' [-fpermissive]
   static uint8_t interruptMask; // which interrupts to mask
                  ^
/home/anne/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src/SPI.h:316:18: error: local class 'class read_LCD_buttons()::SPIClass' shall not have static data member 'uint8_t read_LCD_buttons()::SPIClass::interruptSave' [-fpermissive]
   static uint8_t interruptSave; // temp storage, to restore state
                  ^
In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RadioHead.h:836:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHGenericDriver.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHDatagram.h:9,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHReliableDatagram.h:10,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:30:
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:43:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:49:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:55:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:62:1: error: a function-definition is not allowed here before '{' token
 {
 ^
/home/anne/Downloads/arduino-1.6.7/hardware/tools/avr/avr/include/util/atomic.h:69:1: error: a function-definition is not allowed here before '{' token
 {
 ^
In file included from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHNRFSPIDriver.h:10:0,
                 from /home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RH_NRF24.h:11,
                 from /home/anne/Arduino/wireless_seeder_controller_client/wireless_seeder_controller_client.ino:31:
/home/anne/Downloads/arduino-1.6.7/libraries/RadioHead/RHHardwareSPI.h:65:22: error: 'read_LCD_buttons()::RHHardwareSPI hardware_spi', declared using local type 'read_LCD_buttons()::RHHardwareSPI', is used but never defined [-fpermissive]
 extern RHHardwareSPI hardware_spi;
                      ^
wireless_seeder_controller_client:45: error: a function-definition is not allowed here before '{' token
   void setup() {
                ^
wireless_seeder_controller_client:68: error: a function-definition is not allowed here before '{' token
   {
   ^
wireless_seeder_controller_client:79: error: a function-definition is not allowed here before '{' token
   void listenForServer() {
                          ^
wireless_seeder_controller_client:116: error: expected '}' at end of input
   }
   ^
exit status 1
a function-definition is not allowed here before '{' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

What are you doing here? Shouldn’t there be a closing curly brace after “return btnNONE”?

int read_LCD_buttons() {              // read the buttons
  adc_key_in = analogRead(0);       // read the value from the sensor

  if (adc_key_in > 1000) return btnNONE;

  if (adc_key_in < 50)   return btnRIGHT;
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;

  return btnNONE;                // when all others fail, return this.

// shouldn't there be a '}' here?

#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

  // Singleton instance of the radio driver
  RH_NRF24 driver;
  // RH_NRF24 driver(8, 7);   // For RFM73 on Anarduino Mini

  // Class to manage message delivery and receipt, using the driver declared above
  RHReliableDatagram manager(driver, CLIENT_ADDRESS);

SurferTim:
What are you doing here? Shouldn’t there be a closing curly brace after “return btnNONE”?

int read_LCD_buttons() {              // read the buttons

adc_key_in = analogRead(0);      // read the value from the sensor

if (adc_key_in > 1000) return btnNONE;

if (adc_key_in < 50)  return btnRIGHT;
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;

return btnNONE;                // when all others fail, return this.

// shouldn’t there be a ‘}’ here?

#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
  RH_NRF24 driver;
  // RH_NRF24 driver(8, 7);  // For RFM73 on Anarduino Mini

// Class to manage message delivery and receipt, using the driver declared above
  RHReliableDatagram manager(driver, CLIENT_ADDRESS);

Ta Dah!

You win a well deserved Karma for that one. Boy was I looking in the wrong place.

Thanks Tim.

Arrgh!

Error, you must wait one hour before awarding a karma point! :-(

In 1 hour I hope to award you number 500!

That's why good indentation is important ;)

And as a tip, if you stand next to a bracket the IDE will show you the corresponding closing bracket ;)