Can't call function in void setup()

Hello. Again trouble (@ every character of code i type) and it's wearing on me and the will to continue this hobby.
Although it's a big Arduino communitiy i've been searching for a answer to this simple question for half an hour now.
I want to call a function in the void setup() but i'm getting the well known Compilation error: 'defaultToEEPROM' was not declared in this scope.
It seems only the function of the libs and the emebedded lib's can be called.
I'v quadruple checked it (and copy paste the name two times) but i doesn't work. If this is something that doesn't work it should be discribed somewhere.
thx

Which Arduino board are you using ?

Post an example sketch showing what you are trying to do, using code tags when you do, because it is simply not true that you cannot call a function from withing the setup() function

is that function defined in your code?

while you may include the EEPROM library, #include <EEPROM.h>, that function is not defined in the library.

You may need to scroll up in the computer output to see if there are additional warnings or errors.

This can be caused by something as simple as a misplaced bracket in the code, causing the compiler to think the function definition is inside another function, forgetting to end a multi-line comment, etc. If you can post the code that has the error then someone likely can quickly spot the problem.

Post the code.

Before you do, use the IDE Autoformat tool. It makes some errors easier to spot - you may even see the problem yourself after doing

a7
.

without your code and info about your board, we are a bit in the dark to help out as the proverbial crystal ball is still in the dishwasher...

➜ Please do yourself a favor and read How to get the best out of this forum. Post accordingly, including code with code tags, necessary documentation for your request such as your exact circuit and power supply details, links to components, etc.

3 Likes

Joined Dec 11, 2024 Read 22h (13h recently)

You missed something, somehow:

Please read.

You are working on a informatic project. And what is most needed in an informatic project is detailed information

Worse, even. You got it right starting this thread:

So, is this a new code, or do you continue to modify, and struggle with, that code? I realize this may be a new problem, but if it's with the same code, mentioning that would have enabled us to go back and pick up from that thread. Better, though, would be to present us with the new version, in a new message in THAT thread, so that we could maintain continuity, rather than firing up a new context-free thread.

That other topic has wandered between different problems during its 80 or so posts so much that it is probably a good idea to start fresh with a new problem, which this seems to be

@mutmong Please post your problem code here

Sorry for the wait but y'all have to wait a bit longer. My problem was probably caused by a syntax error that wasn't visible at first because the compiler at highest warning level didn't detect the other non-recognised functions (and then the shit hits the fan if you start to guess and try 'other' alterations). I've been trying to get things right after 3 hour of sweating and i've figured it out now. I doing my verry best to code as clear as possible but sometimes i'm looking over it a 100 times (and 9 out of 10 times it's those f*cking curly brackets. Especialy when incerting extra code). I'll try to call the function in the void setup() after i'v solved an other problem in my code. So i'll get back to you soon.
Now it's time to cool down because i was ready to plant a hammer in my Arduino board.

board Uno R3

Curly brackets are easy. They always come in pairs that enclose a block of code

What makes them even easier is to put each curly bracket on its own line with no other code and to Auto format the code in the IDE so that the code in each block is indented by the same amount. You can change the Auto format command in the IDE to do both of these things at the same time at the click of a menu item or keypress

Auto format your code often. You can never do it too many times

1 Like

Yes new problem, same sketch/project. EEPROM works fine now. But i still have to work out a problem before comming back to this and re-test.

auto format ctrl+T? Doesn't work verry well for me. Always missing the errors.

It doesn't fix them, it just formats the code so they're more obvious.

As for curlys, if you hover over one, it's matching mate is hilighted. So, hover over the opening { in an if statement, and then look to see if the code you expect to be part of the if clause is correctly encased.

It does not fix errors, rather it formats the existing code in a sensible way

Suppose, for instance, that you have missed a closing curly bracket. After Auto formatting the code it will be obvious that something is wrong because the sketch will not have its final closing curly bracket on the left margin

An example

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

    void loop()
    {
    }

At the very least try putting each curly bracket alone on its own line

In that example, the missing closure } for setup is doubly obvious, because loop() isn't to the far left. A dead giveaway.

The treads/topics become waaaay to long (80 message+) and i'v had understandable 'complaints' about it. So after multiple advice i'm starting a new topic every time a new problem arrises that i can't solve. My sketch is getting complicated and i don't want to post it completely because it will cause discussions beyond my imagination (for example: yes i tried a one button lib but after dissecting the lib for a week i was 100% shure i couldn't use it) although every thing works fine without any warnings. With every problem i encounter i try to explain the context as complete as possible/needed....and i'm getting there that way because i'm still making (slow) progress. It's going to be a little masterpiece for me because i'm not going for compromises. Everything has a good reason for doing it that way and i'm taking all the advice in account (like for example storing a key and firmware version @ the beginning of the EEPROM memory :right_facing_fist:)