Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Using Vin as reference voltage for a Level Shifter

  1. #1
    Junior Member
    Join Date
    Jul 2019

    Using Vin as reference voltage for a Level Shifter


    I have a project with a Teensy 3.5 where I want to read the inputs on an old NES controller.

    Because the controller sends 5V levels, I am using a TXB0104 level shifter (this one from adafruit) but I was not sure what would be the best way to feed 5V since the Teesny 3.5 is working with 3.3V

    Looking at the Teesny schematic is realized that Vusb is actually 5V and because it is connect to Vin too I could simply connect Vin to the controller and the reference voltage for the TXB0104.
    I was not able yet to read the NES controller input but so far I was able to have proper voltage on my outputs (as long as I reduce the CPU speed otherwise it seems it confuse the TXB0104 and the output has unstable readings)

    My question is: is it really safe to use Vin to power 5V components in a project?

    edit: the project is powered through the USB port.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    If your T3.5 is connected to USB and you have not cut the VUSB/VIN connection, than VIN will have the voltage from USB which is typically pretty close to +5v which should be fine

    A couple of notes/Questions:

    a) Do you really need this level shifter? The T3.5 (like the T3.2) digital pins are 5v tolerant. They will output 3.3v but will not be hurt by 5v.

    b) TXB0104 have a maximum speed they can run at.. I believe 100mbs, so you may need to put in delays to get the timings to work with the level shifter. Also not sure of how fast you can drive the shifter chip within the NES (

    c) If you use the chip you need to make sure that you wire it in the right direction: Port A can only go up to 3.6v where Port B can go up to 5.5v...

    And as always it might help to see pictures showing wiring and/or code...

  3. #3
    Junior Member
    Join Date
    Jul 2019
    Thank for answering my main question.

    I didn't go into the details of the project because I try to figure out as much as possible myself (I am very much a beginner in this field).

    a. I am not sure 100% sure I need a level shifter but the shift register inside the NES controller is a CD4021B
    The datasheet seems to indicate it would need 5V to work so I just jump on the opportunity to play around level shifters. But I didn't properly test the volage tolerance of the chip. I just ran some basic example code (including the one you linked to) that would not work anyway because the T3.5 is so much faster than the Arduino Uno.

    b. So the strange thing is that when testing the TXB0104 I simply use the following code
    void setup() {
      pinMode(23, OUTPUT);
    void loop() {
      digitalWrite(23, HIGH);
    I assumed it would send a constant 3.3V voltage to the pin and that the CPU speed wouldn't matter but that's not the result I got. At 120MHz it was running too fast for the TXB0104 (I got a really fluctuating voltage in the 5V output) but it was running properly at 24MHz.

    c. Thanks. Adafruit is kind enough to make it very clear on their board for people like me

  4. #4
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Isle in the Salish Sea
    Edit.... nevermind....I think I'm off track...

    ...The datasheet seems to indicate it would need 5V to work so I just jump on the opportunity to play around level shifters..
    Topmost row of page 4 indicates minimum supply is 3 volts.

    But the performance may be poor given the data provided about higher voltages.
    Last edited by oddson; 07-04-2019 at 08:23 PM.

  5. #5
    Junior Member
    Join Date
    Jul 2019
    I removed the level shifter, tweaked my timing when communication with the CD4021B and everything seems to run fine.

    Using the 3.3V is a bit too weak and I get a lot of garbage but using the 5V on Vin is working pretty well.

    Thanks everyone, that was easier than expected.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts