So basically I'm trying to design the circuit for a BCD code detector which should have 4 inputs and gives an output of 1 if the equivalent decimal is 0<=input<=9. Else, it should give zero.

Now as I understand it(although not sure) the physical circuit using LED and resistors alongside the NAND gates, should light up when the output is 1 and off when the equivalent digital output is 0.

However, as I run the simulation (and also the real circuit) the LED does not turn on and off as I explained above. Why????? enter image description here

Edit: the DCBA are simply the four digits binary input. With b corresponding to the most significant bit and A as the LSB. Now the circuit has worked as the answer below described but only if the DIP switch is rotated 180 degrees. Why though??? shouldn't a switch act as a short or open circuit and thus no matter how it's rotated, it's either on or off.

  • \$\begingroup\$ Please clarify your schematic, it presently does not make sense. Where are those bottom three logic gates connected (the three nets marked as 'B', 'C', 'D')? The only other locations in the circuit marked 'B', 'C', and 'D' are all directly connected to the +5V supply, so I hope those aren't the connection points. Also, are the two nodes marked as '?' connected together? If so, you have another problem because you have two push-pull outputs connected directly together. All in all the schematic doesn't make sense, perhaps redraw it in the CircuitLab tool provided by StackExchange? \$\endgroup\$ – Mr. Snrub Mar 5 '19 at 6:41
  • \$\begingroup\$ You will also find it much simpler to debug if you eliminate unnecessary bends and crossings in the schematic. \$\endgroup\$ – Transistor Mar 5 '19 at 7:19

Because you have the LED wired to +5V.

That means that when the output of the logic gate is high (+5V), there's no net voltage across the LED, and it remains dark.

When the gate is low (0V), then there's a difference of 5V across the LED and resistor, and the LED lights up.

If you want the LED to light up for valid BCD digits, you need to eliminate the last inverter stage and connect the cathode of the LED to the previous gate's output, which goes high for non-BCD values, and low for valid BCD values.

  • \$\begingroup\$ You sir are absolutely right and I eventually concluded the same thing. But here is a baffling thing, what you described above ( lighting up when the codes are invalid and lights off for valid inputs.) only works if the DIP switch is inverted. Meaning in the current picture it won't behave normally. This absolutely drives me nuts! Why on earth would a switch act differently when rotated 180 degree. Isn't it supposed to act as either short or open circuit? \$\endgroup\$ – user184373 Mar 5 '19 at 21:02
  • \$\begingroup\$ No. The difference is in the handle position. In one rotation, "up" is "on". When you turn it around, now "down" is "on". If you're thinking of "up" and "down" as "1" and "0" respectively, turning it around reverses the relationship. \$\endgroup\$ – Dave Tweed Mar 5 '19 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy