If # takes only the lines with the correct number of chars (avoids incorrec readins)īutton_A=$(echo $LINE | cut -c2) # -c2 indicates the position of the button value in the line sent by the arduino, in my case the button A is on the second position. <- to be filled with the other buttons, and with the keyboard touch you want to use Stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb -icanon min 1 time 1īutton_A=1 # State of the button A (1 = released, 0 = pressed) ![]() On the linux side, I create a bash script : #!/bin/bash This will send to serial something like that: 111111111 <- no button is pressedġ11011111 <- button attached to D5 is pressedġ10011111 <- button attached to D4 is also pressedġ10011111 <- buttton attached to D4 is releasedġ11111111 <- buttton attached to D5 is released Stat = digitalRead(Pin) //Stat is 0 when the button is pressed, 1 else PinMode(i, INPUT_PULLUP) // defines all pins used as Pullups So, yes, the buttons will act as a key of a keyboard, rather than exactly a joystick, but that should be ok for old consoles emulation.Īrduino: int Pin= for each pin where a button is attached to, i use pinmode(xxx,input_pull).I'm using linux, but I'm sure you will find the equivalent for other systems. ![]() Hi all, this is an old post, but as I went through it when I was looking a solution for a similar issue, here is what I do:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |