Using a LED/LDR pair to form inverting Photonic logic gates.
The entire Boolean logic set handled by resistors and diodes! Who'd'a thunk

Similar projects worth following
I always read that inverted logic as in a Not, Nor or Nand can not be made with just diodes and resistors. Well, this might just break out of that box. A inverting Not gate can be made with just one led and two resistors with one of the resistors being a CdS LDR. As of July 2019 I have Buffer, Not, AND, NAND, OR, NOR. XOR and XNOR gates working. Not the fastest gates around and not going to change the world as they are currently designed but they do work and that's all I set out to prove in the first place. Who knows what the future will be for Light Logic.

All the logic elements are now coming together for the design and build of a fully functional processor that uses only diodes, resistors and a few capacitors. It will not be fast nor small in size but it will be cool as hack and be educational and fun to watch as the user will be able to visually watch and track the flow of data from one logic gate to the next. How cool is that.

The idea for this circuit came to my mind as a rough diagram back around October 5, 2018. I had been working on my #ColorChord - A Steampunk inspired creation  project and sat back thinking about the relationship between the led bar and the CdS cells. Then began thinking about the logic combinations possible and thought that perhaps a diode ( led ) / resistor ( ldr ) would provide the way to a inverting logic gate. In a flash the circuit was in my mind and a quick test set up proved it would work. The rest might be history......

