On pro micro, or leonardo is an ATmega32U4, this chip have USB HID on Board.
I dont want to write the complete code new. So this is the easiest way to test some stuff :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok here, is the tested sketch:
So if anybody need a real keyboard input for a dart matrix he can use:
#include<Keyboard.h>#define NUM_ROWS 8#define NUM_COLS 9#define DEBOUNCE_VALUE 100#define REPEAT_DELAY 500// Keymap for normal usebytekeyMap[NUM_ROWS][NUM_COLS]={{'0','1','2','4','5','6','7','8','9'},{'a','b','c','d','e','f','g','h','i'},{'j','k','l','m','n','o','p','q','r'},{'s','t','u','v','w','x','y','z','A'},{'B','C','D','E','F','G','H','I','J'},{'K','L','M','N','O','P','Q','R','S'},{'T','U','V','W','X','Y','Z','+','-'},{'*','/','?','!','&','$','@','#','_'}};// Global VariablesintdebounceCount[NUM_ROWS][NUM_COLS];intaltKeyFlag;boolserial_output;// Define the row and column pinsbytecolPins[NUM_COLS]={A0,A1,A2,A3,15,14,16,10,1};// A,B,C,D,E,F,G,HbyterowPins[NUM_ROWS]={2,3,4,5,6,7,8,9};// SETUPvoidsetup(){// Set all pins as inputs and activate pull-upsserial_output=false;for(bytec=0;c<NUM_COLS;c++){pinMode(colPins[c],INPUT);digitalWrite(colPins[c],HIGH);// Clear debounce countsfor(byter=0;r<NUM_ROWS;r++){debounceCount[r][c]=0;}}// Set all pins as inputsfor(byter=0;r<NUM_ROWS;r++){pinMode(rowPins[r],INPUT);}// Function key is NOT pressed// Initialise the keyboardif(serial_output){Serial.begin(9600);}else{Keyboard.begin();}}// LOOPvoidloop(){boolkeyPressed=false;for(byter=0;r<NUM_ROWS;r++){// Run through the rows, turn them onpinMode(rowPins[r],OUTPUT);digitalWrite(rowPins[r],LOW);for(bytec=0;c<NUM_COLS;c++){if(digitalRead(colPins[c])==LOW){// Increase the debounce countdebounceCount[r][c]++;// Has the switch been pressed continually for long enough?intcount=debounceCount[r][c];if(count==DEBOUNCE_VALUE){// First presskeyPressed=true;pressKey(r,c);}elseif(count>DEBOUNCE_VALUE){// Check for repeatscount-=DEBOUNCE_VALUE;if(count%REPEAT_DELAY==0){// Send repeatkeyPressed=true;pressKey(r,c);}}}else{// Not pressed; reset debounce countdebounceCount[r][c]=0;}}// Turn the row back offpinMode(rowPins[r],INPUT);}}voidpressKey(byter,bytec){// Send the keypressif(serial_output){Serial.print("|");Serial.print("\r\n");Serial.print("|");Serial.print(r);Serial.print(",");Serial.print(c);Serial.print(":");}bytekey=keyMap[r][c];if(serial_output){if(key>0){Serial.write(key);}}else{if(key>0)Keyboard.write(key);}}
Remember that you need a pro micro or leonardo, or another board with enough pins and a ATmega32U4 chip.
I try to do a simple unity example in the next weeks :) I am short in time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We have 26 free GPIO on a Raspberry, and they can be extented if needed. I am sure that is possible.
BUT raspberry is a complete other architecure. So you can not direct use the Arduino code from here for a raspberry.
The golden way is to use Raspberry 0,1,2 or 3 with a connected Arduino Nano in the DartBoard. (The space is there for it :) ).
Then u can connect keyboard to the raspberry, too. (for the zero u need a powered USB HUB, and a special GPIO Network card).
I am currently work on it. And show you my succees :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Andreas,
I add this sketch to the project, for any purpose.
I was pretty sure that the code from Arduino wouldn't be usable for a Rasp, but, it should be quite easy to write a piece of code for Rasp, don't you think ?
Whatever, the main issue with Arduino was to make a sketch loop that can detect a very small amount of time for the change of sate of a switch. As far as I can remember, a dart planting on a board is far faster than any keyboard capabilities to detect a closing switch.
But a soon as this issue is solved, it should be quite easy to write something for a Rasp ?
I have to buy one, one day.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i am not sure that a raspberry GPIO can handle the presses that fast without a Arduino.
the Atmega in the Arduino boards are cheap and do a good job.
We should stay on this little friends. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys, my name is Matthew, I apologize for intruding, for two days I began this project in mind and yesterday I installed everything on a center Cyberdine (http://www.cyberdine.hr/),collegato directly to a arduino in 16x4, delay added to the code to not have double hits and lowered the DEBOUNCE_VALUE to 1 ..
Then all worked perfectly in windows 7.
MI think I understood from the translation you want to use Arduino as a real USB keyboard with all the function keys.
With my old project I used arduino Leonardo in this way using the Arduino KEYCODE..tutti say they can not send keycode or at least not all, but if you are armed with patience just try the keycode 50 to 300 and ensured that buttons find them all.
A single flaw, it seems every operating system reads the codes in their own way, so the code will have win7, win 8 others and 10 others.
I have a small software found on the net to test areas and test the key code ..
tested and working with this project ([http://www.yoresupply.com/BallaTron5000])
I apologize but I had to understand the translated and then re-translate my message maybe some misunderstanding is understandable.
Greetings from Italy,
Matthew
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To be honest I did not really understood the purpose of faking a keyboard with the Arduino. But if someone could explain me I would be interested !
BTW, I am surprised and happy to discover this new project called BallaTRON ! Another great OpenSource project for playing darts ! As I can read, it fake a keyboard, maybe it can answer to my question above !
Unfortunately, this software runs on windows exclusively for now, I cannot try it.
Cheers to all !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey folks,
are you able to rewrite: https://sourceforge.net/p/pydarts/source/ci/master/tree/arduino_uno_config/arduino_uno_config_8x10_sample/arduino_uno_config_8x10_sample.ino
to a real keyboard output?
I will try to port it in c# unity3d
But to keep things easy, it would be nice to have the outputs as real keypresses.
Is keypad.h or keyboard.h helpfully?
I can use then a pro micro or an Leonardo as USB HID Interface thats identified as Keyboard.
I don't know how to do that for the moment...
Good luck for portage ! You'll need some ;)
This should do the trick! :)
Did you successfully tested it ?
Does it means that your arduino will be able to fake a Usb keyboard ?
Great !
On pro micro, or leonardo is an ATmega32U4, this chip have USB HID on Board.
I dont want to write the complete code new. So this is the easiest way to test some stuff :)
Ok here, is the tested sketch:
So if anybody need a real keyboard input for a dart matrix he can use:
Remember that you need a pro micro or leonardo, or another board with enough pins and a ATmega32U4 chip.
I try to do a simple unity example in the next weeks :) I am short in time.
Andreas,
Do you think that it would be possible, and interesting to use the input pins of a Raspberry instead of using an Arduino in the dart board ?
If we can connect the slicks to the rasp, we might be able to get rid of the computer , don't we ?
We have 26 free GPIO on a Raspberry, and they can be extented if needed. I am sure that is possible.
BUT raspberry is a complete other architecure. So you can not direct use the Arduino code from here for a raspberry.
The golden way is to use Raspberry 0,1,2 or 3 with a connected Arduino Nano in the DartBoard. (The space is there for it :) ).
Then u can connect keyboard to the raspberry, too. (for the zero u need a powered USB HUB, and a special GPIO Network card).
I am currently work on it. And show you my succees :)
Andreas,
I add this sketch to the project, for any purpose.
I was pretty sure that the code from Arduino wouldn't be usable for a Rasp, but, it should be quite easy to write a piece of code for Rasp, don't you think ?
Whatever, the main issue with Arduino was to make a sketch loop that can detect a very small amount of time for the change of sate of a switch. As far as I can remember, a dart planting on a board is far faster than any keyboard capabilities to detect a closing switch.
But a soon as this issue is solved, it should be quite easy to write something for a Rasp ?
I have to buy one, one day.
i am not sure that a raspberry GPIO can handle the presses that fast without a Arduino.
the Atmega in the Arduino boards are cheap and do a good job.
We should stay on this little friends. :)
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi guys, my name is Matthew, I apologize for intruding, for two days I began this project in mind and yesterday I installed everything on a center Cyberdine (http://www.cyberdine.hr/),collegato directly to a arduino in 16x4, delay added to the code to not have double hits and lowered the DEBOUNCE_VALUE to 1 ..
Then all worked perfectly in windows 7.
MI think I understood from the translation you want to use Arduino as a real USB keyboard with all the function keys.
With my old project I used arduino Leonardo in this way using the Arduino KEYCODE..tutti say they can not send keycode or at least not all, but if you are armed with patience just try the keycode 50 to 300 and ensured that buttons find them all.
A single flaw, it seems every operating system reads the codes in their own way, so the code will have win7, win 8 others and 10 others.
I have a small software found on the net to test areas and test the key code ..
tested and working with this project ([http://www.yoresupply.com/BallaTron5000])
I apologize but I had to understand the translated and then re-translate my message maybe some misunderstanding is understandable.
Greetings from Italy,
Matthew
Hi @Matthew, Hi @Andreas !
To be honest I did not really understood the purpose of faking a keyboard with the Arduino. But if someone could explain me I would be interested !
BTW, I am surprised and happy to discover this new project called BallaTRON ! Another great OpenSource project for playing darts ! As I can read, it fake a keyboard, maybe it can answer to my question above !
Unfortunately, this software runs on windows exclusively for now, I cannot try it.
Cheers to all !
The code above work for direct keyboard input, it is just a test for a unity project.