Pages: [1]   Go Down
Author Topic: Serial/Sensor reading problems  (Read 394 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
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 =1

const 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...
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would run the H bridge off a different power supply. Your theory about the low voltage may be correct. You could measure it ...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually, currently the Uno is running off USB, and the buttons, hbridge etc are running of a 6V power supply (2200mah? I would have to check, its a universal AC wall adapter)

I think for the sake of getting the system to work for purpose of my upcoming presentation, I am going to rebuild the system and try to get it working.

Also, I cant seem to find this info.  If my Arduino Mini 5V, runs at 5V, will it be ok if one of the inputs rates at 6V or less?  Im curious because I am considering changing my wiring scheme so that the button connects to Ground THROUGH the Arduino, instead of using a 10k resistor and sensor wire.

Thanks!
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are running from 5V, your inputs should not exceed 5.5V (absolute maximum). See datasheet, page 313.

You can use a voltage divider to reduce an input to be within range.
Logged

Pages: [1]   Go Up
Jump to: