16-key keypad with an Arduino and a PCF8574 I/O expander module

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this video I show you a nice way to connect a 16-key keypad to an Arduino (or any i2C compatible microcontroller) with a smart device. The smart device is a PCF8574 I/O expander which allows us to have 8 I/O ports controlled via i2C. It is a great device because we do not need to sacrifice any of the native I/O ports of the Arduino since we use the i2C pins. With this additional module it is really simple to handle this 16-key keypad. This demo will show you how you can enter numbers, how you can delete characters and how you can pass the numbers to some numerical type variables (double, float, int...etc).
    Please don't forget to subscribe!
    Source code: curiousscientist.tech/blog/16...
    If you want to buy the same modules, tools...etc. I use, please look around on my website. These products are affiliate products, so when you buy something using my links, you are helping me and it does not cost you anything.
    curiousscientist.tech/tools
  • Věda a technologie

Komentáře • 47

  • @tijhevella-verney3609
    @tijhevella-verney3609 Před 2 lety +1

    A quite in-depth look at these incredibly useful chips! You could chop down on the lines by using a for loop as an example containing 4 if statements with some multiplication to figure out what each button will be depending on the first 4 bytes sent. Would be less code, but I do understand that it would not be as readable for demonstration purposes. These chips are plenty of fun indeed 😄 Thanks for the videos!

    • @CuriousScientist
      @CuriousScientist  Před 2 lety +1

      Thank you! Yes, there could have been more done in terms of code optimization. I agree that this chip is a very cool chip; it helped me in many projects where I needed a large number of I/O ports. Cheers!

  • @chrisgilbert7573
    @chrisgilbert7573 Před 2 lety +1

    Hi! I really enjoy your channel, extremely interesting and thorough. It would be super interesting to see a ESP32 Bluetooth version of this. I would imagine it could be used for your camera slider and the coil winder. Again, great work!

    • @CuriousScientist
      @CuriousScientist  Před 2 lety +1

      Hi and thank you! I used ESP32 for other projects that I have not published here, but generally, it is the same code as for Arduino as long as it does not require wifi or bluetooth. I try to avoid ESP32 for now because I do not need the wireless function and I still have a lot to learn in the world of Arduino and STM32.

  • @micultimy91
    @micultimy91 Před 3 lety +2

    hey. just discovered your channel and I am truly impressed! 👍🏻 I've seen that you've made some videos with AS5600 encoder module. Have you thought about using AS5600 as MPG for a control panel?
    I'm currently trying to build something that uses AS5600 as a MPG, but it's going to take a while because my programming skills are not that advanced. Keep the good work going! Good luck 👍🏻👍🏻👍🏻

    • @CuriousScientist
      @CuriousScientist  Před 3 lety

      Thanks! I don't see the use of the AS5600 as an MPG since there is already a specific hardware for pulse generation. It is much easier to set up an MPG (like I did in some of my videos).

  • @m.zubair387
    @m.zubair387 Před 2 lety +1

    i have a customized row column keypad, which I am running with 4094 and 4052, its working but
    i was looking for help about denounce and hold key, your video and code will help me. Good content

  • @irgski
    @irgski Před rokem

    How do you prevent key "ghosting" - where, if more than one key is pressed it may or may not cause an incorrect key press.?

  • @u_arif
    @u_arif Před 2 lety

    hey, did you try the keypad i2c library? would that not have been much easier and simpler? great vid btw

    • @CuriousScientist
      @CuriousScientist  Před 2 lety +1

      Hi! If I simply use the libraries, I never learn how these things works. I am aware of the different libraries, but I want to avoid them where it is possible.

    • @u_arif
      @u_arif Před 2 lety

      Respect bro

    • @CuriousScientist
      @CuriousScientist  Před 2 lety

      Thank you!

  • @brianxavier8873
    @brianxavier8873 Před 3 lety +1

    good job. but why did you go back to arduino and not stick to stm32 bluepill?

    • @CuriousScientist
      @CuriousScientist  Před 3 lety

      Hi and thanks! I did not have a free STM32 available and I did not want to disassemble other projects.

  • @Dekan88
    @Dekan88 Před rokem

    Hi, I just tested this code and I'm getting an error " no matching function for call to 'LiquidCrystal_I2C::begin()" Can't find anyone's code that will work with the PCF8574.

  • @rodrigobautistagutierrez5366

    How does it handle debounce?

    • @CuriousScientist
      @CuriousScientist  Před 3 lety

      I explained it in the video. Please watch it more carefully.

  • @objection_your_honor
    @objection_your_honor Před rokem

    Can I send a sequence of keyboard keys with on button press?
    EX: send "Left Shift + Right CTRL + F12" with one key press.

    • @CuriousScientist
      @CuriousScientist  Před rokem

      Hi! Sure, but not with a regular Arduino like the Nano or the Uno. You'll need something with native USB support. Arduinos with the Atmega32U4 chip are suitable for the task. Leonardo, Micro, Pro Micro could work for your task.

    • @objection_your_honor
      @objection_your_honor Před rokem +1

      @@CuriousScientist Got it thanks. I just bought 2 pro micro from AliSlow. 👍

    • @CuriousScientist
      @CuriousScientist  Před rokem

      @@objection_your_honor Super, you're welcome!
      While the boards are on their way to you, read this article on Arduino's website:
      www.arduino.cc/reference/en/language/functions/usb/keyboard/
      Alternatively, just Google "Arduino keystroke". There are many great tutorials out there.

    • @objection_your_honor
      @objection_your_honor Před rokem +1

      @@CuriousScientist Will do. Thanks.

  • @edwintok2466
    @edwintok2466 Před rokem

    Hello! Relatively new to Arduino so i was wondering if the configuration & code is compatible with Arduino Uno on tinkercad? Want to try familiarizing with tinkercad before beginning.

    • @CuriousScientist
      @CuriousScientist  Před rokem

      Hi! Sorry, I have never worked with tinkercad, so I cannot answer this question. Try it, I guess, it is just a software, nothing can go wrong.

    • @edwintok2466
      @edwintok2466 Před rokem

      @@CuriousScientist No worries! Appreciate your prompt reply, however can i ask if this is compatible for Arduino Uno R3 as well, are there anything i should look out for to change in the code

    • @CuriousScientist
      @CuriousScientist  Před rokem

      Sure, Uno and Nano (board in the video) use the same chip. I think no changes would be necessary.

    • @edwintok2466
      @edwintok2466 Před rokem

      @@CuriousScientist Tried it out and worked out really well! Thank you so much for the guidance and video. In addition can i ask if theres any guides if i want to further expand the ports by connecting another port expander?

    • @CuriousScientist
      @CuriousScientist  Před rokem

      Sure, look up PCF8574 in my videos. I have a video where I use it to grab the key presses on a keypad. I also used it in other projects.

  • @tuyenvo1038
    @tuyenvo1038 Před rokem

    Hi. My name is Vo Tan Tuyen, I come from Vietnam.
    Your project is very cool because it can apply to many projects. and my project also needs this part but I am not very familiar with Arduino can you show me how to print(entire string) to output an integer (without the ".00" character). My English is not good, there are mistakes, please forgive me.
    Thank you very much.

    • @CuriousScientist
      @CuriousScientist  Před rokem +1

      Hi! The easiest way is to store the number as an integer (int). Or if you want to print a float without the decimals, you just have to tell the print function. For example, serial.print(variable name, 0) will not print any decimals. Arduino has a really nice documentation, you should read it.

  • @Dekan88
    @Dekan88 Před rokem

    Hay, in your code, you foegot lcd.init(); and lcd.backligjt(); the lcd did not light up. The keys do not work in the right order. Can you fix your code?

    • @CuriousScientist
      @CuriousScientist  Před rokem

      I did not forget anything, you can see that the code works...
      You are not using the same LCD library as I do.

    • @Dekan88
      @Dekan88 Před rokem

      So, what is this library you're using? How can I download it?

    • @CuriousScientist
      @CuriousScientist  Před rokem

      You can download it from the library manager.

    • @Dekan88
      @Dekan88 Před rokem

      I did try that, and it did not find the library. I'll try again tomorrow.

    • @CuriousScientist
      @CuriousScientist  Před rokem

      @@Dekan88 Good luck!

  • @rodrigobautistagutierrez5366

    It does not handle debouncing at all. Desperse.

    • @CuriousScientist
      @CuriousScientist  Před 3 lety +1

      It does... You are just not watching the video carefully. First of all, you can see it in the demo that there are no bouncing. Second, the part that you seemingly cannot understand is that after the code detects any keystroke, it does not allow any other keystrokes to be detected for 300 ms. This makes sure that any bouncing decays and just a single button press is registered.