Hey all,
Ive been working on a project and after wiring it all together - it did not seem to work. I have 2 buttons, 2 Sensors, an H Bridge and a motor (connected through the H Bridge).
This equates to 4 inputs and 3 outputs to run the system.
So I went ahead and tested each piece by itself at first.
I was able to get the buttons and sensors to show up on the Serial monitor, and I was able to start and stop the motor. HOWEVER, when I hook all the code together, I can not get the buttons to work! The idea is to press the button to turn on the motor, but when I add the motor code, the button no longer works. I made up this code to test the button using Serial
int button_start = 0; //start button status start.pin
int button_res = 0; //reset button status res.pin
int brew_time = 0; //brew time
int time_on = 0; //allows timer IF loop if =1const int res_Pin = 11; //reset button pin
const int start_Pin = 10; //start button pin
const int sens_top = 13; //top sensor pin
const int sens_bot = 12; //bottom sensor pin
const int motor_enable = 5; //enable HBRIDGE controller
const int motor_1A = 6;
const int motor_2A = 9;void setup(){
Serial.begin(9600);pinMode(res_Pin, INPUT);
pinMode(start_Pin, INPUT);
pinMode(sens_top, INPUT);
pinMode(sens_bot, INPUT);pinMode(motor_enable, OUTPUT);
pinMode(motor_1A, OUTPUT);
pinMode(motor_2A, OUTPUT);}
void loop() {
button_start = digitalRead(start_Pin);
Serial.println(button_start);}
Now, if I remove the
pinMode(motor_enable, OUTPUT);
pinMode(motor_1A, OUTPUT);
pinMode(motor_2A, OUTPUT);
from the code, the button shows up fine in the serial display. Any reason/idea/theory why this would be?? My thought was maybe somehow the OUTPUTS are draining the voltage low enough that the INPUTS are not being read at a high enough voltage to be considered HIGH? but that just seems odd...