Still working on my camera trap and need to have a very basic program to control two outputs with one input.
It is an infrared camera trap working on a 38khz system, everything is already made except for the programming of the ATTINY85 that will run it.
I need two outputs: when one is high, the other needs to be low and vice versa so that when the beam from the emitter is being received, output 1 is high and output 2 is low. Breaking of the beam would reverse this and when the beam is visible again it would go back to its original state.
The input is from the output of a TSSAL through an optocoupler, so basically a switch.
This is the code I have, and it does not work, and I cannot figure out why.
Something I also would like to see is each time the outputs change, there is a slight delay of maybe 60ms before the output that is being switched off goes to low, but no delay in the other output going to high - so a bit of an overlap. This is important for the camera as it needs 56ms to respond.
This is the code I have, and it does not work, and I cannot figure out why.
Maybe I'm just more irritable than usual today, but this kind of thing really pisses me off. "Does not work" means nothing to me. Obviously it's not doing what you want it to do, or you wouldn't be here. So what is it actually doing? What tests have you tried?
I have put the ATTINY on the breadboard and run it. It continues to switch between output 1 and 2 every 10 seconds or so if I leave it alone. Closing the input circuit when output 1 is high makes it instantly jump back to output 2 and the cycle of switching back and forth continues. This is the sketch I am using:
Why do you want to use an attiny for this? One of your outputs is just a copy of the input. The other output is the logical inverse of it. Why not simply use a not gate? You can make one from a single transistor. No programming required.
I did make it as an analog circuit with transistors but I need to have a triggering event, no matter how fast be able to set the output to the camera for a minimum of 60ms to ensure every beam break ends up in the camera responding. I can make the circuit hold itself with the attiny more easily than anything else.
I tried again with the attiny and had it work... sort of. The switching time was very slow, also much to my shock:
The attiny on the breadboard would switch if I move my hand anywhere near it! I'm not joking, a finger within 5mm of it but not touching would make it switch again and again. This is getting very frustrating as there is one issue after another.
Still working on my camera trap and need to have a very basic program to control two outputs with one input.
It is an infrared camera trap working on a 38khz system, everything is already made except for the programming of the ATTINY85 that will run it.
I need two outputs: when one is high, the other needs to be low and vice versa so that when the beam from the emitter is being received, output 1 is high and output 2 is low. Breaking of the beam would reverse this and when the beam is visible again it would go back to its original state.
The input is from the output of a TSSAL through an optocoupler, so basically a switch.
This is the code I have, and it does not work, and I cannot figure out why.
Something I also would like to see is each time the outputs change, there is a slight delay of maybe 60ms before the output that is being switched off goes to low, but no delay in the other output going to high - so a bit of an overlap. This is important for the camera as it needs 56ms to respond.
Any help is greatly appreciated.
Thanks
beam from the emitter is being received,
You need to define accurately the following:
(a) After the arrival of the beam from the emitter to receiver, the receiver asserts LL
at DPin-2 of Arduino.
(b) When the beam is cut-off, the receiver asserts LH at DPin-2.
To satisfy conditions (a) and (b), the DPin-2 must have external pull-up (5 K would work) or
enable internal pull-up by: pinMode(SW, INPUT_PULLUP) command.
By not working, there have been two things. Currently, I have the outputs switching back and forth without any change in the input.
That is why I asked. "Doesn't work" could mean either "LED never turns on when the switch is activated" or "LED turns on randomly even when the switch is not activated", and the causes for both can be different.
Since yours is #2, it's most likely to be a floating input like ty_ger07 suggested. Post a schematic.
The attiny on the breadboard would switch if I move my hand anywhere near it! I'm not joking, a finger within 5mm of it but not touching would make it switch again and again. This is getting very frustrating as there is one issue after another.
This is actually not as unusual as you think it is. Without going into complicated details, it has to do with the fact that having part of your body near an electric circuit slightly changes its capacitance. Capacitive proximity sensors use this to detect the presence of objects without having to touch them. A touch sensor is basically a proximity sensor that uses a threshold value to determine touch/no-touch. Theremins also use this effect to change an oscillator's frequency and create music.