I am totally new.
I Want to control PC volume (like volume up/Down?mute) and also numeric 0 to 9, ( . ) [Dot], subtract, divide, multiply, add, RETURN.
All are ok...
But problem is, I don't know how to add the "Volume key" and "RETURN" key.
mine full code here, anyone can edit this?
In my code, RGB not mendetory.
> #include <Keyboard.h>
> #include <Adafruit_NeoPixel.h>
>
> #define ledCount 5 //how many LEDs are there
> #define ledPin 21 //which pin are they connected to
>
> int longPressDelay = 350; //customizable keyboard values
> int spamSpeed = 15;
>
> byte inputs[] = {2,3,4,5,}; //declaring inputs and outputs
> #define inCount sizeof(inputs)/sizeof(inputs[0])
> byte outputs[] = {6,7,8,9,10};
> #define outCount sizeof(outputs)/sizeof(outputs[0])
>
> char layout[outCount][inCount] = { //layout grid for characters (adjust if your grid is not 4x4)
> {'VOL+', 'VOL-', 'MUTE', 'POWER_BUTTON'},
> {'7', '8', '9', '*'},
> {'4', '5', '6', '-'},
> {'1', '2', '3', '+'},
> {'0', '.', '/', 'RENTER'},
> };
>
> int keyDown[outCount][inCount];
> bool keyLong[outCount][inCount];
>
> Adafruit_NeoPixel strip = Adafruit_NeoPixel(ledCount, ledPin, NEO_GRB + NEO_KHZ800);
>
> void setup(){
>
> for(int i=0; i<outCount; i++){ //declaring all the outputs and setting them high
> pinMode(outputs[i],OUTPUT);
> digitalWrite(outputs[i],HIGH);
> }
> for(int i=0; i<inCount; i++){ //declaring all the inputs and activating the internal pullup resistor
> pinMode(inputs[i],INPUT_PULLUP);
> }
>
> Serial.begin(9600); //establishing Serial link and initializing keyboard
> Serial.println("Connected");
> Keyboard.begin();
>
> strip.begin(); //initializing LEDs and setting them all to white
>
> //------------------------------------------------
> // put your initial LED color configuration here, e.g. this:
>
> for (int i = 0; i<ledCount; i++){
> strip.setPixelColor(i,50,50,50);
> }
>
> //------------------------------------------------
>
> strip.show();
> }
>
> //Main loop going through all the keys, then waiting 0.5ms
> void loop() {
> for (int i=0; i<outCount; i++)
> {
> digitalWrite(outputs[i],LOW); //setting one row low
> delayMicroseconds(5); //giving electronics time to settle down
>
> for(int j=0; j<inCount; j++)
> {
> if(digitalRead(inputs[j]) == LOW)
> {
> keyPressed(i,j); //calling keyPressed function if one of the inputs reads low
> }
> else if(keyDown[i][j] != 0) //resetting the key if it is not pressed any more
> {
> resetKey(i,j);
> }
> }
>
> digitalWrite(outputs[i],HIGH);
> delayMicroseconds(500); //setting the row high and waiting 0.5ms until next cycle
> }
> }
>
> //if a key is pressed, this Funtion is called and outputs to serial the key location, it also sends the keystroke if not already done so
> void keyPressed(int row, int col){
> Serial.print("Output: ");
> Serial.print(row);
> Serial.print(" Input: ");
> Serial.print(col);
> Serial.print(" ");
> Serial.println(layout[row][col]);
>
> if(keyDown[row][col]==0){ //if the function is called for the first time for this key
> Keyboard.write(layout[row][col]);
> }
> else if(keyLong[row][col] && keyDown[row][col] > spamSpeed){ //if the key has been held long enough to warrant another keystroke set
> Keyboard.write(layout[row][col]);
> keyDown[row][col] = 1;
> }
> else if(keyDown[row][col] > longPressDelay){ //if the key has been held for longer that longPressDelay, it switches into spam mode
> keyLong[row][col] = true;
> }
>
> keyDown[row][col]++;
> }
>
> void resetKey(int row, int col){ //resetting the variables after key is released
> keyDown[row][col] = 0;
> keyLong[row][col] = false;
> }
>