Search the Community
Showing results for tags 'joystick'.
-
I'm a newbie trying out the Gameduino samples and having a problem with my joystick, which I think is a clone of the old Atari 2600 style. When I run the joytest sample my left, right, and back work OK, but the 'forward' direction gets triggered by the orange button, and moving the stick forward has no effect. I've tried a few different pin numbers at random without any success. In trying to debug this I am struggling to understand how the pins in the code below relate to the pin numbers in the hardware guide. http://papilio.cc/index.php?n=Papilio.ClassicComputingShield#joystick void loop(){ GD.putstr(40, 10, digitalRead(5) ? "-" : "F"); // maps to my orange button GD.putstr(40, 20, digitalRead(6) ? "-" : "D"); // works GD.putstr(35, 15, digitalRead(7) ? "-" : "L"); // works GD.putstr(45, 15, digitalRead(8) ? "-" : "R"); // works //GD.putstr(17, 24, digitalRead(2) ? "-" : "S"); // always on (if I un-comment this) Any insights appreciated, Rupert
-
I am coding in Verilog. I am trying to use the MicroJoystick installed on LogicStartMegaWing, the shield with Papilio-One 500k (my FPGA board). I have to do simple tasks like increment or decrement a reg variable on different movements of the joystick. Initially I was running the above code in an alwaya @ (SWITCH) block i.e. the block will be running whenever there is a movement in joystick (on this board joystick shares the pins with five switches). This led to complete loss of control of the cursor on the VGA display (very fast multiple increments or decrements), even on slightest movement of the joystick. Then I ran the same code in an always @ (slowclk) block where 'slowclk' is a 1Hz clock. This led to improvement as there were finite, slower increments or decrements. However, the problem is not completely resolved i.e. on one move of the joystick there are multiple increments to the reg. How can I remove this debounce from the input through the joystick? Need some help on this. I am also putting my code to generate the slowclk and to use the joystick. /////////////// module Slowclock( input clk_25, output reg slowclk ); reg [63:0] i; parameter delay = 12500000; initial begin slowclk = 0; i = 64'd0; end always @ (posedge clk_25) begin if (i < delay) i= i+1; else begin i = 64'd0; slowclk = ~slowclk; end end endmodule ///////////// always @ (slowclk) begin if (SWITCH[0]==0) if (I==0) I <= 3'd5; else I <= I - 1; if (SWITCH1]==0) if (I==5) I <= 3'd0; else I <= I+1; if (SWITCH[3]==0) if (J==5) J <= 3'd0; else J <= J + 1; if (SWITCH[4]==0) if (J==0) J <= 3'd5; else J <= J - 1; end //////////////