Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAY button doesn't work #332

Open
ERREberto opened this issue Nov 23, 2024 · 1 comment
Open

PLAY button doesn't work #332

ERREberto opened this issue Nov 23, 2024 · 1 comment

Comments

@ERREberto
Copy link

ERREberto commented Nov 23, 2024

Hi, every button of this program work except for the play button

#include <Arduino.h>
#include <BleKeyboard.h>
BleKeyboard bleKeyboard;

const int volup = 26 ;
const int voldown = 27;
const int play = 12;
const int next = 14;
const int prev = 13;

const int ledPin = 15;
int luce = 0;


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(volup, INPUT_PULLDOWN);  
  pinMode(voldown, INPUT_PULLDOWN);
  pinMode(play, INPUT_PULLDOWN);  
  pinMode(next, INPUT_PULLDOWN);
  pinMode(prev, INPUT_PULLDOWN);
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleKeyboard.begin();
}

void loop() {
  luce = analogRead(4);

  if(luce < 1000){
    digitalWrite(ledPin, HIGH);
  }
  else{
    digitalWrite(ledPin, LOW);
  }

  if(bleKeyboard.isConnected()) {

    if(digitalRead(volup)== HIGH){
      Serial.println("VOLUME UP");
      bleKeyboard.write(KEY_MEDIA_VOLUME_UP);
      delay(500);
    }

    else if(digitalRead(voldown)== HIGH){
      Serial.println("VOLUME DOWN");
      bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN);
      delay(500);
    }
    
    else if(digitalRead(play)== HIGH){
      Serial.println("PLAY or PAUSE the music");
      bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
      delay(500);
    }
    
    else if(digitalRead(next)== HIGH){
      Serial.println("Next track");
      bleKeyboard.write(KEY_MEDIA_NEXT_TRACK);
      delay(500);
    }
    
    else if(digitalRead(prev)== HIGH){
      Serial.println("previous track ");
      bleKeyboard.write(KEY_MEDIA_PREVIOUS_TRACK);
      delay(500);
    }
  }
}

I tried it on my phone and on my pc (WINDOWS 11) but the play button is the only one which isn't working on both. It doesn't even get written in the serial monitor.

@Phr3d13
Copy link

Phr3d13 commented Dec 16, 2024

Could it be the pin you're using? (have no idea, just trying a shot in the dark as a random helpful passerby)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants