How to Control a Ton of Inputs using Shift Registers!

Поділитися
Вставка
  • Опубліковано 8 кві 2013
  • This video explains how to use shift registers(74HC595) to control an insane amount of digital inputs.
    Part 2:
    • Part 2 - How to Contro...
    Check these videos out first:
    • How Shift Registers Work!
    • Video
    The code in the video: (note - I had the data and clock backwards in the video)
    www.kevindarrah.com/download/a...
    Check out my Tindie store (trigBoard is available) www.tindie.com/stores/kdcircu...
    Thanks to all the Patrons for dropping a few bucks in the tip jar to help make these videos happen!
    / kdarrah
    Twitter: / kdcircuits
    For inquiries or design services:
    www.kdcircuits.com
  • Наука та технологія

КОМЕНТАРІ • 280

  • @GIGLIndia
    @GIGLIndia 11 років тому

    i was making 5*5*5 led cube using 595 shift register and bc 547 transistor. it worked in starting and is not working properly. i have not attached any resistor in the base emitter of transistor and 220 ohms in the collector emitter .CAN THIS BE A PROBLEM. or can you guess...

  • @serverguy2
    @serverguy2 9 років тому +7

    I was a maestro of IBM 370/390 assembler. You are a maestro of at least Arduino coding. So maybe also C and others. Anyway, I appreciate your coding. Even with the quick hacks you write for these little demos, the code is still tight without being so tight to be incomprehensible like some C/C++ coders like to do. You show off just the right amount. It is easy to understand and "elegant" for demo level programs. I have seen MUCH worse. Thank you for taking the time to do these demos. I understand the electronics and have for decades but your integration with programming is enlightening at the next level of HW/SW integration. Well done.

  • @funy0n583
    @funy0n583 Рік тому

    first he says he's going to assume we understand how shift registers work and then he says "I'm sure if you guys are familiar with diodes or not" haha I appreciate you explaining everything

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yes, you have a good point, and I just added an annotation, but this does allow you to mix inputs and outputs in the same shift register bank

  • @lloydrmc
    @lloydrmc Рік тому

    Brilliant! Provision for debounce, (frequently not the case with shift register videos). Plus SPI library for speed.
    Lots of lateral thinking here. Earned you a subscription

  • @jzgonzo
    @jzgonzo 6 років тому +4

    I'm not an electronic engineer but your explanation was pretty clear. Now i'm ready to solve a problem that seemed very complicated to me before watching this great video. Thanks!

  • @EddieVanHalen1977
    @EddieVanHalen1977 10 років тому

    I am 2 minutes in and I already know I am going to subscribe. This guy is soooo good. Like butter. Thank you Kevin. Your presentation is just flawless and perfect. I cannot wait to watch many of your videos. Thank you so much. I am fan.

  • @Kevindarrah
    @Kevindarrah  11 років тому

    nice one! Thanks for the tip. I was just goofing around with these

  • @shedactivist
    @shedactivist 3 роки тому

    Perfect. I was looking for a way to use BCD switches as inputs to Arduino and you have shown me the way.

  • @darktherapy
    @darktherapy 11 років тому

    Cheers Kevin, you did a better video explaining this technique than in possibly could.

  • @wreckless_-jl6uu
    @wreckless_-jl6uu 4 роки тому

    *Very nice, I actually under stand shift registers a lot better now!! Specifically the 74HC595!! Thanks!!!*

  • @BarrettSimms
    @BarrettSimms 9 років тому +1

    This is really great. Thanks. It would be good to see how you wired everything up when you do these.

  • @codenothing
    @codenothing 8 років тому

    Thank you so much for this video! you answered a lot of questions I had for my pinball project.

  • @DOSTalks
    @DOSTalks 9 років тому

    Just want to say man, really good video very clear and understandable you have a great channel

  • @luw1z
    @luw1z 10 років тому

    Thanks alot for the explanation. I was wondering if you have the part numbers for the diodes you used?

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yea, I know... I need to do that. Many people have suggested the same. Just been really busy lately

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yep this will work for you... sounds like an awesome project! You may want to review the other comments below to see what others have suggested

  • @mainkordormawblei
    @mainkordormawblei 6 років тому

    thank you so much Kevin for that awesome video, can you do another for 74HC165? it would really helpful. thank you.

  • @JayDAnderson
    @JayDAnderson 10 років тому +1

    Very efficient way to sense the actuation of any one or more of a number of buttons. Great. You are basically setting each button on a single bit then polling all the bits in the byte to see which one are on or off.

  • @Kevindarrah
    @Kevindarrah  11 років тому

    my code was to simply toggle the LED on or off, but if you just need to read the value in as being just on or OFF, that is simple, since a double tap wouldn't affect you. Like the ISR being called would not flip your output

  • @souravdokania1929
    @souravdokania1929 8 років тому +1

    This did blow my mind, it was so awesome. I could have never imagined such an amazing technique was even possible.

  • @fierdawsbugiez
    @fierdawsbugiez 3 роки тому

    Tq for the detail explanation,..about to build something and learning for shift reg, already watch many vid n good input

  • @The1wsx10
    @The1wsx10 8 років тому

    very nice video. i only have a basic knowledge of what different components do and i was able to understand this very clearly

  • @avdwio
    @avdwio 11 років тому +2

    Methinks an array or two would help to clean up the code.
    You could remove the while loop at the end and repeat the pin read function without actually writing to the leds. Run pin_read, get an array for which buttons are pressed, compare it to the array for the buttons which were previously pressed. From that you can find which buttons have gone from 0 to 1. If nothing's changed, there's no difference, so pin_read can just keep looping while the input is high.

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yes you are right! Ha, this actually got me as well! will update the code

  • @user-zg6qh1bk8y
    @user-zg6qh1bk8y 5 років тому

    Hey I appreciate the video, but it would be very helpful to beginners like myself to have a schematic. Is there a wiring diagram that you could share with us??

  • @anuragmahajan5919
    @anuragmahajan5919 2 місяці тому

    Thanks, that was very helpful!!!

  • @ThirdPer3on
    @ThirdPer3on 6 років тому

    Love your work!

  • @electrik0
    @electrik0 9 років тому

    Great video, Thanks for sharing!

  • @Kevindarrah
    @Kevindarrah  11 років тому

    I think you just inspired me to make a followup video!

  • @Lefterhs15
    @Lefterhs15 8 років тому

    Thanks man. Really helpful !

  • @thebackyardguru3785
    @thebackyardguru3785 10 років тому +2

    Awesome tutorial, any chance i can get a schematic.. been at it for a week and i just cant get it to work. I am from South Africa, not sure where i am going wrong... difference in IC maybe... PS i am still a newbie, what is the best way of trouble shooting where i am going wrong?

  • @1Joren
    @1Joren 8 років тому

    Erhm honestly thanks for showing that circuit with the analogRead at the start. That'll actually do for my project since it's only 4 buttons I'm using and they shouldn't/can't be pressed at the same time in my interface. I'll definitely start playing with shift registers in the future though when time is a less pressing issue :P

  • @unity4alle1
    @unity4alle1 2 роки тому

    Hi Kevin, I am trying to figure out how to make simple led selection indicator, so I want 8 LED to be shifted in an infinite loop by a press of a button. So one press next LED is lit, another press next to last LED is lit and so on in circle. I hope you understand what I want to do. Please help, thank you :)

  • @oscareriksson9414
    @oscareriksson9414 5 місяців тому

    Cool trick! I was thinking of letting the last output shift everything back to the micro controller. As in insted of connecting another shift register in series, I would connect it back to the arduino in this case. There I would shift the bits into a byte and after the 8 clocks I would have the output byte back and could mask for the correct buttonpress. I figured it would maybe work since it shifts out from there. But maybe your loop is better hmm I'll try and see. This gave me inspiration! Thanx

  • @alexstone691
    @alexstone691 9 років тому +2

    You are the best dude!!

  • @KJ7JHN
    @KJ7JHN 5 років тому

    Complete awesomeness! Thank you.

  • @abdoubobo7763
    @abdoubobo7763 2 роки тому

    Thank you so much Kevin. Please i need the diagram?

  • @flyingsquirrel3271
    @flyingsquirrel3271 5 років тому +3

    This is so cool! Thanks for explaining!
    And also: Fix your indentation!!! :-P

  • @geraldmoritz8523
    @geraldmoritz8523 8 років тому

    Great Video ! I want to use a Rotary Encoder and need the Interrupt for this one. But I could use any PinChangeInterrrupt for checking any pressed button, right ? Greetings from Austria !

  • @PihkalTheTihkal
    @PihkalTheTihkal 11 років тому

    I was going to ask why you didn't use a regular parallel in - serial out shiftregister but since multiple people already asked it I'm not going to ask it again.)
    It's actually a pretty neat technique that I've never seen before so thank you for explaining it.
    Using outputs as inputs if that's not thinking outside of the box, I don't know what is.
    Great video, as always.

  • @chemistry7699
    @chemistry7699 10 років тому

    Thank you. I now more fully understand how CCDs work by shifting the data.

  • @T-FLoWW
    @T-FLoWW 6 років тому

    Hi. I have a working circuit which has 4 digit 7 segment led display. I want to to read the Data and make my arduino send Smae numbers to my serial monitor tgat what my segment display shows simultaneously. What u wld advice? And umm this segment display has total 12 inputs which 8 for leds and 4 for shifting from eacg 1 number block cathodes(or anodes). Any advice?

  • @Leo.Martins
    @Leo.Martins 3 роки тому

    Thank God. Finaly found what i've needed!

  • @ImaginationToForm
    @ImaginationToForm 11 років тому

    Hi,
    Very useful information. I wasn't needing thousands but I am going to be making a control panel for a spaceship game I play to make it more interesting to play than just keyboard. Going to use different switches and types of lights. Was probably needing about 20 inputs and more outputs. Was going to add extra just to give it more of a spaceship feel too :) I thought I was going to have to use analog multiplexers for input but I guess I can just use the shift registers now.

  • @danielguevara9357
    @danielguevara9357 8 років тому

    exellent thats the best tutorial ever been made

  • @markpedretti3765
    @markpedretti3765 6 років тому

    I'm looking for something similar but I need to press a button and it will turn off the other. it's possible?

  • @JurriaanPetersen
    @JurriaanPetersen 11 років тому +2

    The while loop at the end of the ISR should not be necessary, if the IRS is only called on the rising edge. And if you did want to improve your code(or make it shorter) you could also replace the whole check variable by replacing it with "1

  • @cjmendoza8599
    @cjmendoza8599 5 років тому

    @kevin darrah sir im asking for help do you have a schematic diagram of 4 or 5 or more inputs interlocking circuits...for example i have a four inputs push button 1 to 4 and output LED 1 to 4 the sequence is like this..if i press push button 4 the LED4 will turn on then when i press push button 1 the LED 4 will turn off then the LED 1 will turn on then when i press push button 3 the LED 1 will turn off then LED 3 will turn on and so on..it always one LED will acivate on OUTPUT...please...thanks in advance

  • @edgarestebanroseroarmas2774
    @edgarestebanroseroarmas2774 3 роки тому

    Amazing technique!

  • @MrManuHeel
    @MrManuHeel 7 років тому

    Hi Kevin ! I'm working on a project using your setup (actually, using the "piano" version as it's exactly what I'm trying to achieve), and I can't figure out something. I don't get the usage and difference between the data and what you call "Input from the buttons" (pin 2). What exactly is this pin 2 doing and how to connect it to my buttons ? We can't really see the board or schematics in your video :/
    Thanks !

  • @nerdyneddy7887
    @nerdyneddy7887 11 років тому

    As you had as a baloon at the start, a parallel in serial out is the way ti go for input. 3 pins, clock, load & data.
    cheers

  • @maniamone
    @maniamone 3 місяці тому

    hi, are you using two 74HC595 for both controlling inputs and outputs? and is it possible to have the circuit schematic of this tutorial?

  • @13firebug13
    @13firebug13 10 років тому

    Is there a reason why I can't get my led circuit, the circuit is from a double ended light saber thing that have I think 6 leds on one circuit that has one + cable for each and one - cable for all of them.

  • @Psykamaholik
    @Psykamaholik 8 років тому

    Just wondering if you could offer suggestions as to why this code works on an UNO but not on a mega2650? I've tried changing the pins in the code to the appropriate MOSI and SCK pins on the mega but still no luck. Any help appreciated

  • @korbanomalley7002
    @korbanomalley7002 10 років тому

    I am relativity new to programming shift registers. How could I modify this code to use only 1 register for inputs and then do something like print "high" to the serial monitor?

  • @zelra891
    @zelra891 9 років тому

    thanks. clear video on how it works. but i'm not familiar with SPI, so the code is a little hard to understand.

  • @doomaster4
    @doomaster4 10 років тому

    Have you tried connecting this to the arduino in your cube to change the animation that is running?

  • @YoussefEl.
    @YoussefEl. 8 років тому

    How would you apply the same principle for an analog signal ? The Arduino has only 6 analog inputs, what could we use to extend that to say 20+ analog inputs?

  • @Kevindarrah
    @Kevindarrah  11 років тому

    hmmm, maybe? I think there might be a way to modify what I have here for something like that, but this is interrupt driven, so if you only care about a reading above a threshold then yea, I think this coudl work

  • @Gator198l
    @Gator198l 9 років тому

    Kevin, how is this wired? I'm having problems getting this set up. Thanks.

  • @bergweg
    @bergweg 11 років тому

    I was about to post the same question. The 74HC595 is a Serial to Serial/Parallel IC, I'd use a Parallel to Serial IC with internal pull-up resistors.

  • @dadholly3133
    @dadholly3133 10 років тому

    Can a automatic style casino keno game be made up with Arduino or some micro controller. It would show game number as well as drawing 20 random numbers out of 80 leds.

  • @iam.masoudsamimi
    @iam.masoudsamimi 3 роки тому

    Do you have schematics/diagrams for the connections please?

  • @priyabratasaha5385
    @priyabratasaha5385 7 років тому

    Great idea BOSS!

  • @german.galvis
    @german.galvis 6 років тому

    I couldn't find schematics for this in your site! are those published anywhere else? :O :O

  • @avtargrewal7422
    @avtargrewal7422 7 років тому

    Hi Kevin .I am working on project where I need to switch on /off 16 LED with 16 switch with Arduino uno.Could you please show me how to edit the code for 16l LED's whit 16 switches

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yea that's a good idea, I still need to bust out my pi and figure out how to work with it

  • @deltasecurity7135
    @deltasecurity7135 9 років тому

    Hello Mr.Darrah , Kevin ,
    First of all , congratulations for you excellent job. That being said , I wonder if you can post a tutorial with the wiring diagram of the circuit, because I tried several times and could not make it work.
    Thank you in advance.
    Wagner Hiroshi

  • @TexasSkyPilot2
    @TexasSkyPilot2 10 років тому +1

    Good explanation of good design. Cinematography should be front lighting to remove glare from back light on desktop.

  • @Firashelou
    @Firashelou 11 років тому

    hello, can you please put a fritzing picture or a schematic for the circuit ?

  • @mbrumlow
    @mbrumlow 10 років тому +2

    I am just getting into Arduino, but have experience with programming.
    I was just wondering about your code a bit.
    I was thinking that it may be better to make pen_read set a global boolean, then in your loop you would do basically what you are doing in pen_read right now.
    loop would be while(pressed) { *current_pen_read_code*; pressed = false; };
    Like I said, I am new, and don't have the parts to test this yet. Can you think of why that would not work, or why that would be less effective?

  • @adriancastellanoszaragoza5878
    @adriancastellanoszaragoza5878 10 років тому

    Awsome tutorial

  • @charnjit525
    @charnjit525 5 років тому

    As any arduino board all pins can be used as digitalRead. My arduino Pro micro board has 18 pins for use as digitalRead. I
    Need to 42 pins for input to my arduino board(for different outputs) . Is it possible using 74HC595 shift register????? . If yes, please help me with arduino sketch & wiring diagram arduino board to 74HC595 and push buttons,,,,,,,

  • @yorgle
    @yorgle 10 років тому

    This is remarkably similar to how a Diode Matrix Rom works. Very clever!

  • @chadjamesjohnson
    @chadjamesjohnson 11 років тому

    Hey, I'm curious. What microcontroller are you using in this video?

  • @Kevindarrah
    @Kevindarrah  11 років тому

    yea they are, but no prob since we are debouncing in software. A simple delay is all that's needed

  • @MrXiaofanZhang
    @MrXiaofanZhang 11 років тому

    Hi there,
    Has anybody got any tips/ advice for a relative beginner in electronics? I've got some basic knowledge about basic components(leds, resistors, caps) and the picaxe system. But I was wondering if there are any good websites or other resources that could help me broaden my knowledge/ understanding and work with more complex things with more integrated circuits driving a wider variety of outputs.
    Thanks.

  • @htkevo5273
    @htkevo5273 4 роки тому +1

    I think u can also use a 74165 parallel in serial out that has its output pin hooked to DS of the 74595 to achieve this

    • @LikeVHD
      @LikeVHD Рік тому +1

      I think. If using 74165 then no need to use 74595 anymore. It is possible to connect the push button directly to the 74165 to reduce complexity. The rest is just programming.

  • @thomasthiry4293
    @thomasthiry4293 5 років тому

    Hi! Does all this can work on a raspberry pi (and domoticz)? Thanks :)

  • @Neslekkim
    @Neslekkim 11 років тому

    The buttons you are using here, are they not giving you any bounceproblems?, if so, what buttons are they?

  • @10magicalfingers27
    @10magicalfingers27 4 роки тому +1

    Hi Kevin, I'm trying to make a small simple midi keyboard with 25keys (nothing fancy, just digital switches reading on and offs and sending the data to the computer) . I just need it to be polyphonic upto 10keys. I.e it should be able to detect (on or off) for 10 keys at them same time. And it should be very responsive in reading it. Are multiplexers okay or shift registers? Which shift register do I need need. And i saw you pressing multiple buttons at once. How many can actually be pressed at the same time and still work in your setup.

    • @Obzy98
      @Obzy98 Рік тому +1

      Hey @10magicalfingers27
      I'm curious to know if you got a solution for your project. Did it work? And do you mind sharing your thoughts?

  • @DeeegerD
    @DeeegerD 9 років тому +30

    Good button technique but all those delays in an ISR is very bad practice. You should only record the state of the buttons into variables and let the main loop process debounce and determine if the buttons have been pressed. Another way is to check a clock state and determine if the button has been pressed long enough in the ISR and set a state. The objective is to manage the button state as quickly as possible in the ISR and return to the main loop (rest of the code).

    • @DupczacyBawol
      @DupczacyBawol 6 років тому +2

      Agreed, but the author was saying he had not prepared himself to the video, and he appologized to us. As for ISR, indeed the 'routine' (not function) should only set some flag to true/false, and that is all. Hardware interrupts work aside normal program execution. MC/CPU stops normal program execution for checking all that interupt stater and running ISRs. And I think unless the current ISR() routine finishes it halts executing next ISRs, thus stops running the code and other interrupts (timers?). I think, such behavior prevents also from multiple execution of the same ISR over, and over again berore the first one finishes. (we would experience interrupts interrupted by interrupts - endless loop). The loop function should do the job. Anyway great lecture, thank the author. Have a nice day.

    • @Gilhad1
      @Gilhad1 6 років тому +1

      You are right, but purpose of THIS video was not ISR, but the button/diode/pin 2 trick, no more. So the code is just as demo, how it is possible to read that, not how it should be done in "real" program and even waiting in ISR does not matter, as there is no other code to execute, nor other interrupt to take care of.

    • @HDFoxra
      @HDFoxra 5 років тому

      @@DupczacyBawol As pointed out, yea... this has nothing to do with ISR or anything like that. And even if he apologized for not being prepared to make a video... if you haven't prepared, why make the video? Lol. EVEN then, again, being prepared for a video has nothing to do with implementation. I could set up 20 servers for a business, but then go 'I wasn't prepared to give an orientation on how to use these servers', and yet that orientation would have NOTHING to do with me actually installing an OS onto the hardware and installing the necessary drivers/software...

  • @watodo1688
    @watodo1688 Рік тому +1

    Hi bro we need circuit diagram for this project

  • @avdwio
    @avdwio 11 років тому

    So what happens if you're holding down one button and then press another? I'd assume that while loop at the end screws you over a bit there.

  • @hyperscitic92a
    @hyperscitic92a 10 років тому +16

    Could you please post schematic of this circuit on your website. I understand shift registers pretty well but I'm a bit confused how you wired this project up.

    • @Leilektsoglou
      @Leilektsoglou 3 роки тому

      +Kyle Leser Did you manage to make the wiring?

    • @ianthehunter3532
      @ianthehunter3532 3 роки тому

      @@Leilektsoglou Did you manage to make the wiring?

    • @jacobstrous8929
      @jacobstrous8929 2 роки тому

      @@ianthehunter3532 Did you manage to make the wiring?

    • @ianthehunter3532
      @ianthehunter3532 2 роки тому

      @@jacobstrous8929 no, gonna use io extenders

  • @TomLeg
    @TomLeg 4 роки тому

    What pushbutton are you using?

  • @bitmeister
    @bitmeister 11 років тому

    Wow, no dislikes, congratulations! Great vid!

  • @serhioromano
    @serhioromano 8 років тому

    Kevin, I would like to discuss one idea with you. How could I contact you?

    • @Kevindarrah
      @Kevindarrah  8 років тому

      +Sergey Romanov kdcircuits.com

  • @FreeApophis
    @FreeApophis 10 років тому +1

    That is pretty neat.
    However for a thousand inputs it would probably be a good idea to be a bit more efficiant: You could make this even faster by divide and conquer instead of a linear search. For 1024 Inputs you only would need 10 checking cycles compared to 1024 in the linear search.

  • @SkyhanViper
    @SkyhanViper 8 років тому

    u can use data lactches for same porpose.
    74hc374
    no code needed.
    just use external data read command
    74138 demultiplexer will also help u for more inputs

  • @Yefatbastard
    @Yefatbastard 8 років тому +4

    Diodes are like check valves, they only allow current to flow in one direction..

  • @4.0.4
    @4.0.4 7 років тому +1

    Isn't this simplier with the CD4021 chip instead of the 74HC595 chip?
    I'm a novice so I really don't know, but it does seem like one chip is made to shift out (e.g., to a bunch of LEDs) and another to shift in (e.g., many buttons)
    On the other hand most arduino kits come with a 74HC595 and not a CD4021 so maybe I'm missing something.

    • @GordieGii
      @GordieGii 6 років тому

      To use a CD4021 (or other parallel to serial shift register) you have to constantly read in the register to know whether anything changed. With the '595 you just turn on all the outputs and you forget about it until an interrupt occurs. When an interrupt occurs then scan to see which one(s) caused the interrupt.

  • @bwoogie
    @bwoogie 7 років тому +1

    The diodes are required if anyone is wondering :) I didn't have any on hand so I just used some LEDs! for testing purposes, anyways.

    • @AnimilesYT
      @AnimilesYT 5 років тому

      Aren't LEDs horrible diodes? I have no facts to back it up, but I've heard that LEDs were made to emit light, and not to block the current. But if it works for testing purposes then I don't really see a problem either xD

  • @SimonKatimba
    @SimonKatimba 7 років тому

    could you please show me a schematic of how i would connect 8 switches(input) to my 74HC165 to Arduino and then to my 74HC595 to my 8 LEDs(output)?When a correspong switch is off, then a corresponding LED should go on

  • @Yemto
    @Yemto 8 років тому

    I had no idea the shift register could be used for inputs too, thanks so much.

    • @RFC3514
      @RFC3514 8 років тому

      +Yemto - This is a pretty roundabout way of doing it, using a serial-to-parallel shift register, though (useful if you only have those available). Assuming you're not stuck with the 74HC595, though, you can use a parallel-to-serial (or bidirectional) shift register (ex., CD4021B) to do most of the work for you.
      Check the "Parallel to Serial conversion" tutorial page in the Arduino site for some examples.

    • @GordieGii
      @GordieGii 6 років тому

      To use a CD4021B (or other parallel to serial shift register) you have to constantly read in the register to know whether anything changed. With the '595 you just turn on all the outputs and you forget about it until an interrupt occurs. When an interrupt occurs then scan to see which one(s) caused the interrupt.
      His way is actually pretty clever.

  • @lcf4359
    @lcf4359 Рік тому

    It would really be helpful if you upload the circuit schematic

  • @ClokworkGremlin
    @ClokworkGremlin 5 років тому

    So it's basically a ghetto MUX, which is pretty cool if you don't have an 8-to-1 MUX lying around, but the really interesting thing about this is that since you're strobing the source voltage across the pins, it should actually work with analog inputs as well as pushbuttons. When you do the strobing pass, the pulldown resistor will reduce the voltage across the inactive pins to 0, so you can theoretically get the voltage across only one input at a time.
    You may need to do some resistor math to figure it out exactly. It's been a few years since I had to calculate circuit diagrams, but could be especially useful if you have a limited number of ADC pins available.

    • @ClokworkGremlin
      @ClokworkGremlin 5 років тому

      Back to say: I just tried this, and it actually works way better than I expected, but not exactly how I described 2 months ago.
      Your analog inputs each have one reference pin tied to VCC or ground, depending on whether you want them to be active-high or active-low. (VCC for active-low, VSS for active-high)
      The other reference pin is tied to the shift register, and is strobed through just like in this example (or the later one where he switched from ISR to polling)
      Analog values are connected to a single analog pin via a diode. If the circuit is set up in Active-High mode, the diodes should be pointing *from the analog sensor into the MCU analog input pin.* In Active-Low mode, point them the other direction.
      The analog pin will read whatever the highest/lowest (depending on mode) value among all of the analog sensors is. By setting the shift register pin to inactive mode (low for active-high, high for active-low), you effectively remove that sensor from the circuit. Set only one sensor active at a time and strobe through them to read 8 analog values on a single input pin.

  • @TheRossiale
    @TheRossiale 11 років тому

    Can it be used for analog readings? :)

  • @Skandawin78
    @Skandawin78 7 років тому

    how many shift registers I need to control 25 key keyboard ? what is scan matrix? with 9*3 scan matrix can I control all 25 keys . how to set up that? pls advise

    • @Gilhad1
      @Gilhad1 6 років тому

      4 registers using this idea verbatim. to read matrix you need different aproach. Depends on many factors, what is the best, I woul use one mcp23017 over I2C for matrix up to 16 (rows+cols total)