Go Down

Topic: Could it be done simpler? (Read 540 times) previous topic - next topic


Hi to all,

This is my first true go at coding and actually making a project that works.
I have used example sketches and some pieces of sketch that other people helped me with.

I would like to know if there was any way that things could have been done simpler? Taking into account that this is all new ground for me.

The sketch works for me as vers_1. now I have some improvements to make and a few tweaks.

Advice greatly accepted.

Coding Badly

[font=Couriern New]ulngSensorPulses [/font]needs to be protected with a critical section.

You have a large number of string constants.  I'm surprised you have not run out of SRAM.  Have you consider using the F-macro to isolate the strings to Flash (if that's possible)?

Your indentation is very inconsistent which makes it difficult to read the source code.

This snippet makes no sense...

Code: [Select]
// Read
intADKeyIn = analogRead(intAnalogPin); 
// Debounce
delay(ulngDbounce); //switch debounce delay
intDelta = (analogRead(intAnalogPin) - intADKeyIn); //gives the button a slight range to allow for a little contact resistance noise
if (intNoiseBand < abs(intDelta)) return KEYPAD_NONE;  // noise

If the two values are close to the same treat the condition as no keypress?  If the two values are close to the same I would think that indicates a good read on a keypress not a bad read.

Go Up