#241

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 พ.ย. 2024

ความคิดเห็น • 231

  • @RalphBacon
    @RalphBacon  2 ปีที่แล้ว +24

    GOOD NEWS! I've tested the tri-state option now.
    You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state. This ensures no 45μA leakage through the resistors.
    If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
    Thank goodness! Obviously I designed it to do this 🤥

    • @egonsvensson2728
      @egonsvensson2728 2 ปีที่แล้ว +1

      Excellent work and fast follow up!
      I think we all learned a new trick or two today to add to our bag of knowledge :).

    • @algobit6011
      @algobit6011 2 ปีที่แล้ว +1

      Excellent work. I love your videos and your persistence and dedication.

    • @piconano
      @piconano 2 ปีที่แล้ว

      If the air is dry, and charges builds up in the air, a floating mosfet gate can and most often does trigger the mosfet.
      Its not a big deal in this application though.

    • @SmithyScotland
      @SmithyScotland 2 ปีที่แล้ว +1

      I've started using individually-addressable leds (ws2812 / Neopixles). One gpio pin, hundreds of leds.

    • @Tekwyzard
      @Tekwyzard 2 ปีที่แล้ว +1

      I did wonder why you didn't do that version. As you found out, the GPIO once declared to be an output, is very definitely either high or low and can even have a pullup enabled in setup (pinmode), so there's really no need for mosfet pullup/pulldown resistors. It'll briefly float and stuff be a bit wibbly wobbly before being defined in setup, but that's no big issue in this instance. Good video to highlight some techniques and some 'gotcha's' though that beginners probably won't have considered. I'd probably not trust the high impedance gpio input state to keep the mosfet gates off though, unless you really know enough charge, even microamps, leaks via the gpio, to keep the voltage on the gates somewhat defined.

  • @PeterCCamilleri
    @PeterCCamilleri 2 ปีที่แล้ว +2

    This is a great idea. I think it's even better than most may think. If the Arduino pin is set to an input, both LEDs should be OFF. This gives us a third state. Secondly, I think that since the gates of the MOSFETs are connected together, only one resistor is needed. R5 can be omitted. This will save a part and lower power consumption further.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Yes, if the GPIO pin keeps the MOSFET off (when required) we could kill R5. Possibly R6 too. Without using the Si4599 the Arduino does "leak" current in the INPUT mode; whether that is enough to switch on either MOSFET I haven't tested.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @ceptimus
    @ceptimus 2 ปีที่แล้ว +2

    Use a TLE2426. Looks like a transistor, but is a 'precision rail splitter', that provides 2.5V when connected across VCC and GND. It can sink or source 20mA, but draws only 280uA when not being required to sink or source current. LED can then be red, green, or off by setting the IO pin high, low, or input. You can tweak the brightness of the red and green individually (if required) by adding a small-value resistor in either the VCC or the GND line that feeds the TLE2426.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I've just spent far too long reading the datasheet for this device (thanks for the heads up) and I think you are advocating using TWO of these devices instead of my MOSFETs? Is that going to work with a bi-colour LED?
      Does each "output" pin of the TLE2426 have to go to a different LED (not a back-to-back)?
      I'm going to get a coffee now to see if my brain wakes up.

    • @ceptimus
      @ceptimus 2 ปีที่แล้ว +1

      @@RalphBacon No, you only need one. One leg of your bi-colour LED to the '2.5 volt rail' and the other to your Arduino I/O. An inline resistor of about 68 ohms will limit the LED current to 10mA - you could use 100 ohm. So the only components needed are one TLE2426, one resistor, and your bi-colour LED. If you want to adjust the red/green brightness you just add one extra resistor, probably 10 or 22 ohms to either the VCC or the GND lines that feed the TLE2426. This method is no good for blue LEDs (which need more than 2.5V to light up) but works great for standard red, green, and yellow ones.

  • @mr.bianchirider8126
    @mr.bianchirider8126 2 ปีที่แล้ว +1

    Yet another great video. This will work well with my just ‘completed’ PIR project using an ESP8266-01 that has only two readily available pins. Currently I use the remaining pin for a red LED to signal motion. With your video I can have red for movement and green for none. Sure, I could of used a Wemos R1 D2 but I enjoy the challenge of being limited.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yup sounds like a plan!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yes, the ESP-01 is, after all, an ESP8266 so ESP-NOW is available to it. I use that here in the workshop for all my sensors.

  • @davidwillmore
    @davidwillmore 2 ปีที่แล้ว +2

    As a colorblind person, I hate those red green LEDs. A few years back, I bought a bag of 100 red/blue bicolor LEDs and I have been replacing the red/green ones everywhere I can. I haven't had to swap out the current limiting resistors yet fortunately.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +2

      That must be very frustrating indeed. Yes, there are other colour combinations but I chose these as I am fed up with blue🔵LEDs everywhere (eye-searingly bright, mostly).

  • @wires4auto
    @wires4auto 2 ปีที่แล้ว

    I am 1 minute in and I think I know. Connect 1 leg of the LED to 2.5v (no idea where you get it from) then used the digital write to set the GPIO pin high or low 😜 I hope I am right.
    UPDATE
    Now 4mins in and changing my mind to using analog Write a PWM value to sort out the current limiting resistors 🤩
    Nice move with the mofets! Ok I'll order some si4599 😉 oohh I also found a FR120N relay replacement for Arduino 😁 bought.
    Cheers Ralph another great video

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      It was interesting to see how your view changed as you watched more of the video!
      Si4599 definitely worth investigating, if not for this then for the auto on/off circuit I designed a while ago (and which I'm using in my 3 storage bin lid circuits).

  • @glendenog9095
    @glendenog9095 2 ปีที่แล้ว +1

    worth noting that there are lots of 3/4 pin bi-color led available, which eliminates the need for the more expensive and complicated mosfet circuit.

    • @glendenog9095
      @glendenog9095 2 ปีที่แล้ว

      ​@gsdcbill I'll let you think about it, find one and look at the datasheet. hint, you still only need 2 resistors.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      If this bicolour sort of LED isn't any good, a single wire Neo Pixel would be an alternative, although at the expense of an Arduino library (Adafruit or fastLED, for example).

    • @glendenog9095
      @glendenog9095 2 ปีที่แล้ว +1

      @@RalphBacon I actually played an april joke on myself with that :) common emitter/collector doesn't work, series doesn't work, mosfet is a good trick!

  • @CTCTraining1
    @CTCTraining1 2 ปีที่แล้ว +2

    Thanks Ralph, another very useful technique. Maybe worth starting a new playlist for project power saving tricks? Have a great week. 👍😀

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Thanks, you too!

  • @edwardandrews9240
    @edwardandrews9240 2 ปีที่แล้ว

    2 LED's on one GPIO featuring ON_1/OFF_2, ON_2/OFF_1, as well as OFF_1/OFF_2.
    I recently viewed your single GPIO/dual LED approach - Very Novel. At the very end of your video, you showed a two led configuration (rather than the single "two-color LED" demonstrated in the video. I went forward and used that technique with two LEDs.
    Recently I was working on project where I intended to use two independent LED's, one to show "SD CARD READY", with a second LED to show "SD ACCESS-IN-PROCESS". I had orignally expected to use two GPIO pins of an ESP32, one for each LED. Your video got me to thinking and I came up with a simple scheme that you eluded to at the end of your video to drive both LEDS with one GPIO. The circuit and my notes are shown below.
    CPU +3.3V -----------------------------------------------------------------+
    LED L1 |
    +------(K) BLU (A)--------------+
    |
    CPU GPIO xx ----( R1, 390)--+
    | LED L2
    +------(A) BLU (K)------------+
    |
    |
    CPU GND ----------------------------------------------------------------+

    Here's the truth table for this curcuit
    GPIO xx L1 L2
    GPIO = Input Mode OFF OFF
    GPIO = OUTPUT_LOW ON OFF
    GPIO = OUTPUT_HIGH OFF ON
    I show BLU LEDs as they have a high enough V(fwd) voltage drop to act like non-conducting zener diodes when the GPIO PORT is in the INPUT MODE (no pull-up).
    When GPIO port is OUTPUT_LOW, L1 is ON while L2 is OFF.
    When GPIO port is OUTPUT_HIGH, L2 is ON while L1 is OFF.
    One can increase or decrease the value of R1 as needed to dial in the desired LED current/brightness level.
    Note, this circuit works well for a 3.3V CPUs and BLU or other LEDs (like White ones) that have >2V V(fwd) values but not so well with 5V CPUs.
    If using a 5V CPU, an extra silicon diode (or two/three) ("D1") in series between L1 Anode and +5V, and and additional silicon diode ("D2") (or two/three) in series between L2 Cathode and GROUND will raise the zener diode effect needed to keep the LEDs non-conducting (a.k.a.: OFF) while the GPIO port is set to INPUT mode. An extra LED can be used instead of silicon diodes in series witht the primary display LEDs to achieve the same result.
    Si Diode D1
    CPU +5.0V ------------------(A) Si Diode (K)-----------------------+
    LED L1 |
    +------(K) BLU (A)--------------+
    |
    CPU GPIO xx ----( R1, 390)--+
    | LED L2
    +------(A) BLU (K)------------+
    |
    Si Diode D2 |
    CPU GND -------------------(K) Si Diode (A)---------------------+
    If using RED LEDs with lower V(fwd) drops, you may need to add extra silicon Diodes (D1/D2) in series as needed to keep the LEDs off when needed, even if using a 3.3V CPU.
    This idea just and my notes detail a way to drive two independent LEDs from a single GPIO port. Take care.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Indeed, that approach is the one I used in my Smart Workshop Heater Controller last year: two LEDs controlled by a single GPIO pin (you can find the schematic here bit.ly/3FnIIaS - it's the bit in the "STATUS" area).
      As you say this works for 3v3 supplies (in my case, a red and green LED) but with 5v they might start to conduct anyway.
      I'm impressed with your diagrams; it must have taken you ages to line everything up (or do you have some sort of app to do this?).
      Thanks for sharing, very clear info for all readers to digest 👍

  • @jcxtra
    @jcxtra 2 ปีที่แล้ว

    Hey Ralph, thanks for the video! I'm home alone today and you kept me company (so to speak!)
    I couldn't figure out what you meant, until I saw the schematic, then I was like yeah, batteries will not be 5v unless you have a voltage converter (to buck or boost battery). Then there's the current leak, too. You could hotwire MOSFETS though (like you did!).
    It reminds me of when I was playing with "tri-state" GPIO pins (in my head). I didn't get too far with it, but the idea was you could have a pin in 3 states. So fully on at 5v, partly on at 2.5v and off at 0v. I didn't get very far with it, but was one of the ways I was looking at to reduce GPIO pins (but eventually my solution was much more simple - get rid of the individual status LEDs and replace it with a WS2812b LED since I was already using them in my project, and they only need one GPIO for pretty much any length of string, so programatically I can just make one addressable LED the status one (at any colour).
    Although I do like the approachable way you've described some quite mind boggling use of MOSfETs (they confused me at first, but now I know they're beautiful devices. Sometimes tiny but have high current capabilities)

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Someone suggested using one or more TLE2426 but even if that worked they are £3 ($5) a pop. Cheaper to buy a bigger microcontroller!

    • @jcxtra
      @jcxtra 2 ปีที่แล้ว +1

      @@RalphBacon Yes. That's always the thing to look at. When it's just for something that's needed to keep your BOM down, adding components that cost the same price as the chip isn't the best. Like with the ATTiny85, if you need a weak GPIO for something small you can use Reset but... it's not exactly much more to your BOM to go up to ATTiny84 really, and then you get 6 (iirc) more GPIO pins.

  • @fonsecaj2
    @fonsecaj2 2 ปีที่แล้ว

    Brilliant solution Ralph. You just solve me a problem of missing one pin in my AtTINY85. THANK YOU.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Always happy to help, Jose!

  • @jeffbeck6501
    @jeffbeck6501 2 ปีที่แล้ว

    Thumbs up for letting us know that red and green LEDs need different current, and thus different resistors. That is really great info to know. For most of us out here, it is success just to get the LED to turn on and off. You raised our level of knowledge. But to be more precise, the video title should have said "One GPIO, 2 mutually exclusive LED's". It only works if the 2 LEDs are mutually exclusive. When you introduced the 2 MOSFET's though, I had to leave the room. There has got to be an easier way. The first thing is to try to find a better processor with an extra GPIO. If that is not an option, then maybe just using a relay might be easier, ...although really ugly. Maybe some kind of small chip that acts like a SPDT switch. Maybe you could do with an optocoupler as well. I am using PC817s as isolators between proximity sensors and a CNC machine's motherboard that I am designing, and they are fun to work with. Maybe a tiny switch register chip might also be an option. I find it amazing that I now seem to have enough knowledge to even talk to someone like you, so I am feeling pretty good about that. With Arduino and youtube and the net, I have learned a lot about electronics in the last 10 years, and it has been pretty cool. I never thought I would ever be able to just make up just about any circuit imaginable, in both analog and digital. I can't believe I can now do that.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Like a lot of electronics, it only _looks_ more complicated than it is. The two MOSFETS are contains in a tiny 6-pin chip and I use them all the time. Easy peasy.

    • @jeffbeck6501
      @jeffbeck6501 2 ปีที่แล้ว

      @@RalphBacon It is "easy greasy" in my country.

  • @PeetHobby
    @PeetHobby ปีที่แล้ว

    9:55 We can accomplish that with only one n-type MOSFET. If we set the GPIO to high-z, and let the mosfet pull low when GPIO is in high-z mode or low(like in your circuit) then the resistor circuit will be disconnected from the ground and the GPIO is in the high-z mode so only very small leak current can flow(a couple of uA I guess).

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Well, that's a good theory; has anyone actually done it, though?

  • @uwezimmermann5427
    @uwezimmermann5427 2 ปีที่แล้ว +1

    I made a quick-test board for ATmega328-chips which I use with my students. Every once in a while some GPIO-pins get fried in the output direction and I wanted to quickly test the functionality of all output pins. So I connected 23 bicolor LEDs to a ZIFF-socket and the GPIO pins and the other side I connected to a voltage regulator set to about 1/2 of the 5 V supply voltage.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      If the GPIO (output) pin gets fried, what colour do you see? Does current always then flow _into_ the port? Curious about the use of bi-colour LEDs here.

    • @uwezimmermann5427
      @uwezimmermann5427 2 ปีที่แล้ว +1

      @@RalphBacon I'll record a #short, even though I don't like those...
      I run a test program which switches the GPIO-pins into output mode and then toggles between LOW and HIGH. A low is indicated by green and a high by red in my configuration since I connected the bi-color LEDs in this way. So for a LOW on the output the output sinks current from 2.5 V through the green LED to GND and for a HIGH the output sources current from VCC through the red LED to 2.5 V on the outside. Most often when my students fry an output the corresponding output will go into a high-resistive state (probably the bond wire burns up like a fuse) in that case neither of the two LEDs would light up in the test sequence, another failure mode could be a shorted output transistor which would turn either the red or green LED on permanently.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Understood. The final question is: what do you do with chips that have one or more GPIO pins non-functional? Just annotate that and ensure the student knows not to use, say, D3, or what? What if a whole port is dead?

    • @uwezimmermann5427
      @uwezimmermann5427 2 ปีที่แล้ว +1

      @@RalphBacon I use these for my personal projects or donate them to the students. It's mostly to avoid that the students work with broken equipment without noticing.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Sounds as though you have this nailed down 👍🏻

  • @Urmyrx
    @Urmyrx 2 ปีที่แล้ว

    Another great video ... and timely! Just yesterday I was thinking that I should learn about mosfets and replace the relay, that I added to a buck converter, to switch it on and off. Now I can (slightly modify) your circuit, replace the relay with a mosfet and detect reverse voltage = excellent!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Wow! I'm glad it has inspired you to make some changes 👍🏻

  • @algobit6011
    @algobit6011 2 ปีที่แล้ว +1

    Not to be picky, but there is still about 45.45 micro amps constantly flowing from 5v supply to ground through the 100k and 10k gate resistors in series. But definitely better than without the mosfets.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      You might get away with higher than 100KΩ / 10kΩ resistor - or none at all if the GPIO pin biases the Gates of the MOSFETs correctly - I never tried that, only just having thought about it! If I had to remove one of the resistors it would be the 10kΩ, just to see what happens.
      But with the MCU in a powered down state, and VCC still running, the MOSFETs would (probably) conduct, hence the resistors!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 2 ปีที่แล้ว

    will be good to look at the current flowing through the two resistors during switching, i expect to see a point in time where both fets are conducting due the two gates being connected together. in this application i can't see a problem with a few miliamps being drawn as a current spike. but without the resistors you could be shorting out the supply.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I suppose it depends on how quickly the MOSFETs switch. Vishay state 7-30nS switch on delay, 16-30nS to switch off. Can we live with that?

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 2 ปีที่แล้ว +1

      @@RalphBacon it's not so much the switching on and off times, it's how long the two inputs remain in the voltage range where they are both on. Remember there may be quite an overlap on switching points. In your circuit its not a real problem as the max current is limited by the two resistors, but it's worth pointing out that if those resistors were not there, you would be shorting out the supply for that cross over time. You have again given me something to think about on a friday. keep it up :-)

  • @user-fr3hy9uh6y
    @user-fr3hy9uh6y 2 ปีที่แล้ว

    I use micro controllers to save on external logic. With micro controllers costing less than $5 I now can spend almost as much to save one pin on a controller and still not be able to turn both lamps off, or PWM them, to save power. Good video on logic design, especially for applications where you need the external drivers anyway to drive larger loads.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yes, in this Real World case (my Smart Workshop Heater Controller) I always have either green or red on; at no time would the LED be unlit. But I'm sure it can be done 🤷‍♀️

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @pietpaaltjes7419
    @pietpaaltjes7419 2 ปีที่แล้ว +1

    My first impulse was to connect an inverter input (40106, 7414 or inverting opamp) to the gpio pin and connect the led between the gpio pin and the inverter output. For setting the current per led I would put a diode in series with a resistor and parallel to that the same with the diode the other way. and that lot in series with the duo led ofcourse. But I think this has draw backs, like still extra power consumption by the inverter or opamp. You only need 1 inverter in stead of 6. And maybe you can not reliably turn both leds of using 3 state of the gpio pin. So I like the fet solution better. Nice 😃

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      As the MOSFET pair is in a tiny package I agree that it is a neat solution and works well, even in tri-state mode.

  • @williammiller7543
    @williammiller7543 2 ปีที่แล้ว

    Ralph, thanks again for a great idea. I've been working on a few projects recently that didn't need WiFi so I brought out the trusty UNO. I'll switch it over to a NANO once I get it working properly.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      "Trusty UNO". Is that a new release? 😂🤣😁

  • @chrisviviers5649
    @chrisviviers5649 2 ปีที่แล้ว +1

    What about using a CD4013 latch? Just toggle its clock to flip between the two states.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Certainly another solution, Chris.

  • @WagonLoads
    @WagonLoads ปีที่แล้ว

    You could add 10 LEDs to a single GPIO using a BarGraph LED driver, and PWM the output to make a (PWM to Voltage) which selects the LED you want..
    The BarGraph chips feature a constant current output so each LED is the same brightness.
    Using your circuit, you could also PWM the output to change brightness..
    Using PWM, I was able to light the LED on a relay without tripping the relay...

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Cool! Thanks for sharing 👍

  • @robertofkennedy
    @robertofkennedy 2 ปีที่แล้ว +1

    Looks to me the current will still flow through the Mosfet pull up and pull down resistors.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      It would, albeit in the order of μA but they can be removed once it's all in place (see pinned comment for full details).

  • @andymouse
    @andymouse 2 ปีที่แล้ว +1

    Hi Ralph, love the CGI animation at the start !...cheers.

  • @Enigma758
    @Enigma758 2 ปีที่แล้ว

    So to turn the LEDs completely off you would need to set the output to an input so that it is Hi-Z. Not sure if you mentioned that in the video.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      It doesn't turn fully off; there is a small (very dim, how dim depends on the LED) leakage current. I never designed it for that 😢

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @vonries
    @vonries 2 ปีที่แล้ว

    Very cool Ralph. I never saw the solution coming, brilliant.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Even I look at the circuit, Steven, and think: that looks over-engineered; but sometimes "needs must" rules the day!

  • @avejst
    @avejst 2 ปีที่แล้ว

    Great walkthrough of the process 👍
    Thanks for sharing your experience with all of us 👍😀

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Glad you enjoyed it. Nice to see you here again, Asger 😁

  • @cheetahkid
    @cheetahkid 2 ปีที่แล้ว +2

    there is one more colour that you missed out on, Yellow. you can use PWM at 250 or 500Hz and that red green now is yellow colour.

    • @markcummings150
      @markcummings150 2 ปีที่แล้ว

      How about changing the mark-space ratio and getting everything between green and red as well.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +2

      Yes, PWM is a possibility too, although you get dirty yellow through dirty brown-ish. Not pleasant.

  • @originuk
    @originuk 2 ปีที่แล้ว

    Loving your posts. Really informative stuff - you've managed to explain things in an easily digestible way! Thank you Ralph!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      It's great you find the videos understandable and useful! 👍

  • @davidrichardson376
    @davidrichardson376 2 ปีที่แล้ว

    How about.......Connecting R1 in series with a zener diode and R2 in series with another zener diode, with the sum of both zener voltages being greater than 5V (say 3.3V each). You could Tri-State the I/O pin to turn off/flash either LED and no current will flow from the 5V rail when the IO pin is an input..

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      That's an interesting suggestion, David. As I have the circuit still on my breadboard I might try it out later and see what happens (without using any MOSFETs).

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I tried it. Brace yourself for disappointment 😥
      With an input voltage of 5v2 from my powered hub, the voltage drops to 2v7 after the first 3v0 Zener.
      Theoretically this should not be enough to pass through the second 3v0 Zener but it still manages to sink 0.9mA (858μA to be precise).
      I suspect this is because Zener diodes are not either ON or OFF. They start conducting (a bit) _before_ their knee current/breakdown voltage is reached or exceeded.
      Still far better than the 12-14mA we were experiencing before. However, the LEDs were a bit dim now and the resistors would have to be reduced to compensate - leading to an even higher Zener current flow. Sigh.
      It was well worth suggesting, though, and testing on your behalf. 😜

    • @davidrichardson376
      @davidrichardson376 2 ปีที่แล้ว +1

      @@RalphBacon Thanks RB. As soon as I hit the "Reply" button I realised that the green led would not work very well with a 3.3v zener since the green led has a higher forward voltage drop than the red led and the sum of both would be about 5.0v, with no headroom to set the led current via the series resistor value. I would need a 2.7v zener which has an even worse "Knee" region than the 3.3v unit !
      dr

  • @piconano
    @piconano 2 ปีที่แล้ว

    I would hope you don't waste 13.5mA on an LED in a battery power device, to begin with!
    Considering an Arduino consumes about 14mA @16MHz
    I find 5mA to be more than enough for any indicating LEDs.
    Love your clever circuit.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Glad you like it!
      Actually, my battery powered circuits actually consume, when 'asleep', exactly zero μA because I use my very own auto on/off circuit! Also done with an Si4599. See video #123. th-cam.com/video/g1rbIG2BO0U/w-d-xo.html
      I even have some LEDs that only need 2mA to shine quite brightly. Perfect for battery-powered devices. But difficult to find on Asian warehouse sites because they rarely tell you the minimum forward current required. Sigh.
      And we can always save the power for an LED by making it flash briefly; 5 x 50mS flashes per second is both eye-catching and power-saving! I should have mentioned that in this video. Double sigh.

  • @bobsort
    @bobsort 2 ปีที่แล้ว

    Clever Idea, I loved the solution for brightness. wouldn't it work with one mosfet? isn't it enough to cut either ground or vcc?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      If you don't block both routes then you would get leaking current from VCC to ground when the GPIO pin was HIGH. And vice versa.

  • @DuckDonald1969
    @DuckDonald1969 2 ปีที่แล้ว

    hello Ralph,
    great video!
    But you have not brought the leakage current to 0.
    It's not flowing now (5V/400 --> 12,5mA) but it's still (5V/110k --> 45,45µa) 😀
    BR Frank

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      We _might_ be able to lose one or both of the resistors. As long as one of them was not needed (because the associated MOSFET was biased OFF by the state of the GPIO pin) then there would be no current flow.

  • @jenskaa4044
    @jenskaa4044 2 ปีที่แล้ว

    I don't think the resistors is needed, your pin is either high or low. If it's 3 state the two gates will be feed by the voltage divider of the resistors

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Possibly. I'd have to see whether the MOSFETs were kept in the correct OFF (non-conducting) state when required. Or maybe one of the resistors could be removed (the 10kΩ probably).

  • @gregwmanning
    @gregwmanning 2 ปีที่แล้ว +2

    Gday Ralph. Never seen bicolour leds with only two legs. Smart way to save battery power but still a tiny leakage path via 100K and 10K.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Yes, 45μA apparently (says viewer Algobit) but we might be able to remove the 10k resistor reducing it to zero (or increase to 47k and the 100k to 150k which would mean only 25μA leakage).

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @KW-ei3pi
    @KW-ei3pi ปีที่แล้ว

    Brilliant! A little over my head, but, brilliant!

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Glad you liked it! Well, sort of liked it even if it did go over your head (sounds improbable 😀).

  • @buzzwerd8093
    @buzzwerd8093 ปีที่แล้ว

    You can get red, green, and amber for colors.

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Indeed you can, Buzz, good point.

  • @saddle1940
    @saddle1940 2 ปีที่แล้ว +1

    If you tristate the I/O pin, is 2.5v below the fet gate's knee and both fets and leds are off, or is 2.5v enough to turn it them on and the leds are off but both fets are both on?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      LEDs are off! More info in my pinned comment above 😁

  • @JohannSwart_JWS
    @JohannSwart_JWS 2 ปีที่แล้ว

    Hi Ralph. You are still technically "driving" the LED's from the GPIO pin. In your case, it works fine, but in others, it might not be. The total driving current of the ATMEGA is not that much. I've used a combination of a hex inverter, and a cheap ULN2803 to drive many bicolor LED's without loading the micro. One I/O pin per LED, two channels of the ULN driver. Even the addition of a shift register can let you drive as many of the LED's as you like, with only 3 or so I/O pins. Just a thought :-) Would make in interesting video.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I'm interested to know why it might not be suitable for all, Johann?
      The UNO can drive up to 40mA per GPIO pin although we usually accept the recommendation to keep it at 20mA or below. The LED here (quite inefficient, and not one I'd use in a battery-powered project) takes about 12mA.
      I've looked at your suggested ULN2803; if we wanted to drive lots of LEDs it might be the solution but, frankly, I'd use a NeoPixel first choice and a MOSFET 2N7000 (or similar) second choice.
      Why the ULN2803 (other than to remove the current sourcing/sinking of the MCU)?

    • @JohannSwart_JWS
      @JohannSwart_JWS 2 ปีที่แล้ว

      @@RalphBacon Hi Ralph. The total current should not exceed 200 mA, so given all the available I/O on the Uno, one must be careful not to exceed that. The Uno is typically used by relative beginners, so the impression might be that 40 mA is available on all pins simultaneously, which is not the case. Even more so on the ATMEGA 2560 (Arduino Mega). I make a habit of not using I/O to drive anything directly if I can help it. The ULN2803 driver chip is cheap, dead easy to use, and can drive a LOT of current, very fast - hence my choice. Its even suitable for driving DC motors, solenoids and large relays directly. I have a drawer full of them, and can use them for many different projects. I know there are more expensive, more elegant devices available, but I always have to source and order those specifically for a project. I prefer to use a set of fairly standard building blocks which I keep in stock. The IRL520 MOSFET's are also favourites for driving things, for all the same reasons. Further - in power sensitive circuits, LED's should really be driven with PWM. But, of course, that complicates the code somewhat. PS: This is a much bigger, and potentially more expensive issue on the Raspberry Pi (to be aware of). For which my solution is the same.

    • @SkottTomas
      @SkottTomas 2 ปีที่แล้ว

      @@RalphBacon If driving a lot of LED's is the target, Charlieplexing is also an obtion.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      @Tomas S But not with just a single GPIO pin! 😉

    • @SkottTomas
      @SkottTomas 2 ปีที่แล้ว

      @@RalphBacon No of course not 😁

  • @mukageegee
    @mukageegee 2 ปีที่แล้ว +1

    Hand up....please Mr Bacon, What is a wool wort? Sorry..I am from Lancashire!

    • @Dan-fk7vg
      @Dan-fk7vg 2 ปีที่แล้ว +2

      Wall Wart. An AC-DC adaptor that plugs straight into the wall. Similar to most mobile phone chargers.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      My sympathies and condolences to mukageegee. For both having the misfortune to come from🐑🐑🐑Lancashire _and_ not speaking anything remotely like British English. Dare I mention "Trouble at mill"? 😁😂
      My sister-in-law is from even further 'up norf' too, Durham. Can't understand a word she says. 🤷‍♂️

    • @mukageegee
      @mukageegee 2 ปีที่แล้ว +2

      🤣🤣why eye man woman man!. Going up that way in a week!

  • @romancharak3675
    @romancharak3675 2 ปีที่แล้ว

    Lovely, this solution will come in handy in future.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Indeed. I so nearly used this in my Smart Heater Controller but ended up using two physical LEDs instead. Sigh.

  • @joseph9915
    @joseph9915 2 ปีที่แล้ว

    Interesting, I didn't know they made LEDs like that.
    For the last circuit with the IC would a logic inverter work as an alternative replacement for the second pin?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      A logic inverter might work too but I guess we won't know how well until someone tries it.

  • @egonsvensson2728
    @egonsvensson2728 2 ปีที่แล้ว +1

    Here comes the twist, what if you want to turn off both LED-colours? :) Keep up the good work Ralph, as always.

    • @borayurt66
      @borayurt66 2 ปีที่แล้ว +1

      Only if poor old Arduino had tri-state IO pins. But wait, that can be added with a tri-sate buffer IC... Now, in order to drive (and turn off) a dual pack LED with a single GPIO pin, all you need is 2 mosfets, 4 resistors, and a tri-state buffer IC. :-)

    • @captainboing
      @captainboing 2 ปีที่แล้ว

      Set the pin to input

    • @1978jra
      @1978jra 2 ปีที่แล้ว

      @@borayurt66 Arduino has tristate pins, set them as inputs and boom! But I don't think that would turn both leds off. One led would be still on very dimly... probably :-D

    • @borayurt66
      @borayurt66 2 ปีที่แล้ว +1

      @@1978jra No it doesn't. You're free to try for yourself. At input state, pins sink a little current, enough to drive a standard LED at almost half brightness.

    • @jyvben1520
      @jyvben1520 2 ปีที่แล้ว

      @@captainboing which then equals ground

  • @TheUnofficialMaker
    @TheUnofficialMaker 2 ปีที่แล้ว

    very good Mr Ralph 'Clever' Bacon...so do you love playing pranks too? thought at first maybe this was April fools joke!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      No joke (as the very final pic of my Smart Heater Controller shows where I use TWO physical LEDs but wish I had used a bicolour).

  • @bluegizmo1983
    @bluegizmo1983 2 ปีที่แล้ว

    Am I missing something? ... That circuit will be drawing current at all times anyway because there is no way to turn off the LED. If pin 9 is high, the LED is on. If pin 9 is low, the LED is still on.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      See my pinned comment, Daniel, all will be made clear!

  • @david_pilling
    @david_pilling 2 ปีที่แล้ว

    Charlieplexing. You can always use the analogue pins as digital io pins.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +2

      The two GPIO-pin solution I initially show is not really Charlieplexing. It does save a ground wire but does not drive more LEDs than can be done from two GPIOs anyway.
      Three GPIOs can drive 6 LEDs though - and the more pins you can give the more LEDs you can drive.
      Yes, always good to remember that the badly named "analog pins" are actually _analog-capable_ pins but in all other respects are standard GPIO pins. 👍🏻

  • @castlecodersltd
    @castlecodersltd 2 ปีที่แล้ว

    Great video and explanation. Thank you Ralph

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Glad you liked it!

  • @gpTeacher
    @gpTeacher 2 ปีที่แล้ว

    Absolute genius Ralph! Blew my mind! "Any sufficiently advanced technology is indistinguishable from magic.", Arthur C. Clarke!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      I do have my Harry Potter Magic Set on stand-by at all times. Obvs. 😁

  • @TanjoGalbi
    @TanjoGalbi 2 ปีที่แล้ว

    With the quiz you did, the Spice Girls' Stop has the lyrics "Stop right now..." not "stop right there" so I don't know how you could get them confused! 😂
    Only kidding, of course it's obvious how it can be confused, I'm just being pedantic for effect! 🤪

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Keep working on those effects! Let's call it a Work In Progress 😁

  • @gmanshackshack6822
    @gmanshackshack6822 2 ปีที่แล้ว

    You've not blocked ALL current paths. Current can still flow between VCC and ground via R5 and R6. Now agreed, 5 volts thru 110K Ohms is a pretty small amount of current...

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Agreed, but do read my pinned comment that shows how to overcome this! All good!

  • @robertofkennedy
    @robertofkennedy ปีที่แล้ว

    The gate resistors have a path from vcc to ground ?

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      I can't remember, but it certainly works!

  • @accutrons4540
    @accutrons4540 2 ปีที่แล้ว +1

    Hi Ralph. I can’t see how the current is blocked from vcc to gnd via r5 and r6.

    • @borayurt66
      @borayurt66 2 ปีที่แล้ว

      It is not, but it will be very very low (45uA) compared to the first approach

    • @thomasvnl
      @thomasvnl 2 ปีที่แล้ว

      That would only happen in the off state (or I suppose Digital Output Floating/High Z (if that is what its called) or configured as a Digital input??) and is certainly a lot lower than 12.5mA because of the resistor values but indeed not zero!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      We _might_ be able to lose one or both of the resistors. As long as one of them was not needed (because the associated MOSFET was biased OFF by the state of the GPIO pin) then there would be no current flow.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +3

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

    • @accutrons4540
      @accutrons4540 2 ปีที่แล้ว +1

      Thank for the update. Good work

  • @dl8cy
    @dl8cy 2 ปีที่แล้ว

    cool - small things makes the different! Thanks for that interesting video!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Thanks for watching!

  • @Ed19601
    @Ed19601 2 ปีที่แล้ว

    interesting Ralph. Had not thought of this myself yet. But do I understand correctly there is no way to turn both off?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yes, that's right, I'm afraid. 😢 That said, I haven't tested the behaviour of the MOSFETs when the GPIO pin is INPUT mode. They might stay off. Without it, the Arduino leaks like a sieve!

    • @Ed19601
      @Ed19601 2 ปีที่แล้ว

      @@RalphBacon not a biggie. Though i am sure with adding a few more components and pwm-ing the pin to a certain duty cycle we can get that done as well.
      Nevertheless nifty circuit

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @MrRoyston1953
    @MrRoyston1953 2 ปีที่แล้ว

    well delivered, even I understood it.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      "Even" you, Royston? I'm sure you are doing yourself a disservice. You understand much more than you think. 😀

  • @jeffbeck6501
    @jeffbeck6501 2 ปีที่แล้ว

    So by setting a pin's mode to OUTPUT, and then setting that pin to LOW, ....could you also use that for an extra ground pin like on an Arduino? It would be really wacky to do that, but often times you are wishing you had a ground in a certain location to help with trace routing on a PCB. Would that work and would there be any drawbacks to doing that? Thanks.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yes, you can. And it's not wacky! I'm doing that right now on a project. There is a limit to how much current a GPIO can sink (rather than source) so check the datasheet for the processor you're using. Also, remember it's not a true ground; there is a tiny resistance still that might upset sensitive components you're connecting to it. But that's what prototyping is for, right?

    • @jeffbeck6501
      @jeffbeck6501 2 ปีที่แล้ว

      ​@@RalphBacon Thanks. That is interesting, and it is also good to know that there is a tiny bit of resistance in that type of grounding method. I have a big CNC machine that I use to mill and drill PCB's. My CNC machine runs on an Arduino Uno, and the probe pin is normally held high, and I am using the internal pull up resistor in the Uno, to help hold that pin HIGH. The probe, which is a drill bit in my case, ...when that drill bit probe (which is connected to ground) hits the copper PCB, it connects that Arduino probe pin (A5) to ground, and that lets the GRBL software running inside the Uno know that the probe has hit the copper pcb, and to stop probing. And it works. But sometimes it fails. And that can be really bad. So I am thinking of turning off that internal pull up resistor, and then use a regular external physical resistor connected to 5v to pull up that A5 pin to HIGH. And try different resistor values. I know there could be some resistance in my ground as I do not clip an alligator clip to the drill bit, but rather to the bracket that holds the spindle on, and that surely has some resistance. For whatever reason, sometimes it is not pulling that A5 pin to ground enough to alert the software running on the Arduino Uno that the probe has hit the copper. I have a lot of broken bits as a result of this problem. So if I can tune that circuit with maybe a higher resistor, then maybe it will make it easier for the ground to pull that A5 pin to LOW, and stop the Z axis from destroying more drill bits. A tiny bit of resistance can make a big difference in CNC's, especially when grounding the machine. If there is too much resistance, the shielding does not work well enough, and then you can EMF problems that can make a big strong CNC machine do weird things, and it can get a bit scary.

  • @gerdgerd802
    @gerdgerd802 2 ปีที่แล้ว

    How to switch off the LEDs to save battery power?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      See my pinned comment! 😁

  • @Mr.Leeroy
    @Mr.Leeroy 2 ปีที่แล้ว +1

    it is still terrible for battery powered project since you can not disable both LEDs and one will remain on even during sleep :D
    unless GPIO has high-Z output state

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Some have said that the LED will stay on, very dimly, even with the GPIO pin set to INPUT. I've just tried it out and it's true 😒

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

    • @Mr.Leeroy
      @Mr.Leeroy 2 ปีที่แล้ว

      @@RalphBacon having already 2 transistors in this arrangement it might make more sense to design your external push-pull circuitry proper to application that won't be dependent on internal GPIO structure.

  • @miriamramstudio3982
    @miriamramstudio3982 2 ปีที่แล้ว

    Smart trick. Thanks.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Glad you liked it!

  • @flashcorp76
    @flashcorp76 2 ปีที่แล้ว

    And put your Output in Tri-state mode and your LEDs are both off (? : to test🤔🙂). Wouldn't that too résistance be 10K? (instead of 100K)Cheers 🖖🏻👍🏻

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      The 100k (not 10K) is normally needed for a P-channel MOSFET but not in this case. If you read the pinned comment under this video all will be made clear!

  • @rjpeterson1
    @rjpeterson1 2 ปีที่แล้ว

    Excellent video!

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Thank you very much!

  • @paulgupta2454
    @paulgupta2454 2 ปีที่แล้ว

    How would this work with a three leg LED? I just purchased a three leg, common cathode, Red/Green and can't find a circuit diagram for single GPIO control anywhere.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      It wouldn't work in this case, because the manufacturer has already decided that the cathodes are joined together internally.
      In your case you really do need two GPIO pins, connected (via current limiting resistors) to the anodes of each diode and the common cathode brought to ground.

    • @mkitchen
      @mkitchen ปีที่แล้ว

      @@RalphBaconYou can easily drive a 3-legged LED with a single Arduino pin. The Arduino port drives the red leg of the LED directly (via the 180R) when its HIGH. The green leg is switched via a pnp transistor, its base is driven by the Arduino port going LOW via a current limiting resistor, something like a 10K. And a pnp transistor is pence and a smaller smd footprint than MOSFET driver. It works well for common anode 3-legged LED, just substitute a npn transistor.

  • @Peter_A1466
    @Peter_A1466 2 ปีที่แล้ว

    Would transistors work just as well as mosfets?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I think you could use one PNP transistor and one NPN; they must surely work although there might be some changes required to the bias resistors (if they are even needed).

    • @Peter_A1466
      @Peter_A1466 2 ปีที่แล้ว

      @@RalphBacon Thanks!
      I think I'll give it a try on my breadboard.

  • @1978jra
    @1978jra 2 ปีที่แล้ว

    ööömm... same wire, but on other end it is HIGH and on other LOW?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Which wire? Not simultanously, surely (well, for a few nanoSeconds maybe)?

  • @brettb.345
    @brettb.345 2 ปีที่แล้ว

    Great,another thing I need to buy 😄

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +2

      It's only money. The stuff I never seem to have. Even when I do it's gone immediately. Damn kids. 🧒🏻

  • @jogomez1988a
    @jogomez1988a 2 ปีที่แล้ว

    ¿Y si quieres apagarlos?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Muy simple, Jorge. Configure el pin GPIO en modo INPUT. ¡Vea el comentario fijado para más detalles! 😀

  • @32_bits
    @32_bits 2 ปีที่แล้ว

    Another good video, but is there a brief moment in time when both mosfets are on together?

    • @AnotherBrokenToaster
      @AnotherBrokenToaster 2 ปีที่แล้ว

      There is, but in that case the worst current you could have is through the 400 ohms between them, and this time is probably in the ballpark of around 100ns(conservative guess), so it shouldn't be an issue unless you are switching the color at a very high frequency. So a pulse of 12.5mA lasting 100ns when switching 10 times per second let's say is equivalent to about 1.25uA DC, and compared to the led current it is insignificant. On the other hand if you tried using PWM on the led you might have some trouble(arduino does it at 490Hz so ~1000 switches per second), You would get a 1.25mA DC equivalent current flowing which is a lot worse but within 10% of the leds' current draw so shouldn't be an issue.
      The realistic values are probably about an order of magnitude lower. If you wanted to measure this you could do it by adding a capacitor in parallel to the mosfets' power supply and measuring the current with a multimeter in dc mode.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +2

      Well, maybe. The on/off switching times of the MOSFETs are down in the nano-second region (7nS - 30nS) and we do have the resistors to limit the current anyway so there is no danger of a short circuit here (unlike with a bridge circuit).
      So there is a possibility of 12mA for 20nS per switchover. I can live with that.

  • @MAV_ist
    @MAV_ist 2 ปีที่แล้ว

    good idea

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Thank you! Cheers!

  • @petermoore9504
    @petermoore9504 2 ปีที่แล้ว

    Hi Ralph useful video as always. Have you checked out Wokwi, its an online arduino simulator/constructor. Very interesting. Cheers

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Well, Peter, I just got a BLINK sketch running on Wokwi!
      I don't know what the PacMan type connection-eaters are doing though? But I will share this in a future video (if I remember).
      Thanks for the heads-up! 👍

    • @petermoore9504
      @petermoore9504 2 ปีที่แล้ว

      @@RalphBacon yes slightly odd connections but it seems to be in its infancy, a great resource for educators nonetheless. I saw this on a channel called "upir" on his most recent video so shout out to him. Cheers

  • @jensschroder8214
    @jensschroder8214 2 ปีที่แล้ว +1

    You forgot one thing. How do you turn off both LEDs?
    Simply switch the IO pin to an INPUT then it is high-impedance.
    As an OUTPUT you can switch between high and low.
    So three statuses are possible.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      I'm guessing (I could be wrong) that you did not read the pinned comment before posting this? 🤣😂😁
      But you are 90% correct, of course. Tri-state is not high-impedance. You will get current flowing down an INPUT pin albeit very low - but not low enough not to light up an LED (dimly). Luckily this circuit solves that issue too.

  • @wilfredosandovaldelgado3690
    @wilfredosandovaldelgado3690 2 ปีที่แล้ว

    Great.

  • @ForwardGuidance
    @ForwardGuidance 2 ปีที่แล้ว +1

    Ralph, Where's the cat to walk around your arms while making videos? Time for a rescue mission?

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      Funny you should say that. 🐈 It seems we might be 'inheriting' a cat in the near-ish future, although it's not very friendly. We shall see!

    • @ForwardGuidance
      @ForwardGuidance 2 ปีที่แล้ว

      @@RalphBacon I bet you can turn that cat into a purrrrring crybaby. Hopefully it will get lonely being unfriendly and warm up. We love animals so much! Recently our dog had to go to heaven. We just relocated to the Philippines and after settling down, we'll be on a rescue mission. We've never had dogs/cats at the same time - hoping we can get there this time around.
      Love your content. I don't dabble in any electronics now, but I still enjoy your videos.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Even worse news. We're getting not ONE but TWO cats. One is an adorable fur baby, the other... well, let's say it has "spirit" and won't be snuggling me any time soon. Luckily, Dougle, our dog (Yorkie), knows them both already.

    • @ForwardGuidance
      @ForwardGuidance 2 ปีที่แล้ว

      @@RalphBacon Congratulations!! haha. I had one with spirit once, he was okay, but for some reason, if I touch his back (around just before his tail), he would swing around and come at me fast - scary fast. Because of that, we were careful with how we touched him anywhere, because those crawls hurt. He was a huge cat too. Looking forward to seeing them in the videos - animals, by the way, are good for generating comments.

  • @WagonLoads
    @WagonLoads ปีที่แล้ว

    This is great if you want one or the other LEDs on, but what if you want 3 states?
    RED, GREEN, NONE
    Opps! I see you answered this...
    I am guessing you are allowed to change GPIOs from input to output at any time.
    Beats my solution... DigitalWrite(GND, HIGH); 😉😉😉

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Yes, you can change the state of a GPIO whenever you want.

  • @GnobarEl
    @GnobarEl 2 ปีที่แล้ว

    TOP!!!

  • @flemmingchristiansen2462
    @flemmingchristiansen2462 2 ปีที่แล้ว

    The Bacon way ?? mmm sounds tasty.
    LED need no way ner 20 mA ? You might think twice about that.
    If you really want to save power, why burn energi all the time. One LED will always be on. You only need the one signal, on or off.
    Why not run a single LED on a PWM line, then you only need a capacitor to run the LED

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I disagree, Flemming. My Smart Heater Controller displays either red or green as a _positive_ indication of the state of the heater. I would not want there to be NO indication; what that mean? Heater off or circuit fried?
      For battery projects it's a different game altogether; but even smoke alarms flash the LED for a brief (20mS?) every minute just to let you know it's all working OK.
      BTW did you get that PCB yet?

  • @willofirony
    @willofirony 2 ปีที่แล้ว

    Awesome! We are not worthy.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Except we can't turn the LED off, something that I don't do in my Smart Heater Controller so never considered. 😢

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      GOOD NEWS! I've tested the tri-state option now.
      You can remove both R5 & R6 (the MOSFET Gate resistors) as they are no longer required; the GPIO pin keeps the MOSFETs in the correct state.
      If you set the GPIO pin to INPUT there is ZERO current flow in either direction. Basically, the MOSFETs do not allow current flow. The LED remains OFF. Setting it back to OUTPUT resumes normal operation.
      Thank goodness! Obviously I designed it to do this 🤥

  • @theonlymudgel
    @theonlymudgel 2 ปีที่แล้ว

    Yikes! Even I’m starting to catch on.
    Just kidding. Bet I had you goin’ for a minute.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      I know you better than that! If it includes electricity or a C++ line of code you run screaming for the outback 😜

  • @yogeshitaliya473
    @yogeshitaliya473 2 ปีที่แล้ว

    😘😘😘😘😘

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Hey Yogesh, where have you been lately 😲

  • @dr_frost_dk
    @dr_frost_dk 2 ปีที่แล้ว

    WS2812B is much easier to do for a multi color LED, only 1 resistor is needed, everything else in software, millions of colors, Fading and much more can be done, have a few videos on my channel that shows usages.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Yes, I showed them just a couple of weeks ago. Maybe that is THE answer, after all? The only fly in the ointment is that NeoPixels are normally flat (with 4 pins) whereas I would prefer a standard 3mm LED mounting.

    • @dr_frost_dk
      @dr_frost_dk 2 ปีที่แล้ว

      @@RalphBacon There are "5mm RGB addressable LEDs - WS2812 compatible" ( google search to find them ;) ), but yes no 3mm, also in all my stuff ( video's on my channel ) i always have the LED's behind 3D printed diffuser, or in my TPU buttons with LED's under them so they light up and feel good to press also ;), i also only use the 5050 package and the 2020 package of WS2812B LED's ( get jlcpcb to solder those small suckers on.... )

    • @dr_frost_dk
      @dr_frost_dk 2 ปีที่แล้ว +1

      @@jeremiahbullfrog9288 Yes, but not that much, and haven't checked, but somebody should make a very basic WS2812B driver/library without all the inbuilt effects but just with color and brightness to save on memory and space, code is already pretty easy to use ( FastLED )

  • @fredflintstone1
    @fredflintstone1 2 ปีที่แล้ว

    what the hell is a wall wart is it some sort of non english thing?? or is it a mains powered PSU???

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +3

      It's an ugly phone charger that you plug into a wall socket... A wall wart. A carbuncle. Whatever, ugly. 😁

    • @fredflintstone1
      @fredflintstone1 2 ปีที่แล้ว

      @@RalphBacon yes and $2 instead of £X to many americanisms drifting in and why did you not just use your old system th-cam.com/video/kQZU8kE3ksU/w-d-xo.html

    • @jstro-hobbytech
      @jstro-hobbytech 2 ปีที่แล้ว +2

      @@RalphBacon a carbuncle. Hahahaha I just got a bag of the 5mm ones. I thought they were blinkers when o bought them but I just run them using a triple 5 and a 2n2222 on a separate breadboard from where the output on the circuit the original 555 is on. It's convoluted to explain but I just used 2 leds in opposite directions to the collector so they flip opposite colors in the same timing. This sounds confusing because I can't draw the circuit haha. We have the same taste in leds, like coding and electronics along with flying drones Ralphy. Hahaha

    • @pietpaaltjes7419
      @pietpaaltjes7419 2 ปีที่แล้ว +1

      Ik thougt it was soms kind of pig with tusks living in your wall. 😀