geekhack

geekhack Projects => Making Stuff Together! => Topic started by: Pitrek on Sun, 26 April 2015, 06:43:33

Title: Building 2-switch keyboard
Post by: Pitrek on Sun, 26 April 2015, 06:43:33
Hi! I would like to build my own keyboard for osu!
Can u match components and recommend software for me? Available here: http://allegro.pl/

To the best of my knowledge i need: 2 switches (have 2x Cherry MX Red already) + Teensy 2.0 (not available here, in Poland, need counterpart) + some Zener diodes + wires

Look around and i'm ordering:
http://allegro.pl/przewody-kable-zworki-meski-zenski-m-f-40szt-20cm-i5032615063.html
http://allegro.pl/arduino-pro-micro-atmega-32u4-leonardo-micro-hit-i5014242447.html
http://allegro.pl/zyscom-dioda-1n4148-55szt-i5235852170.html

Can someone tell me how to connect controller with switches, and then how to make it works on PC? I perused a lot od guides, but every guide isn't clear for me.
Will try to use it: http://imgur.com/a/I5RQD#4 and http://kimondo.co.uk/smallest-usb-mechanical-keyboard-world/

But after soldering, completely dont know how to set my keyboard in motion. ;)

Greetings from Poland. Thank you guys!
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Sun, 26 April 2015, 08:05:59
Welcome :)

For a 2 switch board you don't need diodes, and there's not much point buying fancy wires.  You'll need to solder the pins to the controller so you'd may as well solder some thin wire you have hanging around and save yourself some money!

The pro micro you linked is a good choice and has been used for keyboards, so buy that.  I'm struggling to find the pinout with Arduino pin names to say what to connect where but if you can find one I will suggest where to connect the switches.

For the software you can probably use Easy AVR (https://geekhack.org/index.php?topic=51252.0) (very easy to configure) or TMK (https://geekhack.org/index.php?topic=41989.0) (this has more features which you don't need) depending which one works, which you'll have to test.  If not there are other options :)
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Sun, 26 April 2015, 13:17:55
Don't know exactly what is pinout, but this is it: https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro ?

Ok, seems not hard :D And one more question, what have i to do when will i want add RGB diodes, working constant, but with adjustable color and brightness level?

Thank you!
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Sun, 26 April 2015, 14:07:23
That's close but you need one that maps the pins to port numbers on the actual controller chip - they are called things like PB4, PC3 and PD5 (I said Arduino names which you found, but that was wrong...) I think this (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Boards/Pro_Micro_v13.pdf) is it.

If you want RGB LEDs with brightness controls you'll be needing the TMK (https://geekhack.org/index.php?topic=41989.0) firmware - that's one of the features I thought you wouldn't need.  I just checked and it does run on the Pro Micro so all good.

You'll need 3 pins to manage the switches and 3 PWM pins to manage the RGB LEDs, the Pro micro only has 5 PWM pins so both LEDs will have to be the same colour brightness.  I'm not sure how you will be able to change the settings though - usually some keys on the keyboard are programmed to do it, but you won't have enough.  You might be able to add some other switches (small ones, not MX) underneath or on the side of whatever case this will be in?
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Sun, 26 April 2015, 15:51:32
Ok, thank you master.

&
Controller with 6PWM pins on allegro.pl?
For osu! do you know how to make diodes color change with increasing ClicksPerMinute? It would be super, just asking ;)

Ordering today, will try my best, and if it won't succed i'll come back. :D
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Sun, 26 April 2015, 16:39:24
Sorry I don't know many controllers and as I can't read Polish you're probably in a better situation to search than I am.  You could post here requesting controller options, then try and find them - I'm sure someone can help :) 

Or if you can make do with less colours you can use less PWM pins - red, green and orange or red, purple and blue or would only need two pins.

