The dreaded 'a function-definition is not allowed here before '{' token' error

It goes with out saying I am a newbie. What I am trying to do is built a altimeter for a model rocket. I started with this instructable here. However the bubble display used in the project is no longer available so I have used SparkFun’s 10931 4 digit 7 segment display.

Through many iterations I have end up with this code, but have not been able to get passed the "a function-definition is not allowed here before ‘{’ token error. I have gone through the code and counted the number of ‘{’ and ‘}’ and there are 18 of each. I have read through forums and have tried many of the suggestions but I am still stuck. This may just need a fresh set of eyes to review this to see part of the forest that I can’t see.

Please see the attached code and let me know where I have gone wrong.

Thanks in advance

new_altimeter.ino (11.1 KB)

What is the full error?

Crossroads may have that bubble display available on his bubblisuous PCB.


Nested functions (displayNumber, lightNumber) are not supported by C++. Move them out to no-man's-land.

You've placed your additional functions inside the 'setup()' function.