May 31, 2019 -  I now have worked out the circuits for eight individual gates. AND, NAND, Buffer, NOT, OR, NOR, XOR and XNOR. All gates use a single Light Logic element.

  • 1 × Led Green is best but white works well
  • 1 × CdS Photo Resistor LDR
  • 1 × Switching diode 1N914 or other switching diode
  • 1 × Resistor 220 Ohm minimum, use higher values as needed

  • A All Led NAND Gate

    Dr. Cockroach04/06/2021 at 10:39 2 comments

    April 6, 2021 - Working with a free form idea of replacing input switching diodes with Leds. This is a 4 input NAND gate that shows the logic flow from input to output. This circuit works well with my existing Light Logic gates.

    Input diodes are either to ground through a prior CdS LDR  for a zero or open for a one. Minimal stress on the input Leds as the CdS minimum resistance is at a safe level of about 300R or higher.

  • The Final Sequencer Circuit - I think

    Dr. Cockroach05/08/2020 at 22:02 0 comments

    At long last I decided it was time to draw the circuit for the seven step sequencer. The switch shown is only needed if the circuit will not self start. Note that the outputs step by five. That gave me several headaches trying to figure that out......

  • Light Logic - One Year Later

    Dr. Cockroach10/28/2019 at 14:49 0 comments

    Well, it's been a year now from when I started this Light Logic project and after a slow start it has come along nicely IMO.

    Let me just list the successes I have had so far to date ( Oct 28, 2019 )

    All the basic logic gates :

         Non Inverting Buffer, Not, And, Nand, Or, Nor, Xor and Xnor

    S-R Flip Flop

    D-Latch Flip Flop

    Astable Clock Flip Flop

    Seven Step Self Clocked Sequencer

    One Bit Full Adder

    Tri-State Buffer

    From these building blocks I should be able to design a basic processor using only diodes and resistors as the main components and a hand full of capacitors for a sequencer.

    This is so much fun......Can't wait for next year :-D

  • What's in a Name - Vactrol

    Dr. Cockroach10/28/2019 at 10:19 2 comments

    I have been working with Light Logic for over a year now and the name Light Logic fits quite well for the entire logic gate family ie. Not, And, Nand, Or etc....

    What I have recently been looking into was a name for the Led/LDR pair and a few names have popped up such as....

    NPV - Nesselhaus Photonic Valve @Starhawk 

    IPV - Isolated Photo Varistor @Starhawk 

    LLPT - Light Logic Photonic Transistor @Morning.Star 

    Thanks for the cool ideas my friends.

    But @Yann Guidon / YGDES  did some digging and came up with the Vactrol.

    This opto-isolated buffer uses a Led coupled to a LDR in a very small package and the Vactrol name has been in use for quite a few years and used mainly in audio applications.

    So in the end I will follow along and use the name Vactrol for my Led/LDR pair.

  • Tri-State Buffer with Diodes and Resistors

    Dr. Cockroach10/28/2019 at 09:43 0 comments

    Yeah, I know. All my projects on this page are using only diodes and resistors but I have to keep telling myself that.

    I decided to see if Light Logic would work in a Tri-State Buffer circuit intended for transistors and it actually works very nicely. No tricks used in this buffer circuit and a quick look at it will show just how basic and striped down it is. With Enable set low, the output remains Hi-Z no matter the Data setting and with Enable set High then the Data High or Low passes through just as desired.

    The ugly wiring on the back side.

    The really simple and basic circuit.

  • Latest package for Lifgt Logic

    Dr. Cockroach10/26/2019 at 11:24 0 comments

    This is the latest version of Light Logic or at least the Led/CdS pair. I have worked out a method of encapsulation using hot melt glue and black finger nail color that makes the placement of this component better suited to PCB and breadboard use.

    The transistor used as a size reference is a 2N2222 TO-92 package and shows that my Phosistor ( Not sure of the exact name of it yet, any ideas? ) is now getting close to that level.

    Also thank you Hackaday for the recent BLOG for Light Logic

  • Sequencer with a all diode display

    Dr. Cockroach08/30/2019 at 00:24 0 comments

    Sept 29, 2019 -  I am surprised that no one has commented about a slight quirk going on with the display. Notice that when transitioning from 6 to 7 that 8 is briefly shown. Turns out that the sequencer outputs 6 and 7 are both high at the same time for a brief moment and the display diode matrix has all leds active for that short time. This might actually turn out to be a bonus as it might assist with writing to a register much like the Cardboard Computer - IO. IO's sequencer had the same effect and came in handy.

    I spent the better part of this afternoon wiring the Light Logic Sequencer to the diode display from the IO project. The display counts from 1 through 7 for this circuit and loops back to 1. Not bad considering only diodes, resistors and caps are used.


    Dr. Cockroach08/20/2019 at 12:58 0 comments

    Here Be Dragons - Sounds about right for Light Logic about now. I am realizing how much in uncharted waters I have become with the development of LL. The individual gates are fairly straight forward digital in and digital out but with the design and construction of the sequencer, I see analog and digital blending and twisting around into a mesmerizing light show. Is it a part of the processor I want to design and build or is it a stand alone piece of art. Or is it both, I am so confused right now. All I do know is that I must press onward into those waters and discover what is beyond.  Thank you @Starhawk for the idea.

  • Things to remember if duplicating Light Logic

    Dr. Cockroach08/19/2019 at 14:53 0 comments

    Just some things to think about if anyone wishes to duplicate Light Logic.

    1 - There is a wide low end resistance value range with CdS photo cells so try to test and match the cells used.

    2 - Stray light will kill the Light Logic effect faster than anything else.  Light shielding around the Led/Ldr pair IS required.

    3 - Operating voltage is very critical and selection of support resistors is somewhat trial and error.

    Light Logic in its current development is still very experimental and requires a lot of hands on adjustments.

  • Sequencer Size Reduction

    Dr. Cockroach08/18/2019 at 22:21 0 comments

    This is the usable seven step sequencer for the future all Light Logic processor. Resistor and capacitor values need to be tweaked for best performance but this is working better than I had planned on in so short a time.

View all 42 project logs

Enjoy this project?



patrick.revol wrote 12/24/2019 at 19:47 point

Hello, did you try to replace the ldr with diodes to increase the switching speed?


  Are you sure? yes | no

Dr. Cockroach wrote 12/25/2019 at 10:48 point

Hey Pat, I did a couple of trials with PIN diodes and others but did not like the results. Actually I want to go the other way and try grain of wheat bulbs paired with the LDR. Goal is to see how far back in time a electronic logic device could have been used ie. 1890's ? I am sure faster switching is possible but I am the odd sort that thinks backwards rather than forwards sometimes ;-)

  Are you sure? yes | no

Andrey V wrote 08/30/2019 at 17:47 point

Interesting project. Maybe you will implement ALU on your logic gates?

  Are you sure? yes | no

Dr. Cockroach wrote 08/30/2019 at 18:11 point

Hello Andrey, Yes I will have a full 4 bit ALU for this project. I already tested out a single bit Full Adder without any problems so I think a complete processor with my rather odd gate design will work. Not fast but will work :-)

  Are you sure? yes | no

