Multiple Buttons on seperate digital inputs
i cannot figure out i've gone wrong. trying hook multiple buttons (each on own pin) , read results. first 2 work fine (pins 2, , 3) pin 4 doesn't seems response. so, stripped down code (see below) , set read 1 button. works other buttons, not last one.
if change pinbtn[2] index in line:
breadboard view:
https://docs.google.com/document/d/15t35rbkxem9c0rv81egeixqghhtkzm5hxxorcbuejly/edit?usp=sharing
code: [select]
const int pinbtn[] = {2,3,4};
const int pinled = 11;
int pinstate = 0;
void setup(){
pinmode(pinled, output);
for(int = 0; i<3; i++){
pinmode(pinbtn[i], input);
}
}
void loop(){
pinstate = digitalread(pinbtn[2]);
if(pinstate == high){
digitalwrite(pinled, high);
}else{
digitalwrite(pinled, low);
}
}
if change pinbtn[2] index in line:
code: [select]
pinstate = digitalread(pinbtn[2]);
0 or 1 corresponding button work. have changed last pin (pin 4) multiple other pins (in case 1 fried, same result).breadboard view:
https://docs.google.com/document/d/15t35rbkxem9c0rv81egeixqghhtkzm5hxxorcbuejly/edit?usp=sharing
try rotating button through 90 degrees.
Arduino Forum > Using Arduino > Project Guidance > Multiple Buttons on seperate digital inputs
arduino
Comments
Post a Comment