Couple of nit comments:Why int here and not byte?const int BUTTON_PIN = 7;Same with state, prevState, pin. variables that are only 0/1 don't need to be ints, and there are no pins above 255, so they also don't need to be int. You have int's all thru the example that could be byte instead.
I like the explanation you provide. This looks like stuff I just code inline in my sketches.
MrsCrsossRoads ridicules me for it, but I figure I'm saving processing time by not jumping back & forth in & out of functions,
In the datasheet 8.3 SRAM Data Memory shows the SRAM Memory as 2048 x 8 in Figure 8-3. Data Memory Map, which would seem to be in disagreement with the latter statement.
I use an int because the pinMode and digitalWrite functions take ints.In justification: the arduino is a 16-bit processor, so it's all just one bus read anyway. Using ints means that things wind up on even byte boundaries, which might be a good thing (It was a thing back in the day on x86 processors). If your sketch is just one byte short of being able to fit into ram, you probably need a mega.
I cant help feeling that people responding on this thread are missing the point a little.
I use an int because the pinMode and digitalWrite functions take ints.
void digitalWrite(uint8_t pin, uint8_t val).....void pinMode(uint8_t pin, uint8_t mode)....
Yes Robin, we have all heard many times how you prefer doing things with out classes etc.
I think my comments are as reasonable as yours are, but I have not made any personal criticisms....R
No.Code: [Select]void digitalWrite(uint8_t pin, uint8_t val).....void pinMode(uint8_t pin, uint8_t mode)....See: wiring_digital.c