SNES Control

I’m trying to make an adapter using Arduino Uno, to connect my SNES Control at my USB port. I’m having some troubles with Serial.print inside the if().
Here’s my code:

#define CLOCK 3
#define STROBE 2
#define DATA 4

#define SNES_B       0b0000000000000001
#define SNES_Y       0b0000000000000010
#define SNES_SELECT  0b0000000000000100
#define SNES_START   0b0000000000001000
#define SNES_UP      0b0000000000010000
#define SNES_DOWN    0b0000000000100000
#define SNES_LEFT    0b0000000001000000
#define SNES_RIGHT   0b0000000010000000
#define SNES_A       0b0000000100000000
#define SNES_X       0b0000001000000000
#define SNES_L       0b0000010000000000
#define SNES_R       0b0000100000000000

int x;

unsigned int getSNESbuttons(int clock, int strobe, int data) {
    Mapping from
    | B | Y | Select | Start | Up | Down | Left | Right | A | X | L | R | N/A | N/A | N/A | N/A |
  unsigned int fromController = 0b0000000000000000, i;

  //Do the strobe to start reading button values
  digitalWrite(strobe, HIGH);
  digitalWrite(strobe, LOW);

  delayMicroseconds(6); //Wait for controller to start sending the button values 
  for (i = 0; i < 16; i++) {
    fromController |= digitalRead(data) << i; //read the value, shift it and store it as a bit on fromController

    //More one cycle on the clock pin...
    digitalWrite(clock, HIGH);
    digitalWrite(clock, LOW);

  //return the read bits (16)
  return ~fromController;

void setup() {
  pinMode(CLOCK, OUTPUT);
  pinMode(STROBE, OUTPUT);
  pinMode(DATA, INPUT);

unsigned int buttonsPressed;
void loop() {
  buttonsPressed = getSNESbuttons(CLOCK, STROBE, DATA);
  if (buttonsPressed & SNES_UP) {
    Serial.print ("w");
  else if (buttonsPressed & SNES_DOWN) {
    Serial.print ("s");
  /* and continues.. */
  else {

  if (buttonsPressed & SNES_A) {
  else {


If anyone could help me, I’ll aprecciate.


What problem with the prints?


I'm having some troubles

but I'm not telling what they are

Edit: is it perhaps that you don't really want all those "else"s?

The prints isn't working. Inside the serial monitor is all blank when I press the buttons.

You probably don't want the if-else at all, unless you never want to detect multiple button presses.

Add a print statement after the pulseIn() to see what value you are getting for buttonsPressed.