Please read my advice from post #8 more carefully. If there is something you don't understand, please ask.
ok, well I don't understand why I just have to touch the switch switching the 5v to pin 9 and the Arduino registers this as a HIGH. Otherwise the code does what it's required to do although I suspect it could be made more robust - for example what if there is a power cut with the door open, how would the Arduino start up again and deal with this?
As Tom said, you seem to have a floating input. Looking at the diagram you posted before, it's not clear which wires are connected and which are just passing each other. Please draw a proper schematic (hand drawn ok) so we can confirm that.
Also please explain what the purpose of the diode is. This type of circuit is sometimes used in automotive circuits to protect the Arduino against high voltage spikes generated by the engine ignition circuits, but I'm not sure where such spikes might come from in this circuit.
ok here is my diagram more complete. At least the wires' connections are clearer. Not sure what a floating input is. the 5v in is positive to pin 9, negative to Ardunio GND. The diode was because I had no idea how to drop 12v in to 4v and a previous post someone said the zener was necessary in case the voltage exceeded 12v, which IMO it won't as it's from the Denon Amp and likely limited. I don't believe the zener will hurt but haven't installed it anyway as yet.
Hi,
Can you please post some pictures of your project, so we can see your layout?
Thanks... Tom ..
Ok! Done. Bit messy as it's a 'test bed' at the point to get it working before adding relays etc. Breadboard in top of image with the voltage divider isn't currently doing anything other than connecting the 3 common earths, one of which is the black wire coming from the bottom of the image from the 4.8v power supply.
Not using the voltage divider at the moment as supplying 4.8v directly to pin9 / GND via the toggle switch in the bottom of the image.
Once I get this all working fine, then I can start adding in relays etc as the code will be functionally correct.
Hi,
From your picture you have pin9 connected to a switch, not the resistors on the protoboard.
PLEASE connect the resistor setup to your UNO.
The code relies on Pin9 connecting to gnd through the 1200R resistor.
With just the switch, when it is open, pin9 is not connected to anything.
An open input pin is not HIGH or LOW.
Please connect as in your diagram.
Then see if pin9 has problems.
Tom...
Thanks for the review. So - the resistor set up is for when I use 12v trigger from the Amplifier, but for this test bed I was just using 4.8v so bypassed the resistor setup as not necessary. I assumed that with the switch open then then pin9 would be low (ie only go to high on >4v) but you're saying it's floating ie not determined unless either GDN or 4V? Not sure if I could connect 4.8v to the resistor setup and it would work the same way as 12v to it? After all it drops 12v to 4v.
OK just connected up as per the diagram...and it works just the same. Still takes 3 seconds on which off.
Hi,
Just putting a 10k from Pin9 to gnd will keep your pin low when the switch is open.
Tom...
ok have connected this. Works exactly the same.
Hi,
How do you mean exactly the same.
Please post a picture of what you have done?
Hint; for the picture, cover the LED up so the camera will get proper exposure.
Tom...
Just that there is no discernable difference. Circuit still seems sensitive and spuriously acts as though receiving 4v at pin 9 when picking up switch etc.
perhaps it needs better ground?
Also code as I stated before takes 3 seconds or more on switching switch of (pin 9 to LOW) before it activates this second ELSE command, not sure why this is
Great spotting! Have connected the wire to earth and.....now it appears that all that pin 9 sees is a LOW. Even switching the switch on does nothing. Perhaps the 4.8v isn't enough as it was meant to have 12v into the resistor stack? And still doesn't address the 3-5 second wait in the code...
thanks for your help too
OK, I connected the circuit up (minus the relays) to the 12v Amp trigger, using the resistor bridge etc, powering the Uno via a 9v, and voila! works perfectly. So that's great. Even when amp signal stopped, Arduino immediately responds instead of waiting 8 seconds per previously. Being curious, I'm wondering if when on it's test bed, when I turned off the trigger, residual current had to slowly dissipate until it was registered as LOW on the pin - resulting in the long delay? Be good to know I guess. Anyway - next step - connect the relays....
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.