Andrey V wrote 08/30/2019 at 18:34 point

It is very impressive! I think with years I will start to do the same things)

  Are you sure? yes | no

Dr. Cockroach wrote 08/30/2019 at 20:35 point

All I can say is that you do not need years. You have all the tools and the desire so you can do it all now. I really like your lab, very impressive :-) I just work with whatever I can obtain and if I dream it then I go and do it :-)

  Are you sure? yes | no

David H Haffner Sr wrote 04/04/2019 at 19:13 point

Hello Doc, yeah been out for awhile, I was hospitalized at the VA hospital for a time but all is better now. I wasn't sure what was going to happen so I shut down a lot of my online presense except for this place, which I consider the best fit for me anyway. Glad tto see your wonderful creation evolving into a real thing of beauty! 

  Are you sure? yes | no

Dr. Cockroach wrote 04/05/2019 at 00:28 point

Glad your OK David, I wondered where you have been. Great to have you back :-D

  Are you sure? yes | no

retrac wrote 03/29/2019 at 04:16 point

This is a creative and unusual idea.  I think both neon lamps and even incandescent bulbs would work instead of an LED.  Perhaps it's possible to build a computer faster than relay logic entirely out of neons, resistors, and photoresistors.  No semiconductors at all.

One could also use a phototransistor instead of a photoresistor.  That would be quite fast with an LED compared to a photoresistor.  Rise times in the tens of microsecond.  So many variations possible!  You've struck my curiosity, I think I'll see what I can build.  Thank you.

  Are you sure? yes | no

Dr. Cockroach wrote 03/29/2019 at 11:09 point

Hey there retrac and thanks for the input :-) Oh for sure it is doable to not use any semiconductors at all by using other light sources. But as far as speed, well, the CdS photo resistors do have a fairly long reaction time so sequential logic circuits start to have issues as soon as I ramp up the clock speed. If I use a photo transistor then I defeat the idea of this project but yes, that would be a faster way to switch :-)

A friend did send me some PIN photo diodes so going to check them out once I get this project moving again.

  Are you sure? yes | no

Samuel A. Falvo II wrote 02/19/2019 at 17:09 point

If  speed becomes a concern, which I suspect it would if you are trying to build complex logic like instruction decoders and such, then you could use a 2D mask to implement a kind of ROM-like device.  The idea is that the inputs illuminate rows, and the CdS cells detects light along the columns.  The mask, which remains interstitial between the input rows and output columns, implements the complex logic.  (Remember to keep the light from each row isolated from adjacent rows!)  This restricts your propagation delays to just three layers: the input buffering/inverting to drive the rows, and the output logic to collect the columnar results into specific outputs.  This device would be "field programmable" by just swapping out the mask with a new one.

  Are you sure? yes | no

Dr. Cockroach wrote 02/19/2019 at 18:36 point

Thank you @Samuel A. Falvo II , I had not given thought that far ahead but that sounds like a great idea to try out. Yes indeed, speed will be a major factor for more complex logic.

  Are you sure? yes | no

matseng wrote 11/08/2018 at 14:35 point

-H-o-w- (EDIT: Have) you been able to make a self-latching circuit out of this?  I.E basically just a single LDR and one LED connected in series and pointed to each other?  

At full darkness the resistance of the LDR is high enough to not light up the LED, then you temporary short the LDR to light up the LED causing the resistance of the LDR to drop enough to keep the LED on permanently.

If you then temporary short the LED so it will go dark causing the LDR to be high-resistance keeping the LED in a permanent off-state.

(Some current limiting might be a good thing here...)

I played around with it a bit, but my LEDs are so sensitive that they light up enough to cascade-trigger the LDR to full-on.

If it would be possible then a memory matrix rivaling the first core memories in density could be within reach.

  Are you sure? yes | no

Dr. Cockroach wrote 11/08/2018 at 16:04 point

Hey there, The Not, Nor and Nand gates interconnect and work just like their transistor counterparts.... The only connection between the Led and Ldr is their common ground. The led is turned on and off by the previous gate by shunting to ground. So far my s-r latch and D latch are working fine as well as the master slave J-K using the clock signal from the astable that is also using the led/ldr combo :-) Excess room/sun light needs to be shielded to some extent. The self latching idea sounds like something for me to try out....Need to look into it :-)

  Are you sure? yes | no

