I'm getting random values which I've come to find are due to a floating input. The schematic shows a pulldown resistor being used, however there is no mention of it in the code. This is the first time I've attempted a project like this and would appreciate any guidance regarding how and where to add the pulldown code, the last time I wrote any form of programming was 20 years ago in C++ at a very basic level.
const int buttons[] = {2,3,4,5,6,7,8,9,10}; // array of all button pins
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
This is what I had as my current test circuit with external pull down resistors.
Reading the gammon article it seems that I don't need any additional code unless I want to use internal resistors. So, theoretically my current circuit shouldn't give me random values?
Are you getting the +V for the buttons from the RAW pin? That may be your problem, try the VCC pin instead.
Well, I can see how that "schematic" could cause confusion, terrible. Where does the red wire from button #6 connect on the Mini? Etc.
@sterretje: yes, just one for now. I wanted to test one pin/switch to see if I had set everything up ok.
@edgemoron: yes, I'm getting it from the RAW pin. I'll give the VCC pin a go.
@UKHeliBob: thanks for the suggestion, I'll try that too.
Thanks for the tips and feedback, electronics / programming has always been challenging to understand so I appreciate it!
Let's say I get this working with one of the suggested configurations (internal/external pull up/pulldown) and the appropriate code. How likely is it to get a false readout?
Moved to the VCC pin from RAW, still getting random outputs. I don't quite understand why this is happening.
However, I changed the code to use the internal resistor - removed my external resistor - and now I'm getting the correct output from every pin. While I've solved my problem I'd still like to know why the external resistors didn't work.
Yes Larry, I did. I understand the need for resistors. My question isn't asking about the need for resistors. I'm asking why my external pulldown resistors didn't work. Based on all the information that was provided, they were wired correctly and the code was correct.