Go Down

Topic: State Change Detection Issues (Read 600 times) previous topic - next topic

larryd

The schematic for typical inputs has been reissued in post #12.



"My issue at the moment is that my push button is in a constant state of LOW"

I think it is time for you to show us your actual wiring.

Show us a good schematic of your circuit.
Show us a good image of your wiring. 
Give links to components.
Posting images: 
https://forum.arduino.cc/index.php?topic=519037.0




No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

Do you understand what UKHeliBob has told you?



No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Perehama

The vacuum pump is turned on via a relay that is activated by the Arduino pushing 5 volts to it and then the relay switches over to 120V power to turn on the pump. This part of my program works (I have witnessed it turn on the Pump), so can we please focus on my issue at hand please.

The code I know is readable to the Arduino. My issue at the moment is that my push button is in a constant state of LOW When I need it to be flexible and read between the state of LOW and HIGH. Is it not doing this because I have not defined it as a variable that will change in my code at the top?

The only things in my code that do not work are the push button to start the program and the proximity sensor to make the program wait before moving on to waiting on the button to be pushed. One thing at a time though. I need to focus on my push button for now
You are being helped my some of the forum's most experienced and veteran posters. Take their input as valuable. It is free to you, but "Knowledge is power, but powerless if you got it and you do not acknowledge it."
The slender snake hissed as she slithered slowly over the rocks, grass and leaves.

UKHeliBob

Quote
so can we please focus on my issue at hand please.
When looking for problems in my code I fix the ones that I can see, fix them look for more.  I suggest that you do the same.

In your code
Code: [Select]
if (vacuumpumpPin == HIGH)will always be true.
Fix that by reading the state of the pin with digitalRead() and test the state rather than the value of the pin.  At the very least you will get the warm feeling that results from the satisfaction of fixing a bug.  After all, you are going to have to fix it at some time so why not now ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Crezblaine

Providing a full electrical schematic will take time. This project has a lot of stuff hooked up to it so I will need a minute to build it up. I will get it to you guys at some point today hopefully. Right now, all I know is that my code reads the button as a state of low, because when I change the sensorVal to read for LOW, it skips over waiting on the button and begins to read the main program. If I can get a recognizable state change to be detected then I will be golden, but like I said, I will provide the electrical schematic asap. I appreciate all of this help.

Crezblaine

#20
Jul 15, 2019, 06:23 pm Last Edit: Jul 15, 2019, 06:31 pm by Crezblaine
Guys this is a very rough outline of the electrical on my flush cart. It is composed of terminal strips, relays, fuses, switches, buttons, LEDs, and the Arduino of course. I did my best to keep this organized and concise given that I really only have excel at my disposal to create this. I have provided a picture of the cabinet it is all going in as well. Hope this helps a little at least.

larryd

#21
Jul 15, 2019, 06:33 pm Last Edit: Jul 15, 2019, 06:35 pm by larryd




You did a good job of the drawing but this is a wiring diagram, not a schematic.








No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

cattledog

Quote
My issue at the moment is that my push button is in a constant state of LOW When I need it to be flexible and read between the state of LOW and HIGH.
You have pin 38 in INPUT_PULLUP mode. If you disconnect the wire running from the switch to pin 38, does digitalRead(38) give a 1? If it does not, then there is a problem with the Arduino.

If digitalRead(38) reads 0 when connected, then there is a wiring error, or defective switch, such that the switch connects the input to ground when not pushed.

Crezblaine

You did a good job of the drawing but this is a wiring diagram, not a schematic.

I cannot see the pictures you posted again

At the moment, my board reads LOW (0) when it is connected all the time. I will check to see if it reads HIGH (1) when the wire is not connected. I am fairly positive it is a wiring issue like you say cattledog

Crezblaine

Boys I think I figured it out.

The button I am using is a momentary push button that is normally CLOSED. So since it is connected to ground on the other end of the button, that means that while the button is not pressed, it will read LOW (0), but when I do press the button, it breaks the connection to ground and should then read HIGH. Is my assumption wrong? Here is a link to the button I am using if it helps.

https://www.mcmaster.com/catalog/125/943

Part # 6749K103

cattledog

Quote
I think I figured it out.

The button I am using is a momentary push button that is normally CLOSED. So since it is connected to ground on the other end of the button, that means that while the button is not pressed, it will read LOW (0), but when I do press the button, it breaks the connection to ground and should then read HIGH.
BINGO.

larryd

#26
Jul 15, 2019, 10:07 pm Last Edit: Jul 15, 2019, 10:13 pm by larryd
If an ohm meter reads 0 ohms when not pushed and infinite when pushed, it is an N.C. switch.

So yes, you will need to look for a HIGH to detect a push.



A S S U M E   

Ass u me. 

Makes an ass out of you and me.

;)

Good.







No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Crezblaine

Now you see guys, this is where we get into a bit of a grey area. I'm not 100% sure you can have this done in the opposite way the tutorial says. The Arduino wants to read the initial state as HIGH because that is what it sets it at using the PULLUP resistor inside of it. Logic is therefor inverted from that point on and you need to read for a LOW. If I have the button initially grounded, then the Arduino may not be able to set up the PULLUP resistor because it is reading a LOW off of it right from the start, given it is connected to ground. I might need to get a button that is initially open so that the Arduino can set up the PULLUP resistor correctly. Thoughts? Here is the link to the tutorial I am speaking of.

https://www.arduino.cc/en/Tutorial/InputPullupSerial

UKHeliBob

Quote
If I have the button initially grounded, then the Arduino may not be able to set up the PULLUP resistor because it is reading a LOW off of it right from the start, given it is connected to ground.
You are wrong in your assumption.  A quick test shows that it is perfectly possible to set the pinMode() of an input to INPUT_PULLUP whether or not the input is grounded at the time
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Crezblaine

Alright fellas,

I am still having issues, but I might know what is going on.
So, I have confirmed that if you hold the button down before the program starts, it will read HIGH, but if you don't the program will read it as LOW and it will never change if you press it or not. Strangely enough I am having the same problem with my proximity sensor. My sensor will read LOW with an object not in front of it, but when it reaches the end of the program and there is an object in front of it (so it reads HIGH when an object is in front of it), and you pull this object away (should read LOW) it will constantly read HIGH no matter if something is in front of it or not. I think it is the way I am looping the program. When using the goto statements I am, I don't actually let the program end and loop back to the beginning so that it can reset the values it has read when it started. My goto statements make the program keep existing inside itself until it reads a new value, but since the program never loops fully back around to the beginning, the values are never allowed to be reset which is why it keeps reading a constant HIGH (proximity sensor) or a constant LOW (push button). Does this sound reasonable?

Go Up