Also I have never heard of osu! to know how to link to it, but I do know that if you want the LEDs to interact with software running on your computer you won't be able to set it up as a keyboard.  Instead you'll have to run something on the computer which connects to the game and your controller, and this program must convert switch presses into keyboard input and send out the clicks per minute from the game to the controller so it can set the LED brightness.  This would be fun to do but probably not easy...
Title: Re: Building 2-switch keyboard
Post by: rowdy on Sun, 26 April 2015, 18:06:34
You could also consider an Enabler: http://techkeys.us/collections/accessories/products/the-enabler
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Mon, 27 April 2015, 14:49:45
Micro Pro controller is cheaper than 2x enabler 1x1 with shipping ;)

I would like to build something like this:
Some info: http://vk.com/wall-6590565_69272

Components will be tomorrow in my parcelmachine. :3
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Tue, 28 April 2015, 02:22:24
Good to see someone's done this already, that means the game output is available :)
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Wed, 29 April 2015, 11:10:50
Ok, order arrived. ;)
http://i.imgur.com/khxZL61.jpg

Can u explain, how to connect Cherry MX switches with controller?
That way: http://i.imgur.com/M15xRkK.png or http://i.imgur.com/fbfjKMy.png ? I leaned on http://i.imgur.com/YATfsgF.png
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Wed, 29 April 2015, 19:02:42
Ok, order arrived. ;)
http://i.imgur.com/khxZL61.jpg

Can u explain, how to connect Cherry MX switches with controller?
That way: http://i.imgur.com/M15xRkK.png or http://i.imgur.com/fbfjKMy.png ? I leaned on http://i.imgur.com/YATfsgF.png
Actually neither of those is correct if you're using keyboard firmware made for a lot of switches :)

If you open EasyAVR and choose "Handwire Matrix" you get a pop-up text file, about half way down is "pin assignments."  This lists which pins are used for rows and columns, with the PB[number] style names I mentioned before - you need to connect one leg of each switch to a pin from the Row section and the other leg to a Column pin.  You'll need to use pins which aren't connected to LEDs (e.g. PD5 on the bottom right of the diagram) and if you might want to add LEDs later avoid the PWM pins.  It's also easier if you don't use pins next to each other so you don't accidentally solder them together.

