Getting extra outputs on the NodeMCU (ESP8266) with a 74HC595 shift register

Поделиться
HTML-код
  • Опубликовано: 30 окт 2024

Комментарии • 12

  • @randmorf
    @randmorf 8 лет назад

    Being new to NodeMCU eLua programming, your tutorial was helpful to me for figuring out how to drive a 7-Segment LEDs. I think I must have some pins crossed between the '595 and the 7-Segment display or perhaps the eLua SPI code is sending LSBit first (or some combination there of) as the 7-Segment codes I worked out didn't work. But since your program displays all possible segment combinations by performing a binary count from 1 to 255, I used that to drive my 7-segment display and since your code displays the decimal code, whenever it displayed a recognizable character on the 7-Seg LCD, I'd copy down the associated decimal number from the ESPlora terminal window. I did have to slow it down with a 3 second delay between each iteration of the for() loop so I'd have time enough to recognize the character and copy down the decimal number. So, thank you for your demo.
    I suppose I'll go back thru my wiring and try to figure out what is actually wrong, but for now I'm enjoying the fact that what I have works.
    -WRM

    • @randmorf
      @randmorf 8 лет назад

      -- --------------------------------------------------------------------------------------------------------------------------------------------
      -- Based on Luc Small's NodeMCU eLua script to drive a 74HC595 to display a binary count (1-255) to 8 LEDs
      -- RUclips video link: gist.github.com/lucsmall/66d9b6539df7a0daa569
      -- Source code link: ruclips.net/video/MimllhWR0so/видео.html
      --
      -- This script is designed to display hext digits from 0 thru F, plus space and dash
      -- to a 7-Segment LED display. While this code works, I likely had a wireing issue
      -- between the '595 and the 7-Segment display or perhaps the eLua SPI code outputs
      -- the bits LSbit first (I assumed MSbit first) because the 7-segment codes I worked
      -- worked out on paper did not work correctly. However, I was eventually able to work
      -- out the codes using Luc Small's original code with a bit of extra delay between
      -- each count.
      --
      -- --------------------------------------------------------------------------------------------------------------------------------------------
      -- Luc Small uses D2 as the 'latch' (aka 'SS', 'CS', or 'STCP') signal instead of D8; not sure why.
      latch_pin = 2
      gpio.mode(latch_pin, gpio.OUTPUT)
      gpio.write(latch_pin, gpio.LOW) -- Make sure our latch signal (CS) is low before beginning our routine
      -- Initialize SPI object
      result = spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_LOW, spi.DATABITS_8, 0)
      function print7seg(charCode)
      -- Send byte value to SPI object to transmit a bit at a time to the LED display
      spi.send(1, charCode)
      -- Pulse the latch signal line to move data fro the '595's shift register to its
      gpio.write(latch_pin, gpio.HIGH)
      gpio.write(latch_pin, gpio.LOW)
      return
      end
      -- Set up array to handle 7-Seg Display Codes for 0-F, plus 'space' and 'dash'.
      -- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, b, c, d, E, F, space, dash}
      codes = {95, 6, 59, 47, 102, 109, 125, 7, 127, 111, 119, 124, 56, 62, 121, 113, 0, 32}
      -- Cycle binary count from 0 to 255 forever
      while true do
      for i= 1, 18 do
      -- print(codes[i]) -- debug code
      print7seg(codes[i])
      tmr.delay(500000); -- wait a half second between each digit displayed.
      end -- end for() loop
      end -- end while() loop

  • @andersonxavier83
    @andersonxavier83 8 лет назад

    Do y have exemple with AT commands? I am using console arduino code.... Tanks!

  • @klmbss
    @klmbss 7 лет назад

    As for as I understand, I can power register 5v (not 3.3v), and it will be save?

  • @JoeAndolina
    @JoeAndolina 8 лет назад

    Do you have any examples of the Nodemcu with a 4051?

  • @souravdokania1929
    @souravdokania1929 7 лет назад

    I have one question, Why did you use tmr.wdclr() at line number 15 and 17

  • @ocyhaikal
    @ocyhaikal 3 года назад

    can use only gpio without spi (digitalWrite)

  • @eladgoldian8753
    @eladgoldian8753 5 лет назад

    what is the LED's name???
    how i calls?

  • @ruyvieira104
    @ruyvieira104 8 лет назад

    Is it a regular 595 or one that works with 3v3?

    • @LucSmall
      @LucSmall  8 лет назад +1

      It's a 74hc595. The 74hc logic family will work with Vcc anywhere between 2v and 6v. Check out en.wikipedia.org/wiki/7400_series for all the 7400 series variants and operating voltages.

    • @randmorf
      @randmorf 8 лет назад

      Yeah, nice thing about the 74HCxxx series is that you can set the Vcc down to 3.3V and then have your familiar "TTL" chip working at 3.3V logic levels compatible with your ESP8266 SoC or other 32-bit 3.3V MCU. That way you don't have to worry about voltage dividers and/or voltage shifters to match TTL and other +5V signal to the 3.3V inputs of the ESP8266. P.S. nice write-up Luc.

  • @taylorn2165
    @taylorn2165 7 лет назад

    Where did you buy that led?