Dr. Cockroach wrote 11/14/2018 at 10:40 point

It is very possible :-D

  Are you sure? yes | no

matseng wrote 10/29/2018 at 09:41 point

So this means that each gate have both voltage and current gain... Or else the signal would "fizzle out" after chain of a few gates.   So possibly it could be possible to make an (very bandwidth limited) audio amplifier out of LEDs and LDR's then.

[ The department of ancient knowledge wants to remind you all that the word fizzle meant "to break wind without making noise" back 500 years ago ;-) ]

  Are you sure? yes | no

Dr. Cockroach wrote 10/29/2018 at 10:45 point

Fizzle, I can still learn something new every day ;-)

Yep, each gate refreshes the output levels so I might give the gates a try at audio and hear what happens. I do not expect Hi-Fi quality though ;-)

One issue to contend with is the latency of the CdS material as that is limiting the speed of the gates.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 10/15/2018 at 21:18 point

Did you see ?
It shows one example of ROM/decoder with CdS cells :-D

  Are you sure? yes | no

Dr. Cockroach wrote 10/15/2018 at 15:08 point

Thanks Yann for bringing me out of the darkness. Glad you caught this :-)

  Are you sure? yes | no

Yann Guidon / YGDES wrote 10/15/2018 at 18:41 point

it's a pleasure to see you hacking, and I'm glad your experiments are rewarded !

  Are you sure? yes | no

esot.eric wrote 10/14/2018 at 05:43 point

Breaking all the rules! Perfect teaching-aide, too! Nicely done.

  Are you sure? yes | no

Dr. Cockroach wrote 10/14/2018 at 07:31 point

Broke / Bend, I lost track :-) Thanks :-)

  Are you sure? yes | no

Yann Guidon / YGDES wrote 10/14/2018 at 03:52 point

Is there an "optimisation" to merge the input diodes with the LED function ?

Just have the CdR as "high side" resistor, and the 1N4148 are replaced by LEDs that both shine on the photocell :-)

  Are you sure? yes | no

Dr. Cockroach wrote 10/14/2018 at 07:29 point

I was planning on trying to mount real small SMD leds to the CdS and someone else mentioned using fiber optic cables to couple the gates to each other...

  Are you sure? yes | no

Starhawk wrote 10/14/2018 at 01:50 point

You can get LED night lights with CdS cells inside at Dolla Tree, IIRC...

  Are you sure? yes | no

Dr. Cockroach wrote 10/14/2018 at 07:30 point

My Dollar Tree keeps running out of them but I will keep checking my store :-)

  Are you sure? yes | no

Kelly Heaton wrote 10/11/2018 at 13:29 point

What are the specs of your CdS Photo Resistor LDR (what resistance in light and dark)?

  Are you sure? yes | no

Dr. Cockroach wrote 10/11/2018 at 14:55 point

I read about 40K blacked out and 200 Ohms very bright. These Ldrs are from night lights sold at Wal-Mart. @Morning.Star  sent me one of his that went to almost inf when blacked out and about 30 Ohms lighted but I misplaced it for the moment :-)
 For small purchases, the four pack of led night lights with the Ldr runs about $5 and besides the Ldr and Smd led there are a few more useful parts to hack out of them ;-)

  Are you sure? yes | no

Kelly Heaton wrote 10/12/2018 at 01:47 point


  Are you sure? yes | no

Peabody1929 wrote 10/10/2018 at 15:51 point

How about using fiber optic cable to connect the LED output to the photocell input?  A 2 input gate would have two cables over a single photocell.  The fiber optic cable could even be the "wiring" between gates.

  Are you sure? yes | no

Dr. Cockroach wrote 10/10/2018 at 16:26 point

That has been mentioned as well as attaching very small SMD leds to the face of the CdS. Many ways to try this out and looking forward to testing them all :-) Thanks :-)

  Are you sure? yes | no

Morning.Star wrote 10/09/2018 at 05:21 point

Thats what I've been told, not possible. Lol, sounds like a challenge :-D

This is impressive, low level theory and technology. Nice discovery dude. Nice work! :-)

  Are you sure? yes | no

Dr. Cockroach wrote 10/09/2018 at 11:01 point

It looks as if I am going to have to write my own book on how this works. The rules have changed a little bit ;-)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates