Log In  

I, everyone.
I have a new pico-8 experience now.
I use the sparkfun joystick shield with an arduino leonardo.

Here is the code.

#include <Keyboard.h>
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) > 524) Keyboard.write(215);
  else if (analogRead(0) < 500) Keyboard.write(216);
  if (analogRead(1) > 524) Keyboard.write(218);
  else if (analogRead(1) < 500) Keyboard.write(217);
  delay(10);//adapt it with the game
}

You have to change delay depends on which game you play,
with Celeste 10 is perfect.

P#53985 2018-07-07 12:22 ( Edited 2018-07-08 06:24)

Cool! Glad to be reminded of the Leonardo.

I wonder if Keyboard.h is a potential path forward for MIDI note entry in the music editor (with GPIO pins connected to a MIDI controller via serial). I have a Teensy lying around somewhere, maybe I'll try it out. https://playground.arduino.cc/Main/MIDILibrary

P#53999 2018-07-08 02:24 ( Edited 2018-07-08 06:32)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-20 12:22:17 | 0.006s | Q:11