#49 MORE PINS PLEASE! PCF8574 Arduino Pin Extender (Easy)

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ส.ค. 2016
  • Too few pins on your Arduino? Use this I2C controlled pin extender (with optional interrupt) to make life easier!
    All sketches and other stuff can be found here on GitHub:
    github.com/RalphBacon/PCF8574...
    There are three sketches here, starting with the simplest one, an LED flasher. Well, an LED alternator might be a better description and just ensures you have wired it all up correctly (only four wires: two for power and the two I2C SDA, SCL). I then outputs via I2C a HIGH (value 0 - different to Arduino) to turn ON the LED.
    If the above statement seemed a bit odd, remember that the PCF8574 will SINK the current, not source it, so we have to make the pin there LOW to let current rush in and thereby light up the LED (or turn on the relay, whatever you have connected).
    The second sketch shows some INPUT use as well as OUTPUT so you can detect switches being pressed. Here the ultimate lesson is to understand that although you send a READ request of 1 byte to the PCF8574 and you get back all 8 bits indicating which pins are currently LOW, the ones you have used as OUTPUTs previously should be ignored (they value returned contains no meaning, it might be a 0, it might be a 1).
    Finally, the third sketch shows how we can use the interrupt pin on the PCF8574 to drive the interrupt pin on the Arduino LOW or HIGH to signal that one or more pins have now changed value (eg a switch has been pressed or released). Using interrupts is optional as you can just scan (poll) the PCF8754 for changes but it's not very efficient to do that if you are also trying to do 'other stuff' with your Arduino.
    We don't use any libraries (although plenty exist for the PCF8574) as it's more useful to understand what it going on. The only library we require is the standard Wire library for the I2C use.
    All sketches and other stuff can be found here on GitHub:
    github.com/RalphBacon/PCF8574...
    Finally, here's a link to some very useful print routines, although the one we're interested in here is for printing binary values to the Serial window: www.phanderson.com/arduino/ard...
    Any queries or comments, just put them at the bottom of the video and I'll do my best to answer!
    Once again, thanks for watching and please do spread the word, give me a thumbs up if you like the video and don't forget to subscribe to get notification of further (just about weekly) videos going forward!
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @kk6vqq-tim781
    @kk6vqq-tim781 7 ปีที่แล้ว +2

    I just got a couple PCF8574 extenders to add Arduino pins for a project. Your video is the best & most helpful explanation of how to use this handy little device. Thank you!

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

      Well thank you, Tim, nice to hear from you. I'll do a further video in due course on this little device (including some simple binary maths required to change individual bits). It might even be in conjunction with an ATTiny85 as that has only a couple of usable pins, really. Thanks for your post and kind words and I hope there are other videos here that interest you too.

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

    Even your older videos are quite useful... thank you for sharing your knowledge

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

      Glad you like them!

  • @johnharper9829
    @johnharper9829 6 ปีที่แล้ว

    Thank you so very much for this tutorial! I have wasted hours trying to figure out if my PCF8574 even worked. You nailed it! I used your flasher code and made it flash four LEDs. You have removed a major roadblock in my project.
    I got a pint with your name on it!

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

      Mine's a Real Ale, actually, John, probably a stout! Ha ha! I'm very glad you found the video useful and have "got your project off the ground", which is, of course, the tagline for this entire channel. Thank you for the feedback, and keep tuned!

  • @naboulsikhalid7763
    @naboulsikhalid7763 3 หลายเดือนก่อน

    as usual rich content and full of explanations, it seems you don't want us to miss anything. Thank you RALPH

    • @RalphBacon
      @RalphBacon  3 หลายเดือนก่อน

      I appreciate that!

  • @tonyrogers8318
    @tonyrogers8318 7 ปีที่แล้ว

    Thank you for this tutorial, you explained it really well and you are a good speaker.
    You kept my attention for the full 27m44s of the video!

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

      +Tony R
      Thanks for those kind words, Tony (and Happy New Year)! My videos are quite long (probably about 30 minutes each) but they do contain a lot of information so I'm hoping it was worth your 27m44s time and that you'll continue to watch my other videos (and, if not already, become a subscriber). Thanks for posting, I really enjoy communicating with my Arduinite viewers :)

  • @ianturner2229
    @ianturner2229 7 ปีที่แล้ว

    Great stuff Ralph, thanks for a very informative and well described video, it has help me tremendously to work out how in the hell I can monitor quite a few different reed switch sensors, and other sensors I am using, on a rather complex model railway layout without using up all my Uno/Nano/WHY chips. The crucial part was I2C and the use of interrupts, which I needed so that if a loco appeared at any location (reed switch), I could instantly take an action to avoid incorrect point direction, or indeed when a train had reached a stop point in a (very well hidden) hidden storage road.
    Many thanks indeed, keep up the good work....

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

      This is good Ian, that information is being shared and that you're finding it useful. That's what this channel is all about, "Getting your projects off the ground". It's that first step that's probably the most difficult. Anyway, thanks for posting (and I'm glad you didn't find any glaring errors in this video!), I'm always appreciative of Arduinite comments, suggestions and info like yours.

  • @Ernzt8
    @Ernzt8 7 ปีที่แล้ว

    Thanks Ralph for another useful video!

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

      I'm glad you found it useful, Ernst. As some comments in this video show there are bigger chips available too, but I have not tried those out.

  • @jarchdm
    @jarchdm 5 ปีที่แล้ว

    excellent thank you, i needed a good explanation for the interrupt use of this module and you provided in depth and understandable. !

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

      Glad you liked it KJ; funnily enough I was just playing around with it again a few days ago to get more pins on my Wemos D1 mini. I had to watch my own video to refresh my memory! How bizarre is that?

    • @jarchdm
      @jarchdm 5 ปีที่แล้ว

      @@RalphBacon ah I'm glad it's not just me who has to re learn stuff, although it makes me wonder about the state of my brain sometimes

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

      I think there is only room for so much information in anyone's brain, like a filing box. If more is shoved in then something has to come out the other side. That's my excuse anyway, and I'm sticking to it 😜

    • @jarchdm
      @jarchdm 5 ปีที่แล้ว +1

      @@RalphBacon yep that sounds reasonable??....?!! 🙃😉😁 I just remembered I think Sherlock Holmes said that so I guess it must be true..

  • @alexandropalacios7782
    @alexandropalacios7782 3 ปีที่แล้ว

    Hi! Very useful video Ralph. Thanks!

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

      Thanks, Alexandro!

  • @tomhague1162
    @tomhague1162 4 ปีที่แล้ว

    Thank you. Exactly what I needed for a project.

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

      Great, Tom, glad I could be of help!

    • @tomhague1162
      @tomhague1162 4 ปีที่แล้ว

      @@RalphBacon To set all 8 pins high would the entry not be 0xFF? 0xF would work in your case as you only were using pins 1 & 2. 255 Dec = oxFF does it not?

  • @PaulCavanagh69
    @PaulCavanagh69 7 ปีที่แล้ว

    these chips are also used in Serial Interface Board Module Port for Arduino 1602LCDs that can be purchased separately, as these have pins on one side it makes them breadboard friendly.

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

      Exactly so, Paul, which is where I first encountered them. I think these modules were specifically designed to fit the LCD board (a bit of a chicken and egg situation, perhaps) but, of course, work as you would expect as an I2C capable pin extender. Good to hear from you.

  • @rafaelmarroquin4429
    @rafaelmarroquin4429 6 ปีที่แล้ว +1

    really helpful :) thnks for show me that :) Best Regards from EL Salvador

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

      Ola Rafael! Glad you liked this video, there are now more than 100 videos for you to enjoy! Saludos de Inglaterra y gracias por su mensaje.

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

    Thank you teacher .I will use at my project.

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

    Hey Ralph, I know this vid was a while ago, but it gave me a start with Adafruit’s 8574 module. Thanks. Just a note that your initialisation only sets half the outputs. I.e. 0xF should be 0xFF. It drove me nuts for a little while. Maybe you could revisit this sometime. Cheers 👍🏾🤓

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

      Thanks for the info! Yes, "a while ago" is certainly the understatement of the year, Pete! I'll pin a correction note about the parameter you mention. 👍

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

    Best explanation for nubee like me.. thanks man

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

      Glad you liked it!

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

      @@RalphBacon Do you know how to string the binary so it can edited via array and sent editable, also send it back as binary.

  • @alexsemine1
    @alexsemine1 4 ปีที่แล้ว

    Hi Ralph. Great stuff as usual. Big fan of your channel here. I have a question about the ISR that you're explaining at the minute 24. You're using the millis() command inside your ISR, is that accurate? As far as I understand the ISRs operate kinda "outside" of the timeline of the processor, which also the reason why anything done inside the ISR should be as short as possible to avoid temporal disturbances in the execution of the rest of the sketch.

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

      Millis() does not "work" inside the ISR, that's true, Alex, inasmuch that it doesn't get updated. But the value is still available (frozen at the point of entry) so we can still use it. Certainly ISRs should be as simple and quick as possible (whilst _they_ are running, nothing else is) but this won't impede the flow too much. Finally, remember that a lot of my code is demo code to illustrate a point not what you would write for production use. Good that you spotted it though, it shows you've been paying attention!

  • @jterc2k
    @jterc2k 3 ปีที่แล้ว

    Hi Ralph, Thanks for this detailed video. I was get interested because of my ESP8266 IO pin limitation and I think this will be the answer.

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

      Glad it was helpful!

  • @CrazyCoupleDIY
    @CrazyCoupleDIY 5 ปีที่แล้ว

    Good one, thanks for sharing

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

      Thanks for your post, Crazy Couple, good to hear from you.

  • @npi8555
    @npi8555 6 ปีที่แล้ว

    Hello Ralph
    I have been working my way through your videos and hope you continue, they are factual with an explanation which is hard to come by.
    This video was also of great interest, but I wondered if you are aware that the I2C bus system has a varying latency, which if timing is not critical then it is not a problem.
    Several years ago I need some extra ports to control various stepper motors and over a period of 1hour the stepper motors where not at the correct position. During some investigation it was noted that the problem was caused by missing pulses from the I2C expander. After speaking with colleagues and talking to NXP (Philips the I2C inventors). They explained in length the problem was the I2C protocol and the buffering that it uses. Since then I have used the SPI equivalents with no problems. It would be nice to see a follow up using the SPI variant.

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

      That's interesting, not to say worrying, Neal, that the I2C expander would "miss" pulses. I'm wondering whether that was "several years ago" and things have improved now. Hmm.
      The obvious way to test this would be to connect two Arduinos together via I2C (one as slave, the other as master, via this extender) and send a sequential number down the line. If the slave did not receive the correct number then we would have found our problem.
      Frankly, given that this problem was highlighted with stepper motors which are hardly the most precise bits of machinery, I'm wondering whether these were the issue rather than the I2C bus, regardless of what Philips may have said! But we can prove the I2C issue fairly easily. That's the Royal "we", BTW!
      Expanding the number of pins via SPI (perhaps using a MCP23S17) would be a good experiment, nonetheless, so I'll add it to my growing list Interesting Things to Do! Thanks for the suggestion.

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

      I wonder whether if you had run the I2C bus at 400kHz you would have had the same problem? Or these days you can even get it to 1Mhz (not done that though!). Anyway, the SPI pin extender idea is on my list!

    • @npi8555
      @npi8555 6 ปีที่แล้ว +1

      Just a little more information.
      The I2C expander used in the project was a Microchip MCP23017 and the SPI variant was a MCP23S17. The bus line(s) pull-up resistors were 1K2 which is recommended for the 1.7MHz transfer, but due to distance/line capacitance should allow the bus to happly run at 400KHz.

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

    You did a spectacular job of showing how to wire an LED, but my challenge is in getting a push button to work. Everyone seems to demonstrate LEDs, but nobody shows how to actually wire up and communicate with an actual push button switch. That is something that would be greatly appreciated likely by more than just me.

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

      Lighting up an LED is a 'push' or output operation. Easy.
      Reading a push button is slightly more involved. Wire up the button to an extended pin, with a 10K resistor to +VCC (so the button shorts the pin to ground).
      Once you've initialised the PCF8574 using I2C in the usual way you can do this:
      Set the extended pin to INPUT mode:
      pcf8574.pinMode(P2, INPUT);
      To read the input pin (in the loop maybe):
      int p1Digital = PCF8574.digitalRead(P2);
      How do we know that a button was pressed though? When then button is pushed, the PCF8574 INTerrupt pin goes low to tell the Arduino that SOMETHING happened. You can connect this to an interrupt on the Arduino (D2 or D3) and run the function to determine which pin it was (or perhaps there is only one, like above).
      If you are a newbie, the above will not be enough for you. Look at this example:
      www.instructables.com/PCF8574-i2c-Digital-IO-Expander-Fast-Easy-Usage/
      Do you need more?

  • @moesella3542
    @moesella3542 7 ปีที่แล้ว

    Paul, still more other bigger brothers out there, like the NXP PCAL6524 24 bit and also others much higher in I/O...
    Thanks for the video Ralph

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

      Glad you liked the video, Moe, and thanks for the heads up on even bigger pin extenders, very useful.

  • @PaulCavanagh69
    @PaulCavanagh69 7 ปีที่แล้ว

    Great stuff, i'm always looking for ways to extend the GPIO of Arduino. Keep up the good work.

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

      Hey Paul! Indeed, apart from going to a MEGA this is probably one of the better (certainly cheaper) ways of extending the number of pins. Glad it helped, thanks for posting.

  • @cdfref
    @cdfref 5 ปีที่แล้ว

    Hi Ralph
    Was watching this video as always your videos are great and easy to understand. I am thinking about using these on a cable tester. Problem is I want to have a master & a remote to test a cable installed somewhere where the 2 ends can't be brought together. Got me thinking how would this work?
    I'm sure we all have cables to test at times like HDMI in walls between DVD and TV....
    We would need to know if the cable was good and if there were cross wires. Maybe a display would show simple 1-1 2-2 3-3 etc or if a cross 1-1 2-3 3-2 for example.
    Could be a great video as using these means you test cables from 2 core to 128 cores a great project.

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

      I've been thinking about this, Adrian, on and off for a couple of days. It's an intriguing question. I'd probably not use a pin extender but more something like a radio unit like the nRF24L01. Maybe. Possibly something a lot dumber at the remote end, like a switch box. I'll add this to my list of things to think about. Good idea, thanks for posting.

  • @juanbolivar35
    @juanbolivar35 4 ปีที่แล้ว

    Thanks for the video, can you control LEDs Pixels string separately with the Pin extender? or it is only for Relays?

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

      It should do everything a standard GPIO pin can do, Juanacho, so I would expect it to be able to control NeoPixels and the like. Watch the current! Ideally connect the LEDs VCC to a separate power supply and common the grounds together.

  • @nickcooper7133
    @nickcooper7133 6 ปีที่แล้ว

    Great video, very useful. Have you checked out the Microchip MCP23017 ? ... very similar except you get 16 I/O lines (divided into 2x 8 bit ports), 25mA sink OR source per I/O still using I2C (or SPI if you get the MCP23S17 variant) with operating voltages of 1.8-5.5vdc.

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

      I haven't, NIck, but I do have another Microchip MCP3--- sorry, I cannot reveal anything as that is the video-after-next, video #112, so no spoilers! It's not so much a pin extender I'm doing next as a pin ---- sorry, can't reveal that either. Oh dear. Seriously, though, your MCP23017 sounds interesting and I like the wide operating voltage, good for 3.3v and 5v µControllers then. Keep tuned to see what I was going on about!

    • @nickcooper7133
      @nickcooper7133 6 ปีที่แล้ว

      Ooo ... sounds intriguing?? I will keep tuned. I read your blog also, very very sad. My thoughts are with you & your family. Contrary to what people say I don't think "time heals", you just learn to accept it & carry on with life. Benny will no doubt help with this process.

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

      You are correct, Nick. Time does not heal. I just learn not to think about it too much. Benny is a delight, every single day. And he keeps correcting my sketches for me, he's a genius too. Thanks for posting, I hope I haven't over-egged my next-but-one video!

  • @startobytes
    @startobytes 3 ปีที่แล้ว +1

    Very good video

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

      Thanks for the visit!

  • @9brian99
    @9brian99 4 ปีที่แล้ว

    Thanks another great video

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

      Glad you liked it Malcolm!

  • @JoeEvansSound
    @JoeEvansSound 5 ปีที่แล้ว

    Fantastic video. Thank you very much. Very clear instructions and very clearly explained in fabulous English without using "you guys" or starting your sentences with "so" 😉. Can you explain how you would physically daisy chain these devices together, I can't see how you would do it. Thanks very much.

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

      So, you guys, what's up? Oh no!!! I promise never to say those words again! Regarding "daisy chaining" that's not how you do it for the I2C bus, you put all devices in parallel and ensure you configure them to have different hex addresses so you can talk to each one individually, via that address. If you need further explanation let me know, PJ.

    • @JoeEvansSound
      @JoeEvansSound 5 ปีที่แล้ว

      @@RalphBacon ah ha I see. I have looked as some other i2c expanders and I now see there is a plug and socket version so I can connect a few together. Exactly what I need. Thank you very much. :-)

  • @Michael-hn5gi
    @Michael-hn5gi 4 ปีที่แล้ว

    Good morning! I have an arduino micro leonardo atmega32u4 and I wanted to ask if I can use the pcf 8574 expander to multiply the number of pins to connect more buttons and potentiometers? Best wishes.

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

      Yes, Michal, it works via I2C so it should work in exactly the same way. Good luck with this (not that you will need it, it's pretty straightforward).

  • @peterbodnaruk3040
    @peterbodnaruk3040 6 ปีที่แล้ว

    Great video. Could you do one on the Eclipse IDE, especially Sloeber if you use that?
    Pete Bodnaruk

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

      See my reply to you in video #69!

  • @JoeEvansSound
    @JoeEvansSound 5 ปีที่แล้ว

    Hi Ralph - quick question - I am thinking of changing from Arduino IDE to something else. Can you tell me please - I notice you are using a different IDE - what is it please? Thanx

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

      Send me an email. PJ, and I'll send you the exact same email I've already sent two others this week! My email address in in the About section of my channel.

  • @raymondheath7668
    @raymondheath7668 7 ปีที่แล้ว

    I can see the advantage of having a port expander on the I2C bus rather than three dedicated lines for the 74HC595

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

      Indeed, I wanted to get the I2C expander running for the ATTiny85 but managed to get I2C running happily without it. And of, course, with 6 GPIO pins available on that chip now (after my hack... hmmm, not sure that video has been released yet) it might not need one so urgently either.

  • @neilbarnett3046
    @neilbarnett3046 6 ปีที่แล้ว

    The last electronic bits I ordered from China came from Manchester, that's one example of how some companies can ship much more quickly.

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

      And I guessed as much when items from Amazon can be delivered the next day (from China, but either from Amazon's own warehouse, or the supplier's, based as you say in the UK). Good for us, however they do it! Good to hear from you Neil.

  • @asagk
    @asagk 5 ปีที่แล้ว +1

    The use of I²C ready to go ICs has one significant downside... the price. They mostly come so expensive that it already makes one think about to use an ATmega at a similar price to use instead as an I²C slave. And that can be a pretty nice idea!
    Take a look at the most obvious advantages and disadvantages for such attempt:
    + The use of the internal oscillator of an ATmega (8Mhz) offers 2 additional IO-Pins and spares the cost of an external cryastal as well as for the two of 22pF ceramic caps. But using an external crystal of course works also fine.
    + The number pins available, even when two are consumed for I²C (SCLand SDA), is greater than the ones that come with even 2 of PCF8574.
    + An ATmega that comes with I²C interface, can also act as an I²C slave. (sometimes even with extended addressing capability, instead of only 7 bit addressing scheme)
    + In addition to the capabilities of a "ready to go I²C" device, the ATmega as a I²C slave can do stuff like PWM etc. on it's output pins and comes with integrated timers etc. for complex timings.
    + An ATmega can go into modes that reduce power consumption, of which some even allow to wake up (address recognition wake-up) quickly again to serve I²C requests.
    - A major disadvantage is that an ATmega is very limited when it comes to the amount of current that can be sourced/drained on each of the ic-pins (also true for most I²C "ready to go" devices). But to get around this cheap external transistors (BC4xx/BC5xx or similar for less than 2 cents per piece) can be used to address this issue.
    In my personal opinion it makes a good point not make any use of most of the avaiable I²C devices, but instead buy ATmega in quantities where they start getting even cheaper per piece than when bought in very small numbers, and use Atmegas in I²C- / SPI-slave-mode to create custom I/O-devices, containing extended features beyound the ones that come with "ready to go" I²C-devices.
    The price of useing ATmega is compared to I²C peripheral devices at least the same or even lower, depending on the type of ATmega being used as an I²C / SPI emulating device.
    In fact I mostly use PIC24FJ16GA002 as "intelligent" peripheral ICs, because I got a bunch of them for very cheap some time ago... . But a cheap ATmega like Atmega48PA (

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

      Yes, that is an interesting point. And, in fact, one I adopted in a recent video about restarting the Raspberry Pi. Rather than some convoluted mix of analog components I just used a cheap ATTiny85. So it seems we are on the same page! Thanks for posting, Sebastian, good to hear from you.

  • @djsbriscoe
    @djsbriscoe 3 ปีที่แล้ว

    Do you know of any example code to control a standard 16x2 LCD via the PCF8574 using an arduino that just uses the wire library and NOT an external library. I want to understand the gory details of how to send commands one by one. I'm sending commands from a command line interface (provided by Microchip) via a Microchip MCP2221A USB to I2C bridge. The I2C commands can be read from a text file and sent over this bridge. Just need to understand the individual commands. Do you know of any code?

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

      I don't have such information to hand, I'm afraid, (I'm moving house so everything is packed up) but the datasheet for the LCD will tell you the commands to use. Alternatively, look at an existing library and see what is being executed - but warning, they may be poorly commented.

  • @JoeEvansSound
    @JoeEvansSound 5 ปีที่แล้ว

    Hi again Ralph. On a slightly different note... I need 60 odd led lamps which I am going to now use I2c but I also need 50 input push-buttons. I have an arduino Mega so there shouldn't be a lack of normal pins left over to spare.... however do you happen to know if I can use an interrupt to check the pins to see if "any" button has been pressed without going through "each" button to see if "it" has been pressed? Thanks very much. PJ

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

      When using this device you do have to poll to see which one it was, unfortunately, PJ. There's no data sent back as to which pin went high or low, it's not sophisticated. But a simple loop would be sufficient to do this.

    • @JoeEvansSound
      @JoeEvansSound 5 ปีที่แล้ว +1

      @@RalphBacon ah ha I see. Shame about that. Ok thanks very much for that and your continued support. ☺

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

    If I have a lot of led's to run and the power requirements were already pushing the limits on the arduino, could I run this board/chip on a separate 5v supply to run more led's and therefore not overload the arduino?

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

      Exactly so. I tend to use dedicated 5v supplies anyway (common GND) when powering external equipment such as LEDs or motors.

  • @amikhimji
    @amikhimji 4 ปีที่แล้ว

    GREAT VIDEO THANKS

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

      Glad you enjoyed it

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

    Hi, my question is, trying to simulate the project in proteus a fault occurs, could you tell me how to connect the circuit in more detail?

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

      I'm guessing that Proteus does not understand that chip so can't simulate what happens. I'm afraid I don't know or use Proteus so can't help further.

  • @SimpleEnough2k9
    @SimpleEnough2k9 4 ปีที่แล้ว

    I'm using the same board with a keypad. I was hoping that the INT pin would work when a key is pressed but no luck so far. I'm using the Keypad_I2C library. The keys are returned as expected but the interrupt doesn't seem to trigger when a key is pressed. Any idea or I2C keypad library to suggest ? Regards.

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

      I'm trying to remember this far back, but I'm sure that when the state of any of the inputs changed you get a HIGH on the INT pin (not sure for how long though, but long enough to trigger an interrupt on your Arduino). How are you using this INT pin, as an input into an interrupt routine (so using pin D2 or D3 on an UNO)?

    • @SimpleEnough2k9
      @SimpleEnough2k9 4 ปีที่แล้ว

      @@RalphBacon Yes, I'm using pin D2. I tried D3 which gave me the same results. I'm using the "attachInterrupt(digitalPinToInterrupt(interruptPin), KeyPressed, CHANGE);" statement to attach the interrupt. "KeyPressed" is a function that sets a flag which is previously defined at the very top of the sketch as a volatile variable. I'm using the RC circuit from the datasheet as you described. I can confirm that if I disconnect the INT pin from the PCF board and bring the pin D2 low, by shorting the cap's leads, the ISR routine is invoked. At first glance it looks to me that the INT pin from the PCF board isn't doing what it should. Perhaps you or someone else could consider giving it a try and let me know where I goofed ! Thanks again for your help.

  • @elodiecemoi3057
    @elodiecemoi3057 4 ปีที่แล้ว

    Hi Ralph,
    Congratulations for this excellent video ! But where can I find the entire code of the very useful "PrintBinary" void that you use in your video ??

    • @elodiecemoi3057
      @elodiecemoi3057 4 ปีที่แล้ว

      Sorry, I just see that you have given the URL: www.phanderson.com/arduino/arduino_display.html

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

      Cool, glad you found it.

    • @FERNANDO050694
      @FERNANDO050694 4 ปีที่แล้ว

      MULTIPLEXER DISPLAY 7 SEGMENTS (COMMON ANODE OR COMMON CATODE) - ARDUINO - PCF8574 REMOTE 8 BIT I/O EXPANDER FOR I2C BUS
      th-cam.com/video/ENlRaSL34h0/w-d-xo.html

  • @MrHenryrolls
    @MrHenryrolls 5 ปีที่แล้ว

    Ralph, you're a superb teacher. I'm just sorry that a video as useful and constructive as this gets 1/1000th the number of views (and therefore income) as something as dumb as EXPERIMENT Glowing 1000 Degree Ball vs Iphone

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

      Thank you for your kind words, MrHenyRolls, and I agree with you wholeheartedly! I may have to pursue the social media route to get my videos noticed by more people. Nice to hear from you.

  • @JohnPaul-my6ct
    @JohnPaul-my6ct 4 ปีที่แล้ว

    Hi Ralph - Did you actually try the example you put up on Github? It is so confusing when Guys such as yourself put up examples that don't work. I spent ages trying to find where my error was only to see that the I2C address was wrong in all the examples I used in your case it was wrong 3 times! However when all is said and done I learnt a heck of a lot from your tutorial sample thank you.

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

      I'm, glad it all worked out in the end, John. The sketch in my GitHub is the sketch you see in the video. So, yes, fully tested. What went "wrong" for you is that your PCF8574 device had a different I2C address to mine - whether configured by the manufacturer or by design, I don't know. That's why it's always important, when dealing with I2C devices, to run the I2C Scanner sketch _first_ which will confirm connectivity _and_ tell you its address. I've uploaded it many times but on this occasion I did not, so maybe you did not realise this was a useful step (a bit late now, I hear you cry). But you obviously found the correct address somehow, so good job! And in future I will always have to mention the I2C scanner so others do not get caught out like this. Thanks for your feedback, John, appreciated.

    • @JohnPaul-my6ct
      @JohnPaul-my6ct 4 ปีที่แล้ว +1

      @@RalphBacon Thanks a million for the reply and the tutorial. All's well that ends well.
      Regards
      John

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

    Hi Mr. Ralph,
    I went to a weird problem with PCF8574P (not with SOP16 AT chip) chip connected with an ESP8266-01S. as following:
    The blinking on PCF8574P was done successfully but the ESP seemed to halt for about 10 seconds at some 3 times of blinking a led connected to any pin of the PCF8574P and ESP resumed working again.
    However, when I connect ESP to a PCF8574AT (SOP 16), this thing does not happen. However, when I tried connecting both PCF version (P and AT) with Arduino, such weird thing does not happen. I thought ESP does not like P version. Do you have any advice?
    Thanks.
    P/S: The setup of the I2C connection was the same for both PCF version (with 1K pull up resistors on SDA and SCL)

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

      Make sure you have only ONE set of I2C pullup resistors (some manufacturers add them to each board).
      The ESP01 is a 3v3 device; try running the Arduino at 3v3 to see whether you get the same odd results.
      Maybe some of your PCF8574 chips are borderline and do not work well at 3v3 (or are fakes?!) - try another module to see whether you always get the same strange result when using an ESP8266.

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

      @@RalphBacon Thanks for your response, I re-tested in following scenarios:
      1. Mount bare chip PCF8574AT with 2 1K pull up >> working fine with ESP-01S;
      2. Mount port expander (pcf8574AT), no pullup >> working fine also;
      3. Mount bare chip PCF8574P with arduino (3.3V, A4, A5 pin, pull up resistors 1K) >> working fine;
      4. Failed connecting PCF8574P with ESP01-S.
      So I doubt ESP-01S has problem connecting with PCF8574P.

  • @biopoweruk
    @biopoweruk 6 ปีที่แล้ว

    Hi Ralph, I am planning to use an Arduino to control the stops and tabs on a large virtual pipe organ console which will have to sense the binary status of about 250 stops and send about 96 binary signals to solenoids that operate the stops. Can the pcf8574 be chained to read so many channels - or is there another way?

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

      How are the 'binary signals' of the organ stops arrange, biopoweruk? You might be able to make a matrix up if you have access to both 'sides' of the switches. That would reduce the number of ports you need. Let me know...

    • @biopoweruk
      @biopoweruk 6 ปีที่แล้ว

      Each stop knob or stop tab is either 'on' or 'off' and can be switched individually by hand. But they can also be switched by combination settings using small buttons placed between they keyboards. This is done by 12v solenoids on each stop know unit or stop tab unit. I have collected all the parts on Ebay. The whole console is used as a midi sender so the organ sounds are created by computer using the Hauptwerk program from accurate recordings of historic organs from all over the world. I expect to use relay cards to switch the high current taken by the solenoids.

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

      OK, I'm assuming that you have access to both terminals of the stop switches (that is, they are not already connected together with a common ground, for example). By arranging the stop switches in a matrix (rows and columns) you can reduce the number of pins you need to *read* them. If you watch video #13 it describes in some detail how a matrix to read keys is constructed. You could then experiment with one like I used in the demo (pretending each key was an organ stop key) or construct a proof-of-concept using a dozen cheap, push button switches just to get the design right. Now...
      Now, sending the 96 signals is another matter. You can reduce the number of solenoids (you really have 96 relays for this?) by 'charlieplexing' the outputs but it gets complicated all too easily and you can't turn more than one on at any one time. So an alternative could be an Arduino Mega 2560 has which has 51 GPIO pins (not including the RX/TX pair you need to program it via USB) plus it has 16 Analog input pins that can also be used as digital output pins (pin 54 to pin 69).
      But even using a Mega 2560 you will run out of pins almost immediately so using multiple 8574s may be the only way. Note that there are two versions. The PCF8574 has an I2C address range of 0x20 to 0x27, whereas the PCF8574A has an address range of 0x38 to 0x3F). So you can use a maximum of eight of the same type on the I2C bus. That's 16 devices in total, with 8 ports per device = 128 pins in total. Wow!
      I'd certainly start small and work my way up, to ensure it was all going OK. You may like to run this past the gurus at the Arduino forum, forum.arduino.cc to see if they know of a better (=simpler) way of doing this but good luck anyway.

  • @gearhart0steve
    @gearhart0steve 7 ปีที่แล้ว

    Great explanation! I'm so glad you showed me this nifty little module. Here is the thing though, I'm using a compass that uses i2c on my Mega. I am also using a photo interrupter, attached to an interrupt on the Mega, and I have a sample code that counts the ticks of slotted disk on the shaft of a motor. Problem is, when I include the compass code, the interrupt is called sporadically. If I comment out the compass code, the interrupt counts well. Is there a conflict with I2c and interrupt pins ok the mega, I'm using pin 2, and if so, would this module solve my issue? any feedback would be greatly appreciated. I've subbed and will be checking out more of your stuff! thank you.

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

      +Steven Gearhart
      Hi Steven, an interesting question.
      I2C most certainly uses dedicated interrupts behind the scenes so there may be a 'conflict' inasmuch that your own interrupt service routines (ISRs) are not the lightning fast pieces of code they need to be. An ISR should do no more than set a flag or increment a (volatile) count variable. That's it. No Serial.prints or other bits of code - that's the job of the main loop, outside of the ISR. Whilst servicing an interrupt all other servicing of further interrupts is stopped. When an ISR has finished then other interrupts may be pending in which case they will to be serviced.
      Best advice would be to make your ISRs super squeaky clean and slim and see if you still get missed interrupts. As an aside, the arduino forum (forum.arduino.cc/index.php) is excellent as solving issues like this and I highly recommend you joining (for free) and seeing if they can help too (they have much more time than I do!). Just present your problem succinctly with your code formatted they way they like it and describe all the steps you have taken to resolve the problem so far (they like to see you have tried stuff already). You may see me lurking in the shadows answering a few queries when I get a nanosecond of free time too!
      Good luck and thank you so much for an interesting question and subscribing!

    • @gearhart0steve
      @gearhart0steve 7 ปีที่แล้ว

      Thanks for the reply! My ISR is squeaky clean. Just toggling a variable. The main loop () is handling the HMC8553L compass. that is where the issue lies. If I comment that section out, the ISR toggles the variable perfectly. It's an adafruit library so i doubt the issue is there. I just wonder if using i2c and an interrupt on pin 2 is a conflict. I'll try the forums out when I get the time. Thanks again and keep up the great work!

  • @markvisser3598
    @markvisser3598 5 ปีที่แล้ว

    Hy,
    I can’t gate it to work. I coped you first code but it will not work.
    I use a arduino Mega, whit a PCF8574AN with A0=A1=A2=0 so my command should probable be 0x020 or 0x027 (I tried them all but they all don’t work). I have my SDA in port 20 and SCL in port 21. Where could it have go wrong?

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

      The first thing to do is to make sure your I2C is set up correctly and that it can find the PCF8574 device. Use the following sketch to do that:
      www.dropbox.com/s/o4qekrwkps017xm/I2C_HEX_ADDRESS_SCANNER.ino?dl=0

  • @wotesi
    @wotesi 5 ปีที่แล้ว

    Great video, Ralph! Thank you. Can you write here as an example what world be the code to read from e.g. PIN No.6 a variable that is of float type, say reading from temperature sensor?
    Thank you!
    Br,
    Valters.

    • @wotesi
      @wotesi 5 ปีที่แล้ว

      Hi, Ralph! I believe I yesterday found answer to my question - I cannot forward analog signals (e.g. those of float type) by using PCF8574, only digital (HIGH, LOW). Now let me ask different question - how to increase (get more, extend) analog signals in Arduino?
      Thanks!
      BR,
      Valters.

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

      Analog expansion boards are available but read this first, Valters, it may help:
      arduino.stackexchange.com/questions/21536/expanding-analog-inputs-to-the-arduino
      Alternatively, the Mega2560 has 16 analog inputs (and you can get the board in a more compact shape too, see my video #108)

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

    Thank you

  • @peachville4383
    @peachville4383 5 ปีที่แล้ว

    Thanks for sharing :)
    If you want to use Arduino Nano: change the "Wire.beginTransmission(0x027);" to (0x020).
    For additional PCF8574 modules: (0x021); 0x022) etc. and and also move the jumpers accordingly. eg: for 0x21 move just the outside jumper to the left and for 0x22 move just the middle jumper to the left. This way you can access 24 GPIO pins sequentially.
    These are great for adding output pins. For additional input pins, where only one will be used at a time, I use 6 different resistors off each analog pin to create 36 inputs. This uses only the 1st 6 analog pins (A0 to A5). ....I never trust A6 and A7 :(

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

      And thank you for the information, Peachville. But I'm not sure why you don't trust A6 and A7 (which can ONLY be used as analog inputs, not digital GPIO pins) but are otherwise quite standard?

    • @peachville4383
      @peachville4383 5 ปีที่แล้ว

      @@RalphBacon I'm not the only one that avoids A6 & A7 on Nano. Do a google search. At 1st I thought this was just a bad Nano but it wasn't. Datasheets even say that the first analogue reading is unreliable....this may have something to do with it. An analogRead of A6 sometimes seems to leak voltage to A7 when doing sequential reads. I'm not even close to an expert on 'why' and don't have the time, so I just avoid using them this way. :)

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

      Interesting, and I was not aware of this (alleged) deficiency on those pins, I shall bear that in mind, thanks for sharing.

  • @joeblow2109
    @joeblow2109 6 ปีที่แล้ว

    Dope....... I guess you would need some sort of encoder on the output pins to change when the DIPs change :( or maybe some more transistor switching or maybe a simple switching Chip.

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

      See my previous reply!

  • @ScR-jb7th
    @ScR-jb7th 5 ปีที่แล้ว

    Hi Ralph, Great channel, I have watched several of your videos and find them really informative, so much so that I have just subscribed and pressed that bell. I have a very simple question that I probably should know the answer to but I need some reassurance before I start blowing stuff up. My proposed project uses a lcd touch screen that uses the majority of pins on my Uno, I do have the two I2C pins near the reset button free, so, can I use the PCF8574 board to control a 8 Relay Module, it is the polarity reversal thing that is confusing me...

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

      Welcome to the Arduinite world, ScR, and thanks for subbing. Appreciated.
      I'm not totally sure what you mean by "polarity reversal" (it's been a while since I made this video) but let's see what I can suggest.
      When you say the LCD screen uses most pins up, you still have the Analog pins A0 thru A5 that you can use as digital pins in the usual manner. That gives you 6 pins, so if you have another two (not the SCL/SDA as they are already in use as A4/A5) you would be able to control the relay board directly (and more simply).
      That said, I see no reason why the relays could not be controlled via I2C and a PCF8574. As your relay board will be undoubtedly optoisolated (right?) all the PCF8574 is driving is an LED (well, eight of them)! Simple to do, but not as simple as my first suggestion.
      Finally, if you really are scrabbling around for pins, watch my video #108 which shows a more compact (and cheap) MEGA2560 which has more pins than you can throw a stick at and costs just £7.52 or just over $9 - a very easy way to increase your pin count whilst keeping everything else 100% Arduino UNO compatible!
      As Albert Einstein said, "Make things as simple as possible - but no simpler!"

    • @ScR-jb7th
      @ScR-jb7th 5 ปีที่แล้ว

      @@RalphBacon Thanks for your reply, and so quickly, I know that I could take Einstein's advice, he is one of my personal icons, although to quote JFK (not an icon) we do things "not because they are easy, but because they are hard". That aside, I muck about with arduinos quite a lot, I usually build projects on the bench with an Uno, or Mega for more options, then I mostly transfer my project to a Nano or a Pro-Mini. I was raking through my Arduino bits box and found a spare Uno, a 8 way relay module and a mcufriend TFT LCD touch screen that I have had for years and have never used it because it is a pin hog. On the Uno, the screen uses all the pins from the Reset to A5 on the analoge side and pin 0 to AREF on the digital side. It does leave (I2C) SCL and (I2C) SDA free, I believe these are the two pins that the PCF8574 needs. All I would need to buy is a PCF8574 module which is considerably cheaper than a new Mega. Anyway, the relay board works as you guessed, it is optoisolated so I am just turning on and off LEDs. My polarity reversal confusion is; my relay board requires a pin to be high (5v+) to operate, easy to do straight from an Arduino as you have drawn in the video at 4:53, Its was the reverse logic bit that made me think that the PCF8574, would be taking pins low (0v)to operate, your drawing at 5:17 sort of confirmed my fears. But after reading your reply and re-watching your video, I think that I now understand where I was going wrong. It was late last night when I watched the video, that's my excuse anyway, you were talking about the input side to the PCF8574, I picked up that you were talking about the output side. I now take it that regardless of the input side, the PCF8574 can drive it's output pins high or low (depending on the sketch), therefore I can turn relays on and off easily with my touchscreen?
      Steve.

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

      Yes, you are correct; the PCF8574 can drive its outputs high or low, just the same as an Arduino would do.
      Having read your descriptive post above though, and the fact that the TFT Touch Screen is such a pin hog, have you considered off-loading that part of the project to a dedicated Arduino Nano? You can get these for about $2.29 from the Far East (eg Banggood, GearBest and AliExpress to name a few). Then use I2C to communicate with it from your main UNO. Or even the serial bus (hardware or SoftSerial).
      Example Nano:
      www.banggood.com/ATmega328P-Nano-V3-Controller-Board-Compatible-Arduino-p-940937.html?p=FQ040729393382015118&
      This might be a more elegant solution and attacks the root cause of the "problem" rather than trying to work around it. The choice is, of course, yours, either solution would work.

    • @ScR-jb7th
      @ScR-jb7th 5 ปีที่แล้ว

      @@RalphBacon I have been watching a few other videos on the PCF8574 and I found one guy who managed to get his screen working through two of them. But I have ordered a couple of PCF8574s to play with, we'll see how I get on.....

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

      Good luck. It's all part of the "fun" Arduinite journey!

  • @omsingharjit
    @omsingharjit 4 ปีที่แล้ว

    M using AliExpress in golden period , i i started my account just few months back . And i noticed that its services are much faster than what people claims.

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

      Sometimes they get delivered quickly, sometimes slowly, very, very slowly!

  • @renjiabarai6196
    @renjiabarai6196 6 ปีที่แล้ว

    Is PCF8574 can handle/controll the sensor like DHT11/22, DS18B20 or other sensor ?

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

      Interesting question, Renji. So far I've just read the state values (or set the values) of an *individual* pin (or a collection of pins) on the PCF8574 but I've not tried it with a sensor which is queried like this. Perhaps others have had experience of this and might chip in but I've added your question to my ever growing list and it may get answered in due course. If you find the answer do please post back here! Sorry I can't be of more help right away

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

      you got the answer ?

  • @omsingharjit
    @omsingharjit 4 ปีที่แล้ว

    Can't use this module to drive 16x2 lcd instead of using its officially made i2c module that are mad3 officially for 16 0in lcd ??

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

      This is the same device as used in the "backpack" modules to turn a standard 16x2 or 20x4 LCDS into an I2C device.

    • @omsingharjit
      @omsingharjit 4 ปีที่แล้ว

      @@RalphBacon yeah , I checked that it is same ic . But on the board there is 3 pairs of unsoldered smd pads marks as add A0 A1 A2 which all are open how it works without any address A switching connections 🤔

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

      Those pads determine the I2C address of the device. Usually they are left unsoldered but by soldering any combination you change the address (used to avoid I2C address conflicts). The datasheet will help you if you need to do this. Use the "I2C Scanner" program to see the address of your device.

  • @AasimAlmuhandis
    @AasimAlmuhandis 7 ปีที่แล้ว

    hey great video, can I know what compiler are you using to program the arduino?

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

      +Aasim Almuhandis
      Sure, I use the Eclipse programming IDE which is not for the fainthearted. If you are a professional developer or are comfortable with Microsoft Visual Studio then this is great otherwise stick with something less challenging is my advice! So:
      Details:
      Eclipse IDE for Arduino Developers
      Info: eclipse.baeyens.it/
      Source: github.com/jantje/arduino-eclipse-plugin
      That last link is for the Arduino development. It took me two attempts and about 3 hours to get it installed the way I wanted it to be. Google is your best friend to find installation instructions (but that last link also gives you that).

    • @stewartrv
      @stewartrv 7 ปีที่แล้ว

      What plugin or whatever are you using? As far as I know Eclipse doesn't do Arduino "out of the box" so to speak...
      (I'm guessing this one: Sloeber?)

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

      Hello stewartrv, you're right, Eclipse doesn't do Arduino but the clever chaps on this Github repository have written this plugin which works very nicely: github.com/jantje/arduino-eclipse-plugin
      You get a very occasional nag to subscribe $1 a month and as soon as I earn any money out of this channel I will feel duty bound to do that; until then though, and for most casual users, it's a purely personal choice :)
      Installing Eclipse may take you a couple of goes and some hours but I find it very nice. However, there's another, simpler IDE called Sublime Text Editor (also with an Arduino plugin) and I've done a video on how to install that (it will be released in the next couple of weeks or so), so if Eclipse is a bit daunting wait for that video. If you subscribe to my channel you'll be notified when it's released too!

  • @brunovilledieux8669
    @brunovilledieux8669 5 ปีที่แล้ว

    high Ralph and thank you for this great video (even a french noobs like me can follow).
    I have a question: i'm trying to emulate tri state io on this PCF8574 to control the microstepping mode of tmc2100 stepstick
    On the arduino (alone) i can do that by setting the pin to output high for 5v,output low for ground and input for open.
    but in your video you say that an input is set by putting it off(high)...so if i get it right it means that open and off are the same behavour right?
    so is it possible to emulate a tri-state io with it?
    thanks again and excuse my poor english

    • @brunovilledieux8669
      @brunovilledieux8669 5 ปีที่แล้ว

      sorry Hi not high Ralph... i think i'v spent to much time with my nano ;)

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

      Bonjour, noob français, et bienvenue sur ma chaîne!
      I'm not sure you can emulate a tri-state really, Bruno. The GPIO pin is either LOW, HIGH or _floating_ which, as its name implies, means that it might be LOW for a bit, then HIGH and generally oscillates around. (That's why it's important to use either grounding resistors on INPUT pins or open them as INPUT_PULLUP.) But a floating pin might not be the same as a pin with high impedance as it will have a voltage (albeit tiny) at that pin.
      What value on the pin do you expect to see in a tri-state mode? Just a high impedance, with no regard to actual voltage? How does your circuit differentiate between a floating pin and another state?

    • @brunovilledieux8669
      @brunovilledieux8669 5 ปีที่แล้ว

      hi @@RalphBacon and thanks for the quick reply
      "What value on the pin do you expect to see in a tri-state mode? Just a high impedance, with no regard to actual voltage?"
      yes i guess for the open state
      "How does your circuit differentiate between a floating pin and another state?"
      i have no idea ,when i hook the 2 config pin of the tmc2100 straight to the nano it work great
      here is a link where i post my code: forum.arduino.cc/index.php?topic=537240.0 it only use pin mode and digital write low and high
      during the night i was looking for a way around and found this io expander :de.aliexpress.com/item/I2C-8-bit-I-O-expander-module-PCA8574AD/32588650413.html
      it use a PCA8574 and if i get it right it have separate setup for input and output do you think it will do the trick?

    • @brunovilledieux8669
      @brunovilledieux8669 5 ปีที่แล้ว

      actually it s PCA9554N

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

      In cases like this, a bit of research and development is always required. I do this all day long! Sometimes things work just as you expect, sometimes not.
      As long as the result you get is *repeatable* then you have a solution. From what you tell me above you seem to have a (part) solution. Now you can try the PCA955N to see if that completes your project, it's what I would do. Good luck!

  • @MultiRdh
    @MultiRdh 6 ปีที่แล้ว

    Can you please make tutorial for wifi home automation with MIT APP INVENTOR with data save in I2C eeprom??

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

      Now then Syed, you're in luck. I've already covered the MIT APP INVENTOR in videos #36 and #37 which shows you how to control your Arduino via your smartphone using Bluetooth. In fact, it's a two-way communication with the Arduino sending back information to your phone too. You could easily adapt this to use Ethernet by watching video #75.
      And the basics of writing to EEPROM was covered in video #65. Wow! It's certainly your lucky day, so good luck with your project.

  • @pikadroo
    @pikadroo 7 ปีที่แล้ว

    So does this only work with the damn backpacks now? I can't seem to get the PCF8574P to work like it used to.

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

      +pikadoo
      Not really understanding your question here! Sure these pin extenders are used as backpacks for the LCD boards but that is just one application for them (and very useful too). But there's been no change in the behaviour of the PCF8574 as far as I know. What problems you getting?

    • @pikadroo
      @pikadroo 7 ปีที่แล้ว

      I have a PCF8574P and yesterday I had a hell of a time getting it going. It's working now, but my problem was the lack up dated information on the Arduino site. It's almost impossible for me as a consumer to keep track of every development in Arduino as it is, but when they have broken links and libraries laying about the web it becomes impossible to get anything done.

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

      I feel your pain! Even though I only do this channel as a hobby it takes all my time to just scrape the surface of what is out there. It would be a full-time job to actually keep abreast of what is happening in the microcontroller world, let alone discovering new libraries and discarding old links. Hopefully, this channel helps that tiny bit in keeping you up-to-date in what is happening!

  • @scorpion1982a
    @scorpion1982a 5 ปีที่แล้ว +1

    Hello
    What is this IDE editor for Arduino?
    Thank you

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

      It's the Eclipse editor, Sloeber edition, tricky to set up and use but have a go.

    • @scorpion1982a
      @scorpion1982a 5 ปีที่แล้ว

      Ralph S Bacon Thanks, I thought. Much nicer than this factory stuff.

  • @JoeEvansSound
    @JoeEvansSound 5 ปีที่แล้ว

    Hi Ralph - me again, hope you are well. Can you tell me please is there a way to do a digitalRead on a I2C pin? I am writing to the pins but i also want to read from them too. Thanx v m.

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

      From what I recall about reading value, PJ, you must connect the interrupt pin from this device to your Arduino. This gets set HIGH when something changes on the PCF8574 (eg a switch closes). Unfortunately it doesn't tell you _which_ pin just went low (or high) you must read each in turn to determine that by knowing the last (previous) state and recognising that it has now changed. Not too onerous if you right a small function to do this. Any help?

    • @JoeEvansSound
      @JoeEvansSound 5 ปีที่แล้ว +1

      @@RalphBacon Mmmmmm interesting!. OK I have gone further into this and I am now getting interesting results. I am actually getting a decimal number returned, reflecting (I am sure) the state of the 8 pins in decimal rather than binary. I am now going to research how to test each bit of a binary number and then (I hope) I will be able to see which LED is on. Curious and curiouser!! Thanx Ralph - nice chatting :¬)
      ------------
      Edit
      I have now sussed out how to read each pin from an i2c expander. I have a few lines of code with magic binary masking in it (cribbed from others). Easy when you know how ! Ha ha ha.

  • @jonelectronics510
    @jonelectronics510 4 ปีที่แล้ว +1

    Hi Ralph. Great little video but I am not too sure your reading of the data sheet was correct. The load circuits I thought are showing their effective test rig that they used to get the values in the datasheet and warning against parasitic values. The INT pin can be held up with a 10k resistor, it's doesn't have to be their 4.7k. If you look at the top of the datasheet the give you an example circuit with their recommended hold ups. The capacitors I thought are there to warn that the values stated on the datasheet are only guaranteed, for example, that you have less than between 10-400pf parasitic capactiance on that pin (from PCB trace capacitance etc.) It is not suggesting you include the capacitor. If you operate outside that the switching times may be too slow, for example, and it will break the datasheet guideline.
    Equally, you would not include the caps on the I2C bus either which they have shown with the 1k resistor. You would start with 10k and then adjust for the switching speed inline with the I2C standard. Let me know your thoughts.

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

      You are doubtless correct, Jon, but as it's been a while (and then some) since I did this video I can't recall the details. I've bookmarked your answer so I can re-read the datasheet in a quite moment. August is looking good. 2022, that is!

    • @FERNANDO050694
      @FERNANDO050694 4 ปีที่แล้ว

      MULTIPLEXER DISPLAY 7 SEGMENTS (COMMON ANODE OR COMMON CATODE) - ARDUINO - PCF8574 REMOTE 8 BIT I/O EXPANDER FOR I2C BUS
      th-cam.com/video/ENlRaSL34h0/w-d-xo.html

  • @michaelbowman4919
    @michaelbowman4919 7 ปีที่แล้ว

    grate tutorial. But. How do you change 1 bit and not efect any other pins. bit masking? Have you got an example?

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

      Hi Michael! You're the first person to ask this question, even though at the time of putting the video together I thought more people would ask it! I deliberately did not mention it because, as you summised, bit masking (any bit manipulation) makes beginners think they can't possibly do it. Wrong!
      In my example sketch, I tentatively did a tiny bit of bit manipulation to determine the state of a single pin:
      status = (abc & 0b100000000)
      where abc is the 8-bit value received from the Wire.read() command immediately preceding this statement.
      So from that, you can see (as I think you already have) that when writing back a value for a different pin, just do bit masking on that value.
      ---------------
      Example:
      ---------------
      (Note that 1 = LOW and 0 = HIGH here, as the pin extender sinks current not supply it).
      We read back value 0b1111110 into variable 'abc', which means only the rightmost, least significant P0 bit is set.
      But now we want to set the second bit from the right (P1) as well as what was already there. I would first NOT the value we read (to get it into human understandable 1=HIGH 0=LOW format) so it now becomes 0b00000001. Easy to see that P0 is HIGH now.
      Now, OR the value with what we want, 0b00000010 (where 0 means leave as is) giving 0b00000011. Easy to see that both the last bits, P0 and P1 are HIGH.
      Finally, NOT that into the required 0b11111100 and write that back down the I2C route. Then both the P0 and P1 bits would be set (at this point 0=HIGH and 1=LOW again).
      Frankly this can be confusing for beginners (which you're obviously not because you asked the question and know about bit masking). It's unfortunate that the pin extender works 'in reverse' with the HIGH and LOW as it means we must use NOT (the ~ symbol on your keyboard in C++) before we write anything to the chip.
      Anyway, I hope this has helped you (and possibly others who may have thought of the question but never asked!).

    • @michaelbowman4919
      @michaelbowman4919 7 ปีที่แล้ว

      Thank you for the reply. I have been smacking my head against the wall on this. From what I have been reading I know I need to to do but cannot understand or nor can I get this to work. My project requires me to address each new pin individuality. Is there a chance in the future that you may do part 2 video? "I" a video on bit-wise operations?. Keep up the the grate work..

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

      Funnily enough I have on my list a project to use that pin extender with a Tiny85 so maybe that's the time to include the bit masking. As I've said in other posts on my channel, don't expect an immediate video as they can take some time from having an idea to producing the final video, but is sounds as though you and others will benefit. In the meantime, I hope you enjoy the other videos in my Beginners playlist and thanks again for bringing up this topic.

  • @johnmarshall2660
    @johnmarshall2660 3 ปีที่แล้ว

    I am trying to use the PCF8574 and Uno as a toggle for 8 switches and output to 8 LED's / operate a Relay or Mosfet etc but I have 2 PCF8574 first is switches and second is LED's and would also like to extend to 16 switches but having problems with sketch .. got working up to switch 1 to 5 but 6, 7, 8 no function ... so would love if you could do a video on this project... Regards John

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

      How odd. If your sketch works with the first 5 inputs why would it not work with the remainder? [Puzzled face]. Sure your code/wiring is triple checked?

    • @johnmarshall2660
      @johnmarshall2660 3 ปีที่แล้ว

      @@RalphBacon We been through that possibility regarding wiring but the circuit is so simple ... been trying another sketch from a member of MERG but the same ... the original sketch is as I said but if you press say button 1 then immediatle after press 6, or 7, or 8, they work so cant be wiring ... so basics 4 wires from Uno I2C and 5v and Gnd to 1st PCF8574 the second one is plugged in at rear of module jumpers set ... 8 ribbon leads from 1st 8574 to breadboard switches ... 8 ribbon leads from 2nd 8574 to LEDs then a 330 ohm to VCC ..even posted on Arduino Forum and they are stumped ... its the most simple circuit I have ever put together ...

    • @johnmarshall2660
      @johnmarshall2660 3 ปีที่แล้ว

      Hi Ralph ... the error was in the IoAbstraction.h and IoAbstractionWire.h library ... sorted and sketch was up loaded to github.com/MERG-DEV ... 16 buttons ..

  • @joeblow2109
    @joeblow2109 6 ปีที่แล้ว

    Hi Ralph, l like to make things more complicated...... how about adding 3 transistors to those DIP switchs and connect them to 3 I/O pins on the UNO and go crazy with coding :-) 128 I/Os from three.
    cheers

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

      You can add up to 8 of these devices onto the I2C bus, Joe, no need for DIPs or anything. Just give each device a unique address (by soldering one or more of the pads marked A0, A1, A2) and you're good to go.

  • @aniketsawant8498
    @aniketsawant8498 3 ปีที่แล้ว

    What is the wattage of 4.7k resistance?

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

      Small, 1/4W should suffice, but you can use larger if you want.

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

    is there a way to stack them?

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

      Yes, I believe you can daisy-chain these to a depth of 8. Just use the correct I2C address for each device.

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

    Hi Ralph
    Thanks for yet another great video - Easy to understand, easy to use. In fact I advise some of my students to see and use your videos - Hope that's OK? :)
    Have you tried to hook up - say 4 modules and do read and write routines to them? I'm looking for an easy scan and write routine, that easy sets up and reads data on multiple I/O expanders - maybe I got to the right person? :)
    BR
    Tomas

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

      Well, Thomas, the PCF8574 has an INT output that is designed to be connected to an interrupt _input_ on your Arduino, for example. This highlights the fact, to the Arduino, that one of the pins has changed on the PCF8574. Then just scan (read) each pin in turn and discover which pin it was (by keeping track of what each pin's status was in your Arduino sketch). As they are all I2C you can connect up to four units (that's all your addresses used up for these modules). Reading the pins from each module is the same as reading from one, using a different address. I'm guessing you already know how to do this! I don't have any easy scan and write routines of my own but from what I've described I think its clear what needs to be done?

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

      Hi Ralph
      That sounds somewhat like I intended to do. I would OR the INT signals together and attach the output to the Arduino INT pin. Then wire the PCF8574 INT pins to normal input pins on the Arduino, which I would have the Arduino scan to discover which PCF8574 did the interrupt - and finally scan this module.

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

      Yes, something like that. Just connecting a diode in series with each module's INT pin to the Arduino's INT pin should be enough to trigger the Arduino.

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

      Yes, then you OR with the diodes. But a diode generates a voltage drop up to about 1V. Normally it goes ok, but when it has to trigger an interrupt, using logic gates would be advisable :)
      There is some good explanation done here: sites.google.com/site/qeewiki/books/avr-guide/external-interrupts-on-the-atmega328

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

      Use a Schottky diode, Tomas. Wikipedia says "...Schottky diodes' voltage drop at forward biases of around 1 mA is in the range of 0.15 V to 0.46 V (see the 1N5817 and 1N5711)..." That may help you.

  • @BasselIssa
    @BasselIssa 7 ปีที่แล้ว

    do you think that i can use the LCD driver showing here www.instructables.com/id/Using-PCF8574-backpacks-with-LCD-modules-and-Ardui/ ?

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

      Hi Bassel! Now although you might 'get away' with using that pin extender with the LCD you link to, what you really need is one that has a built in contrast control - I just bought 10 of them here: www.aliexpress.com/item/5-pcs-IIC-I2C-Interface-LCD1602-Adapter-Plate-for-Arduino/1698225308.html for less than £4 ($5) but individually they are about $1 or in the UK about £2.20 singly. I've used one and it works exactly as expected. I hope this helps and thanks for posting a great question.

    • @BasselIssa
      @BasselIssa 7 ปีที่แล้ว +1

      This is exactly the one i have, got it here with 3$ in Dubai. worth not to wait AliExpress as it takes 35 days to get delivered. I will give it a try according to your nice video. will let you know if it gets work Thanks a lot Ralph for answering

  • @starcitizenmodding4436
    @starcitizenmodding4436 5 ปีที่แล้ว

    "Three squared minus one" i didn't know thats how it worked. That can apply to any number?

    • @starcitizenmodding4436
      @starcitizenmodding4436 5 ปีที่แล้ว

      2:22

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

      Actually, as this a two-way switch we can treat it as a binary bit. The maximum permutations for a binary number is 2^n where n is the number of bits. Here we have 2^3 which is 8. If we had 8 switches (and hence bits) it would be 2^8 which is 256. Any help?

  • @Hyp3rSp8c3
    @Hyp3rSp8c3 6 ปีที่แล้ว

    Can I use this with an attiny 85 without changing the code?

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

      Good question. The short answer is: Probably not. If you look at video #82 it concentrates on getting I2C working on an ATTiny85 - then yes, you can use this pin extender in the same way. It's pretty straightforward in getting I2C running on the Tiny85 as the demo shows, so don't be put off that you might have to change a few lines of code!

    • @Hyp3rSp8c3
      @Hyp3rSp8c3 6 ปีที่แล้ว

      Ralph S Bacon , thank you. I appreciate the help. I will check that video out.

  • @MTSChannel
    @MTSChannel 5 ปีที่แล้ว

    Please give the sample for nodemcu v3 and pcf8575ST, i am beginner. Thank you

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

      I'm afraid I didn't use a NodeMCU for this device - Google may be your best friend in this instance!

  • @konstantinosdamaskos4138
    @konstantinosdamaskos4138 3 ปีที่แล้ว

    Hello, can i control pins with IO expander at the same time?

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

      Do you mean turn on/off multiple pins at the same time,as you can on the Arduino if you address the register? Yes, you can by setting the correct bit values in the byte you send to the device telling it which pins are high and low.

    • @konstantinosdamaskos4138
      @konstantinosdamaskos4138 3 ปีที่แล้ว +1

      @@RalphBacon Thank you very much!!

    • @andrasparanici5491
      @andrasparanici5491 3 ปีที่แล้ว

      @@konstantinosdamaskos4138 It's like I came for this question. Thanks!

    • @andrasparanici5491
      @andrasparanici5491 3 ปีที่แล้ว

      @@RalphBacon This is the answer I was looking for!

  • @LuberthDijkman
    @LuberthDijkman 5 ปีที่แล้ว

    Curious if it could be used on marlin 3d printer
    84.106.2.21:8888/forum/index.php?action=view&id=285

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

      That depends on how the original detector was implemented, Luberth, (if there was one), was it GPIO or I2C based? In its simplest form think of this as a simple on/off switch - could that be used? If so, wire this up to a transistor as per my diagram and it should work.

  • @mikelanham7953
    @mikelanham7953 6 ปีที่แล้ว

    Blinking LEDs works, but how do I use the pin extender with an SPI device, for example ssd1306, OLED. I am attempting to display data from an ESP266-01, on ssd1306 through the PCD8574.

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

      Hmm, tricky one Mike, as this pin expander is I2C, not SPI. However, others like the PCA9502, are an 8-bit I/O expander with I2C-bus *and* SPI interface (see here: www.nxp.com/docs/en/data-sheet/PCA9502.pdf). I don't think I've used one of these but if you know how to connect SPI then I don't see why this would not be a possible solution for you.

    • @mikelanham7953
      @mikelanham7953 6 ปีที่แล้ว

      Sorry, but I don't understand. I want to use fewer pins to connect my SPI OLED to the ESP266-01. The ESP has only a few GPIOs. The port expander takes inputs and produces I2C output that use fewer pins. Correct? I need I2C connection to the ESP266-01 to use this OLED. I am doing this to learn how to use the port expander, LEDs are well and good, but what other devices can be used? Can you give an example? Thank you for the tutorial.

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

      You need to investigate whether the chip I mentioned (PCA9502) allows you to connect your ESP via I2C (two pins) then connect your OLED to the PCA9502 via SPI. Basically, whether both busses can be used simultaneously. But SPI only needs 3 pins (MOSI, MISO, SCLK) plus a CS pin for each device, is this too much for your project?

    • @mikelanham7953
      @mikelanham7953 6 ปีที่แล้ว

      Thank you, as you probably know the ESP has 4 GPIOs, when the RX and TX are used as GPIOs. So, I suspect it is possible to get data plus connect the OLED. I am just not sure how to do it, which is why I watched your tutorial. I am surprised the the PCF8574 will not work. What can it be used for. I bought 10; what can I used them for? Blinking LEDs works, what is the next step? For example, how do you wire-up sensors?

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

      You can connect anything up that needs to be switched on/off, or something that needs to send back a signal (high/low), like a switch or push button. The pin extender facilitates the latter by triggering an interrupt which the Arduino can then detect (so it doesn't have to keep polling the I2C bus to see if something has changed). So...
      So you could connect up any number of relay driven motors, lights and even control the MP3 module I describe in video #40. You can also wire up loads of switches or rotary encoders to send back signals to the Arduino. You should view the P0 to P7 pins on the pin extender as extensions of the standard GPIO pins on the Arduino - except they don't use up the pins already there.
      By the way, as you have so many of these chips you can use up to 8 of them on the same I2C bus; just choose a unique address by shorting the A0, A1 or A2 pins (different combination for each chip) then you will have 64 pins to play with. See here for more details: www.ti.com/lit/ml/scyb031/scyb031.pdf
      And finally, you do seem to have made life difficult for yourself by using an ESP8266-01. Whilst physically small, it also severely limited in the IO pins it has available as you have discovered. Why not use a 'proper' ESP8266 board like the ESPDUINO (about £7.50 / $10 from any of the Far Eastern companies like Banggood) which sounds a more straightforward solution to getting your screen working as you have about 7 GPIO pins, PLUS SPI PLUS I2C available. Just suggestin' !

  • @omkarrenavikar2487
    @omkarrenavikar2487 3 ปีที่แล้ว

    How can we control relay and mosfet using pcf8574 and arduino? what is procedure? anyone have arduino code?

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

      The demo sketch here shows how to set the pins on the PCF8574 HIGH and LOW - just like on the main processor, so just do the same to the relay and MOSFET.

  • @sksuman4400
    @sksuman4400 5 ปีที่แล้ว

    Sir, I am from INDIA and I am a student of ELECTRONICS AND COMMUNICATION ENGINEERING. I am the biggest fan of you. Sir if you make a video on TCA9548A with a clear concept then I will be very thankful to you. I like your way of explanation of any sensor because you always deliver a clear concept. Hope you will upload the video soon sir. Actually, sir Arduino has one SDA and SCL pin, if we have 4 I2c modules then we will be unable to connect all the modules at a time with Arduino, that's why I have requested to you. sir if you have any better idea then please let me know sir.

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

      Hello SK Suman, nice to hear from you. I am not totally clear what problem you have with the I2C bus - you can have up to 64 devices on a single I2C bus as long as each device has a _unique_ hex address. If you have an item with a _fixed_ hex address then the TCA9548A will let you have 8 of these on the _same_ I2C bus. Remember that devices on an I2C bus _share_ the _same_ SDA / SCL lines. However, your suggestion is a good one. I will add it to my list.

    • @sksuman4400
      @sksuman4400 5 ปีที่แล้ว

      Thanks sir

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

      Are you still interested in this device, SK Suman? Watch this week's video!

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

    I wish I could search to see if someone else already made this comment or not using my phone, but oh well I'll say it anyway. Now you can add it to your Attiny and get lots of I2C devices. You'll only be limited my memory. Now if you could just add memory and convert the I2C signal to something else.

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

      But you can't add run-time memory to _any_ Arduino-type chip, vonries, so we have to be creative in our thinking (and terse in our code styling). What do you want to convert the I2C signal to then?

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

      Ralph S Bacon everything I possibly can. I want to know how far a $0.50 chip can be pushed. I don't care how slow it goes just how much it can do. The problem is I'm new to this and have brain injures. Nevertheless, I used to be a pretty good programmer "back in the day."

  • @xmenxwk
    @xmenxwk 6 ปีที่แล้ว

    why not use shift register, much cheaper and smaller.

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

      Indeed this is possible, xmenxwk, but I found it a bit fiddly when I experimented using a 74HC595. There are, however, some detailed instructions on the Arduino web site (link below) for this so it may be something for others to consider. For this demo, though, I just liked the idea of controlling pins via the twin wire (I2C) system, very clean, very logical - but not the only way to do it by any means. I'm not so sure about your claim of smaller (nor cheaper, if you factor in ease-of-implementation) but I won't quibble! Thanks for raising this as an alternative, you never know others may well try it out. Thanks for posting.
      Link: www.arduino.cc/en/Tutorial/ShiftOut

    • @xmenxwk
      @xmenxwk 6 ปีที่แล้ว +1

      Actually shift registers are not difficult to implement, also SOIC-16 of shift register has around half the width of SOIC16 of PCF8574. So they are smaller than the one shown in video, yes you can get smaller size in different package. Also PCF8574 costs more than 3 times. So if you are working in big production and need to save some cost, try shift registers. Thats what I meant. :)

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

      You have indeed intrigued me, xmenxwk, and I shall look at this in more detail to see how easy it would be to implement. Thanks again for highlighting this alternative method of extending pins.

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

    ya terminaron la practica :v

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

      Lo siento, Jean, no entiendo lo que quieres decir aqui.

  • @PaulCavanagh69
    @PaulCavanagh69 7 ปีที่แล้ว

    There is also a bigger brother of this chip:
    PCF8575 Remote 16-Bit I2C and SMBus I/O Expander with Interrupt Output
    datasheet www.ti.com/product/PCF8575

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

      Now this is interesting on two fronts, Paul. Firstly, when I first read that datasheet (thanks for that head up, by the way) I saw that this was 16-bit device, so I raised (a mental) eyebrow wondering how we would interface that to the Arduino. Secondly, this is not a problem, as the 'datasheet' tab on that page shows TWO 8-bit devices connected to this item. Hmm. Interesting. I will have to read more. Thanks for the link, others may be interested in that too.

    • @PaulCavanagh69
      @PaulCavanagh69 7 ปีที่แล้ว

      Thats what i thought "Interesting!" and of course i knew you would also be interested.
      I also found this in my exploration:
      www.sparkfun.com/products/13601
      another chip and breakout board,
      SparkFun 16 Output I/O Expander Breakout - SX1509
      which uses another chip.
      Applications could be a keyboard and a display using one board or chip as all the chips are multi i/o.

    • @PaulCavanagh69
      @PaulCavanagh69 7 ปีที่แล้ว

      i'm sure if you did a search for pcf8575 you'll be able to find libraries such as this one.
      github.com/skywodd/pcf8574_arduino_library

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

      Been there, read the book, got the T-shirt. Well, sort of. I've looked at the library and it is not *that* complicated (it just sends the standard register / data bytes like we've done in a few videos here already). But the library, as always, does make it easier to get on with the job in hand without faffing about with such technicalities. Thanks for the heads up, Paul.

  • @startobytes
    @startobytes 3 ปีที่แล้ว +1

    I am the 500 th Like!!

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

      I like it! (See what I did there?) 👍

  • @sarreqteryx
    @sarreqteryx 7 ปีที่แล้ว

    3²-1? how about making it simle. 2³!

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

      I'm afraid you'll have to put your comment in context, Sarreq, because although 3^2-1 is indeed 2^3 I can't remember how (or even if) this is related to the video! Let me know!

    • @sarreqteryx
      @sarreqteryx 7 ปีที่แล้ว

      Ralph S Bacon at the beginning when you're figuring out how many addresses the dip switch provides

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

      In that case you are definitely correct, the maximum number of permutations in a given number of bits (or dip switch positions) is 2 ^ n. Thank goodness someone is paying attention in these videos because it certainly isn't me!

    • @jimbarchuk
      @jimbarchuk 6 ปีที่แล้ว

      To be perfectly honest, in 30 years of programming I'd never heard of the (x^2)-1 trick!!! When I needed to know a number I'd mentally do the 2...4...8...16 thing in my head. (And even that is only good up to about 8 bits.)
      There's a REASON why it's easier than 2^x. While 2^x is fine for low single digit numbers, can you quickly name what 2^7 is? Or 2^12? However (12^2) is easy, then -1 = 48 is trivial.
      2^x is fewer typed characters, easier to understand in program format, but NOT trivial to do mentally. Actually, personally, I'm not comfortable with ^2 past 12, because I've never used it that much. Also, if I'm doing something that big in hardware or software, by then I'm doing it in hex anyway where mental calculations are absolutely impossible for me and need a calculator.

  • @RaymondJerome
    @RaymondJerome 5 ปีที่แล้ว

    uggl three squared minus 1. you fail. it is two to the third. just try to think of something with 5 switches, i would say think about 2 or 4 switches but ha ha...

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

      Haha, yes it is 2 to the power of 3, not 3 to the power of 2, easy to get confused (at my age, anyway). Thanks for the correction, Raymond.

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

    not easy. i dont understand.

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

      What don't you understand? Let me know!