Help for this code

/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void setup()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:94:49: error: 'grab' was not declared in this scope
attachInterrupt(digitalPinToInterrupt(rxPin), grab, CHANGE);
^~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void click1()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:113:65: error: 'bipOne' was not declared in this scope
processClick(Cash1, cashCame1, cashNice1, ledCach1, ledCach2, bipOne);
^~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:113:65: note: suggested alternative: 'bip'
processClick(Cash1, cashCame1, cashNice1, ledCach1, ledCach2, bipOne);
^~~~~~
bip
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void doubleclick1()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:117:65: error: 'bipTwo' was not declared in this scope
processClick(Cash2, cashCame2, cashNice2, ledCach1, ledCach2, bipTwo);
^~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:117:65: note: suggested alternative: 'bip'
processClick(Cash2, cashCame2, cashNice2, ledCach1, ledCach2, bipTwo);
^~~~~~
bip
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void longPressStart1()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:124:3: error: 'bipLong' was not declared in this scope
bipLong(false);
^~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void RxDisplay()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:139:18: error: 'class String' has no member named 'isEmpty'
if (!displayRx.isEmpty()) {
^~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void TxDisplay()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:146:18: error: 'class String' has no member named 'isEmpty'
if (!displayTx.isEmpty()) {
^~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void processClick(long int&, long int&, long int&, int, int, void (*)())':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:164:18: error: 'SendANMotors' was not declared in this scope
if (cash != 0) SendANMotors(0x25250000 + random(0xffff), cash);
^~~~~~~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:165:22: error: 'SendCame' was not declared in this scope
if (cashCame != 0) SendCame(cashCame);
^~~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:165:22: note: suggested alternative: 'rename'
if (cashCame != 0) SendCame(cashCame);
^~~~~~~~
rename
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:166:22: error: 'SendNice' was not declared in this scope
if (cashNice != 0) SendNice(cashNice);
^~~~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:166:22: note: suggested alternative: 'cashNice'
if (cashNice != 0) SendNice(cashNice);
^~~~~~~~
cashNice
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void activateJammer()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:184:3: error: 'bipOne' was not declared in this scope
bipOne();
^~~~~~
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:184:3: note: suggested alternative: 'bip'
bipOne();
^~~~~~
bip
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino: In function 'void clearCache()':
/private/var/folders/l_/tk4khlhx2zs1hq_4m1pxbb640000gp/T/.arduinoIDE-unsaved2024106-24659-hidym0.462ps/HelloWorld/HelloWorld.ino:198:3: error: 'bipLong' was not declared in this scope
bipLong(false);
^~~~~~~

exit status 1

Compilation error: 'grab' was not declared in this scope

  • Explain how we are supposed to help without seeing your code and schematic ?

  • Please read the forum’s posting guidelines.

code #include <EEPROM.h>
#include "OneButton.h"
#include <LiquidCrystal_I2C.h>

// Pin Definitions
#define rxPin 2
#define rxOn 3
#define txPin 4
#define ledCach1 8
#define ledCach2 6
#define ledJammer 7
#define btsendPin1 A1
#define btsendPin2 A2
#define bip A0

// Constants
#define pulseAN 412
#define maxDelta 200

// Button Objects
OneButton button1(btsendPin1, false);
OneButton button2(btsendPin2, false);

// State Variables
volatile unsigned long prevtime;
volatile unsigned int lolen, hilen, state;
int clickCash;

// Cache Variables
volatile static byte bcounter = 0;
volatile static long code1 = 0;
volatile static long code2 = 0;
volatile long Cash1 = 0, Cash2 = 0;
volatile long cashCame1 = 0, cashCame2 = 0;
volatile long cashNice1 = 0, cashNice2 = 0;
int CashTrigger = 1;
int cashCameTrigger = 1;
int cashNiceTrigger = 1;

// LCD Display
LiquidCrystal_I2C lcd(0x27, 16, 2);
String displayTx = "";
String displayRx = "";
bool displayClear = true;

// Function Prototypes
void setupButton(OneButton &button, void (*clickFunc)(), void (*doubleClickFunc)(), void (*longPressFunc)());
void click1();
void doubleclick1();
void longPressStart1();
void click2();
void longPressStart2();
void RxDisplay();
void TxDisplay();
void clearDisplay();
void processClick(long &cash, long &cashCame, long &cashNice, int led1, int led2, void (*bipFunc)());
bool saveCacheToEEPROM();
void activateJammer();
void clearCache();
void displaySaveStatus(bool hasData);
void displayClearStatus();
void updateDisplay(const String &line1, const String &line2);
bool saveIfNotEmpty(int address, long value);

void setup() {
Serial.begin(9600);

// Pin Initialization
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(rxOn, OUTPUT);
digitalWrite(rxOn, HIGH);
pinMode(bip, OUTPUT);
pinMode(ledCach1, OUTPUT);
pinMode(ledCach2, OUTPUT);
pinMode(ledJammer, OUTPUT);
pinMode(btsendPin1, INPUT);
pinMode(btsendPin2, INPUT);

// Button Initialization
setupButton(button1, click1, doubleclick1, longPressStart1);
setupButton(button2, click2, nullptr, longPressStart2);

// LCD Initialization
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("RF - INSTRUMENTS");
lcd.setCursor(0, 1);
lcd.print("READY");
delay(2000);
clearDisplay();

attachInterrupt(digitalPinToInterrupt(rxPin), grab, CHANGE);
randomSeed(analogRead(0));
}

void loop() {
button1.tick();
button2.tick();
RxDisplay();
}

// Button Setup Function
void setupButton(OneButton &button, void (*clickFunc)(), void (*doubleClickFunc)(), void (*longPressFunc)()) {
button.attachClick(clickFunc);
if (doubleClickFunc) button.attachDoubleClick(doubleClickFunc);
if (longPressFunc) button.attachLongPressStart(longPressFunc);
}

// Button Functions
void click1() {
processClick(Cash1, cashCame1, cashNice1, ledCach1, ledCach2, bipOne);
}

void doubleclick1() {
processClick(Cash2, cashCame2, cashNice2, ledCach1, ledCach2, bipTwo);
}

void longPressStart1() {
digitalWrite(ledJammer, HIGH);
bool hasData = saveCacheToEEPROM();
displaySaveStatus(hasData);
bipLong(false);
digitalWrite(ledJammer, LOW);
}

void click2() {
activateJammer();
}

void longPressStart2() {
clearCache();
displayClearStatus();
}

// Display Functions
void RxDisplay() {
if (!displayRx.isEmpty()) {
updateDisplay("Rx:", displayRx);
displayRx = "";
}
}

void TxDisplay() {
if (!displayTx.isEmpty()) {
updateDisplay("Tx:", displayTx);
displayTx = "";
}
}

void clearDisplay() {
lcd.clear();
}

// Utility Functions
void processClick(long &cash, long &cashCame, long &cashNice, int led1, int led2, void (*bipFunc)()) {
clickCash = 1;
if (cash != 0 || cashCame != 0 || cashNice != 0) {
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
}
digitalWrite(rxOn, LOW);
if (cash != 0) SendANMotors(0x25250000 + random(0xffff), cash);
if (cashCame != 0) SendCame(cashCame);
if (cashNice != 0) SendNice(cashNice);
TxDisplay();
digitalWrite(rxOn, HIGH);
if (cash != 0 || cashCame != 0 || cashNice != 0) bipFunc();
}

bool saveCacheToEEPROM() {
bool dataSaved = false;
dataSaved |= saveIfNotEmpty(0, Cash1);
dataSaved |= saveIfNotEmpty(10, Cash2);
dataSaved |= saveIfNotEmpty(20, cashCame1);
dataSaved |= saveIfNotEmpty(30, cashCame2);
dataSaved |= saveIfNotEmpty(40, cashNice1);
dataSaved |= saveIfNotEmpty(50, cashNice2);
return dataSaved;
}

void activateJammer() {
bipOne();
digitalWrite(ledJammer, HIGH);
updateDisplay("Jammer Active", "");
delay(3000);
updateDisplay("Jammer Stopped", "");
digitalWrite(ledJammer, LOW);
bipOne();
}

void clearCache() {
Cash1 = Cash2 = cashCame1 = cashCame2 = cashNice1 = cashNice2 = 0;
for (int i = 0; i <= 70; i++) EEPROM.put(i, 0);
digitalWrite(ledCach1, LOW);
digitalWrite(ledCach2, LOW);
bipLong(false);
}

void displaySaveStatus(bool hasData) {
clearDisplay();
lcd.print(hasData ? "Saved to EEPROM" : "No Data to Save");
}

void displayClearStatus() {
clearDisplay();
lcd.print("Cache Cleared");
}

void updateDisplay(const String &line1, const String &line2) {
clearDisplay();
lcd.setCursor(0, 0);
lcd.print(line1);
lcd.setCursor(0, 1);
lcd.print(line2);
}

bool saveIfNotEmpty(int address, long value) {
if (value != 0) {
EEPROM.put(address, value);
return true;
}
return false;
}

  • Format your sketch, then repost it using code tags

  • Is this all your code ?

  • Why are there no comments ? :thinking:

Read the error messages. Then think about what they're telling you.

Can you find any of these functions or variables in your code? No? Well, neither can the compiler.

Take a minute or two and peruse the String reference. Can you find any mention of an isEmpty method? No? So what do you expect the compiler to do, invent it?

Welcome to the forum

As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming Questions category of the forum

Please post your full sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

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