It's late and I'm on a small screen so struggling to work it out, but I think PB1 is marked 15 on your controller and PF4 is marked A3 - this should map to row 4 column 8 which is one of the Zs in the pic below (the first row and column are 0 and I can't remember if the rows count from the bottom or top :-[).  Before you solder anything put the letters in as below, compile the hex and flash it.  Then you can carefully touch the pins suggested above with a bit of wire to check it types a Z.
(http://i.imgur.com/RLpDVAT.png)

For the second switch I think PF6 is marked A1 and PB2 is marked 16 so this should map to row 3 column 10, one of the Xs.  Again, test these pins with a wire before soldering.

If both work you can solder the switches to these pins - don't forget to put them through the case first :))
Title: Re: Building 2-switch keyboard
Post by: metalliqaz on Wed, 29 April 2015, 20:08:28
You should hack it to be the same as the sixshooter.  For such a small device, you don't need the full matrix.  Have you already wired it?  I could give you some diagrams
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Thu, 30 April 2015, 00:05:41
Nope, waiting for confirm. ;)

EDIT1: Awaiting for your call :3
http://i.imgur.com/Afn6EFu.jpg
http://i.imgur.com/gPBY3Yg.jpg
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Fri, 01 May 2015, 04:06:33
Guys?  :rolleyes:

EDIT1: Ok, made .hex file, now can't go trough flashing firmware. How to "install" my .hex file on board? Flip-USB doesn't detect device.
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Fri, 01 May 2015, 14:55:24
I don't know what the sixshooter is so can't help with that, but what I posted above should work.  You need to put it in bootloader mode (https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/32U4Note.pdf) then run the flash command, in the command prompt something like
Code: [Select]
avrdude -DV -p atmega32u4 -P SERIAL_PORT -c avr109 -b 57600 -U flash:w:PATH_TO_FIRMWARE.hex:i should work.  I use Linux so you'll need to find an avrdude tutorial to find what to put as SERIAL_PORT :)
Title: Re: Building 2-switch keyboard
Post by: metalliqaz on Fri, 01 May 2015, 16:05:06
The sixshooter is bpiphany's board for the 6-key CM switch tester.  It has no matrix but simply 6 direct keys.  He could just pick any two inputs, then wire up his switches and use the sixshooter firmware.   I'll try to remember to post a pinout, but you can find it on geekhack by searching
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Mon, 04 May 2015, 15:28:38
You need to put it in bootloader mode (https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/32U4Note.pdf) then run the flash command, in the command prompt something like
Code: [Select]
avrdude -DV -p atmega32u4 -P SERIAL_PORT -c avr109 -b 57600 -U flash:w:PATH_TO_FIRMWARE.hex:i should work.  I use Linux so you'll need to find an avrdude tutorial to find what to put as SERIAL_PORT :)

Tried, doesnt' work.

In Flip occures error: "atlibusbdfu.dll" not found, then: could not load library.
My friend has helped me, and somehow install drivers, and made Micro Pro works, but he programmed it by Arduino software writing own code.  It's ok as long as dont want to build sth like GH60.
Any tips?
Title: Re: Building 2-switch keyboard
Post by: metalliqaz on Mon, 04 May 2015, 21:39:43
You need to put it in bootloader mode (https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/32U4Note.pdf) then run the flash command, in the command prompt something like
Code: [Select]
avrdude -DV -p atmega32u4 -P SERIAL_PORT -c avr109 -b 57600 -U flash:w:PATH_TO_FIRMWARE.hex:i should work.  I use Linux so you'll need to find an avrdude tutorial to find what to put as SERIAL_PORT :)

Tried, doesnt' work.

In Flip occures error: "atlibusbdfu.dll" not found, then: could not load library.
My friend has helped me, and somehow install drivers, and made Micro Pro works, but he programmed it by Arduino software writing own code.  It's ok as long as dont want to build sth like GH60.
Any tips?

That error means you don't have the DFU driver installed.  The driver comes with Flip.  What controller are you using?
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Tue, 05 May 2015, 09:12:11
Arduino Pro Micro clone with Atmega 32u4.
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Wed, 06 May 2015, 16:21:15
Any tips?  :) Researched Google, and I am in fix.
Title: Re: Building 2-switch keyboard
Post by: suicidal_orange on Wed, 06 May 2015, 16:48:55
Sorry but no - I've been spoiled by not having to worry about drivers for years due to using Linux.

You could download a live CD of Lubuntu, boot from it, install AVR dude, and then use the command above but that's like using a sledgehammer to crack an egg :))
Title: Re: Building 2-switch keyboard
Post by: berserkfan on Thu, 07 May 2015, 08:58:35
While we're on this topic, I have an atmega Arduino Pro Micro (the blue chip) that I couldn't get to work. I thought I had the Soarer flashed correctly (and scwr.exe was able to detect Soarer's firmware and load more scwr files on it). But the atmega still didn't seem to pass through any keyboard signals. HIDlisten didn't work - totally no responses from a Model F keyboard that was 100% working.

Any suggestion on what I can do? At this point am thinking of abandoning Soarer's firmware, but have no idea how to get EasyAVR to work with a model F/ M.

I use win7 with 64bit.
Title: Re: Building 2-switch keyboard
Post by: ROFLmonstar on Fri, 08 May 2015, 08:08:38
Any tips?  :) Researched Google, and I am in fix.

Try using Cygwin. I flashed a Pro Micro without Flip and with no drivers installed other than the ones that are installed with a standard installation of Cygwin.

It's the same command to flash, too.
Title: Re: Building 2-switch keyboard
Post by: Pitrek on Tue, 12 May 2015, 15:15:12
I am going to try tomorrow. Thanks for advices. ;)