matheynen [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=25088 Joystick shield <p>I, everyone.<br /> I have a new pico-8 experience now.<br /> I use the sparkfun joystick shield with an arduino leonardo.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/25088/joystick.jpg" width=400 height=300 alt="" /> <p>Here is the code.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> #include &lt;Keyboard.h&gt; char btn0 = 3, btn1 = 4, btn2 = 5, btn3 = 6; void setup() { pinMode(btn0, INPUT); digitalWrite(btn0, HIGH); pinMode(btn1, INPUT); digitalWrite(btn1, HIGH); pinMode(btn2, INPUT); digitalWrite(btn2, HIGH); pinMode(btn3, INPUT); digitalWrite(btn3, HIGH); Keyboard.begin(); } void loop() { if (digitalRead(btn0) == LOW) Keyboard.print('x'); if (digitalRead(btn1) == LOW) Keyboard.print('c'); if (digitalRead(btn2) == LOW) Keyboard.print('w'); //z but I'm on azerty board, not qwerty if (digitalRead(btn3) == LOW) Keyboard.print('v'); if (analogRead(0) &gt; 524) Keyboard.write(215); else if (analogRead(0) &lt; 500) Keyboard.write(216); if (analogRead(1) &gt; 524) Keyboard.write(218); else if (analogRead(1) &lt; 500) Keyboard.write(217); delay(10);//adapt it with the game } </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>You have to change delay depends on which game you play,<br /> with Celeste 10 is perfect.</p> https://www.lexaloffle.com/bbs/?tid=31487 https://www.lexaloffle.com/bbs/?tid=31487 Sat, 07 Jul 2018 12:22:26 UTC