@gilshultz Here's the schematic
@Wawa It's the 5volt pro micro
@johnerrington
Thats because they are closer together.
The distance between the sensors didn't change.
This is what it originally looked like (minus the sensors of course)
DOes it STAY stuck if you remove the magnet altogether? Is there some iron nearby that could be magnetised?
I've added the pullup-resistors as seen in the schematic. Once I plug in the usb cable, one of the sensors is immediately shown as active (=LOW). The longer I leave the pro micro connected, the more sensors are shown as active, even without any magnets nearby.
Here's the code that I'm currently using, just in case:
#include <Joystick.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
4, 0, // Button Count, Hat Switch Count
false, false, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, false, // No rudder or throttle
false, false, false); // No accelerator, brake, or steering
void setup() {
// Initialize Button Pins
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
//pinMode(10, INPUT_PULLUP);
//pinMode(14, INPUT_PULLUP);
//pinMode(15, INPUT_PULLUP);
//pinMode(16, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Last state of the buttons
int lastButtonState[4] = {0,0,0,0};
int buttonMap[4] = {6,7,8,9};
// ButtonMap = 0, Pin 10 = UP
// ButtonMap = 1, Pin 15 = RIGHT
// ButtonMap = 2, Pin 16 = DOWN
// ButtonMap = 3, Pin 14 = LEFT
// ButtonMap = 4, Pin 9 = Button 1
// ButtonMap = 5, Pin 8 = Button 2
// ButtonMap = 6, Pin 7 = Button 3
// ButtonMap = 7, Pin 3 = Button 4
// ButtonMap = 8, Pin 2 = Button 5
// ButtonMap = 9, Pin 4 = Button 6
// ButtonMap = 10, Pin 20 = Select Button 1
// ButtonMap = 11, Pin 19 = Start Button 2
// ButtonMap = 12, Pin 5 = Other Button
// ButtonMap = 13, Pin 6 = Other Button
// ButtonMap = 14, Pin 18 = Other Button
// ButtonMap = 15, Pin 21 = Other Button
void loop() {
// Read pin values
for (int index = 0; index < 4; index++)
{
int currentButtonState = !digitalRead(buttonMap[index]);
if (currentButtonState != lastButtonState[index])
{
switch (index) {
case 0: // Black Button 1
Joystick.setButton(0, currentButtonState);
digitalWrite(0, HIGH);
break;
case 1: // Black Button 2
Joystick.setButton(1, currentButtonState);
break;
case 2: // Black Button 3
Joystick.setButton(2, currentButtonState);
break;
case 3: // Black Button 4
Joystick.setButton(3, currentButtonState);
break;
}
lastButtonState[index] = currentButtonState;
}
}
delay(10);
}