tag:blogger.com,1999:blog-3648927237801494248.post1960050248947098375..comments2021-06-23T14:47:10.739+08:00Comments on Blog of Wei-Hsiung Huang: How to use shift register (74HC165)Wei-Hsiung Huanghttp://www.blogger.com/profile/09437875322676421890noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-3648927237801494248.post-69253180914541556872016-06-22T11:12:51.035+08:002016-06-22T11:12:51.035+08:00My Father is doing well. Thank you for your concer...My Father is doing well. Thank you for your concern. I am happy that you've solved the problem. Congratulations!! :-)Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-46823569322508703362016-06-22T00:46:45.520+08:002016-06-22T00:46:45.520+08:00Hiya Wei-Hsiung. Firstly I hope your Father is OK....Hiya Wei-Hsiung. Firstly I hope your Father is OK. I have finally got this to work. I must of changed one digit when stripping out the code. Where bytesVal |= (bitVal << ((8) - i)); .. Should be bytesVal |= (bitVal << ((7) - i));<br>My next step is to put back in the code removed for the UNO digital pins and then add another 74HC165 daisy chained, but I think the hard part is now done. I really have appreciated your input. I will post the full working code once tidied up.<br><br>Many thanks<br><br>LesLes Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-27599261618192936682016-06-21T10:16:58.715+08:002016-06-21T10:16:58.715+08:00I've browsed through your code and the schemat...I've browsed through your code and the schematic (but I don't have time to actually duplicate your settings and trace the code), below are some issues that you might want to check:<br><br>1. Make sure the pins are properly wired.<br><br>In your schematic, A2, A3, and A5 are not wired, but they are used in your code.<br><br>//joyReport.axis[0] = (-32768 to 32767)<br> joyReport.axis[0] = map(analogRead(A0), 0, 1023, -32768,32767 );<br> joyReport.axis[1] = map(analogRead(A1), 0, 1023, -32768,32767 );<br> joyReport.axis[2] = map(analogRead(A2), 0, 1023, -32768,32767 );<br> joyReport.axis[3] = map(analogRead(A3), 0, 1023, -32768,32767 );<br> joyReport.axis[4] = 0;<br> joyReport.axis[5] = 0;<br><br>-------------------------------------------------------------<br> <br> //Pinos analogicos 4 e 5<br> analogicPinAsButton(A4,13);<br> analogicPinAsButton(A5,14);<br><br>2. Make sure the pins used in your code but not wired up are properly terminated (ground or pull up)<br><br>Fail to do so will cause these pins to give out random signal and causes chaotic results (which may explain why the correct buttons are lit but then they go manic.Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-83856850628467646702016-06-20T03:09:47.175+08:002016-06-20T03:09:47.175+08:00Have sent to your email as i'm not sure how to...Have sent to your email as i'm not sure how to add attachments here.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-38603308923330630452016-06-19T09:22:49.885+08:002016-06-19T09:22:49.885+08:00Could you send me your schematic and let me know h...Could you send me your schematic and let me know how you test it (do you use any software to help you do the test)? I haven't looked at you code, but my guess is that there may be problem in your schematic (how you wire up the buttons and the unused pin(s)).Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-7868138418167823282016-06-19T01:42:18.789+08:002016-06-19T01:42:18.789+08:00I've managed to get the array filled and it wo...I've managed to get the array filled and it works fine on the shift register code. I have merged the two codes and when I plug in as a HID device the correct buttons are lit, however on button change it all goes manic. Can you please look at the code and see if you can see where I am going wrong.<br><br>https://forum.arduino.cc/index.php?topic=405837.0<br><br>Many thanks<br><br>LesLes Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-32840427521527880592016-06-17T21:51:01.496+08:002016-06-17T21:51:01.496+08:00There are several ways to do it. For example, you ...There are several ways to do it. For example, you could use a For or While loop and bitwise AND (https://www.arduino.cc/en/Reference/BitwiseAnd) to check each bit. If it's a 1 then put 1 into the corresponding spot in an array, if it's a 0 then put 0.Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-28363587368569502592016-06-17T17:50:39.658+08:002016-06-17T17:50:39.658+08:00Hiya Wei-Hsiung. How would I put the 8 bit binary ...Hiya Wei-Hsiung. How would I put the 8 bit binary into an array? Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-45302175672255542402016-06-11T22:52:08.228+08:002016-06-11T22:52:08.228+08:00Yes! That's correct. And you could find refere...Yes! That's correct. And you could find reference about the keystroke codes, the Keyboard Report Buffer, and other useful info. in my latest post that I've just posted on my blog...Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-46579556793558093942016-06-11T22:48:08.116+08:002016-06-11T22:48:08.116+08:00Many thanks for you input, i'll give it a go. ...Many thanks for you input, i'll give it a go. I presume I need to work out how to send the binary variable/keystrock to a virtual pin so it can be sent to the joy_report as a button?Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-85155547160215327092016-06-11T22:38:54.677+08:002016-06-11T22:38:54.677+08:00I've done some research on HID keyboard and HI...I've done some research on HID keyboard and HID joystick and will post my findings on my blog in a few minutes (it's not finished yet as I want to make a tutorial about it). Hope the preliminary version will help you to carry out your project.Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-25436730566823329052016-06-11T22:35:04.553+08:002016-06-11T22:35:04.553+08:00I've taken a look at the code made by Darran H...I've taken a look at the code made by Darran Hunt and I think he only implemented the sending of joystick data to the PC, not the keystrokes. This can be seemed from the sentence "Here's a sketch demonstrating how to send joystick data to the host." that he put right between the "Example Sketch" and his code. In order to send the keystroke to the PC, the keystroke needs to be added into the "Keyboard Report Buffer", which is the joyReport structure defined in Darran's code and it's sent out by the sendJoyReport function.<br><br>I think what you need to do is to first combine the shift register code that you got from my blog with the HID keyboard example at http://mitchtech.net/arduino-usb-hid-keyboard/ to implement a HID keyboard based on shift register. After that, you could merge this code with Darran's code to come out with what you want to achieve.Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-72378401735564053482016-06-11T22:14:47.901+08:002016-06-11T22:14:47.901+08:00Sorry. It's my fault. I didn't publish tha...Sorry. It's my fault. I didn't publish that post (now it's polished)...Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-1675290493498536812016-06-11T19:02:22.942+08:002016-06-11T19:02:22.942+08:00Hi Wei-Hsiung. I posted up the link again yesterda...Hi Wei-Hsiung. I posted up the link again yesterday but it doesn't seem to be showing.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-4090734056714564832016-06-10T16:21:07.262+08:002016-06-10T16:21:07.262+08:00My apolgies, I thought I had. Will try again:https...My apolgies, I thought I had. Will try again:<br><br>https://forum.arduino.cc/index.php?topic=405837.0Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-7349269264366228642016-06-10T15:30:59.634+08:002016-06-10T15:30:59.634+08:00Could you paste the link to your code on Arduino F...Could you paste the link to your code on Arduino Forum for me to take a look?Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-59143222283670708302016-06-10T15:29:44.008+08:002016-06-10T15:29:44.008+08:00This comment has been removed by the author.This comment has been removed by the author.Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-19285348626045176092016-06-10T15:04:29.110+08:002016-06-10T15:04:29.110+08:00I've still not found a way to link the two cod...I've still not found a way to link the two codes together. Both work independently but not sure where to start adding the 74hc165 to the hid code.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-68716193993273471282016-06-10T14:33:02.342+08:002016-06-10T14:33:02.342+08:00Great!! Let me know how did it work out for you..Great!! Let me know how did it work out for you..Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-33933207794514805392016-06-10T13:28:39.650+08:002016-06-10T13:28:39.650+08:00I've posted up both sets of code i've got ...I've posted up both sets of code i've got so far on the arduino forums. The 74hc165 code has been taken from your site.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-84627561742901057452016-06-10T13:18:57.663+08:002016-06-10T13:18:57.663+08:00I have two thumb sticks on a1 - a4. The other two ...I have two thumb sticks on a1 - a4. The other two analog pins will be used as digital. This at the moment gives me 14 digital. 8 of these will have two dpads. 9 pins will be used for rotary encoders, then a push button and about 8 swithes, so I would be looking at two daisy chained registers.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-85541932812493769872016-06-10T09:41:13.052+08:002016-06-10T09:41:13.052+08:00I think it's possible. The only issue that I c...I think it's possible. The only issue that I could think of is how fast can this extended keyboard sends out the keystroke (need to test it out). How many keys do you currently have on your HID keyboard and how many more keys do you want?Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-73599001941260573212016-06-10T03:56:49.006+08:002016-06-10T03:56:49.006+08:00Many thanks for your quick reply Wei-Hsiung. It...Many thanks for your quick reply Wei-Hsiung. It's to add extra buttons to a custom collective / joystick to mainly use with DCS world. I'm using the Oculus DK2 so i'm trying to avoid using the keyboard blindly. A mega would be easier but I'm limited for space and I have plenty of shift registers.Les Hunthttps://www.blogger.com/profile/02208364236549876992noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-14425825084295791502016-06-09T23:58:41.592+08:002016-06-09T23:58:41.592+08:00What do you want to achieve in the HID mode? What&...What do you want to achieve in the HID mode? What's the application?Wei-Hsiung Huanghttps://www.blogger.com/profile/09437875322676421890noreply@blogger.comtag:blogger.com,1999:blog-3648927237801494248.post-62908525623684464682016-06-09T22:45:00.438+08:002016-06-09T22:45:00.438+08:00Many thanks for the tutorial. Do you know how to i...Many thanks for the tutorial. Do you know how to implement this into a uno in HID mode? I already have HID mode working.Unknownhttps://www.blogger.com/profile/02208364236549876992noreply@blogger.com