Hi, I'm having a problem with my Arduino mega, when i press any button it takes too long to register (1 second) but i need it to register instantly.
I need it to register fast because it will be inside a pinball machine and the ball won't touch it for long.
In general - Arrays and structs are your friends.
Don't duplicate code in your sketch. Write code once - use it multiple times.
You should not use magic numbers or magic names. The I/O pins love to have a functional name.
Do you have experience with programming in C++?
The task can easily be realised with an object.
A structured array contains all information, such as pin addresses for the I/O devices, as well as the information for the timing.
A single service takes care of this information and initiates the intended action.
The structured array makes the sketch scalable until all I/O pins are used up without having to adapt the code for the service.
It is cool stuff, isn´t it?
Hi again, thanks to the people that answered.
J-M-L, the delays aren't the problem because they are executed only after all the button are pressed.
paulpaulson, the code is probably bad but not robot generated, thanks for the coding advice but using arrays didn't fix my problem.
JCA34F, The buttons are some yl-99, they just have an output that goes low when i press the button.
johnerrington, i understand that schematics are needed to help in some cases but in my case it wound't help since it's just 3 buttons and 3 leds conects directly to arduino pins.
I think the solution is something like interrupts.
do you think the ball is waiting until the action is done before going to touch something else.. ?
if you are simulating it, when are you seeing the lag? when nothing is happening?