// Need to define pins for servos

#include <Keypad.h>
#include <Servo.h>

String memory = "";

Servo B; // Create a "Servo" object called "B"
Servo A; // Create a "Servo" object called "A"
Servo G; // Create a "Servo" object called "G"
Servo nF; // Create a "Servo" object called "F"
Servo E; // Create a "Servo" object called "E"
Servo D; // Create a "Servo" object called "D"
Servo C; // Create a "Servo" object called "C"

float off = 0.0; // Variable where the arm's position will be stored (in degrees)
float on = 90.0; // Variable used for the arm's position step

/* Keypad setup */
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 3;
byte rowPins[KEYPAD_ROWS] = {22, 21, 20, 19};
byte colPins[KEYPAD_COLS] = {18, 17, 16};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
  {'A', 'B', 'C'},
  {'D', 'E', 'F'},
  {' ', 'G', ' '},
  {'b', '=', '#'}
};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);

void setup() {
  // put your setup code here, to run once:

  B.attach(2); // Attach the B servo to the pin 2
  B.write(off); // Initialize the B arm's position to 0 (rightmost)

  A.attach(3); 
  A.write(off); 

  G.attach(4); 
  G.write(off); 

  nF.attach(5); 
  nF.write(off); 

  E.attach(6); 
  E.write(off); 

  D.attach(7); 
  D.write(off); 

  C.attach(8); 
  C.write(off); 

  Serial1.begin(115200);
  Serial1.println("Type in a note!");
}

void loop() {
  // put your main code here, to run repeatedly:

  char key = keypad.getKey();

  if (key != NO_KEY) {
    switch (key) {
      case 'A': 
        Serial1.println("A");
        B.write(on);
        A.write(on);
        G.write(off);
        nF.write(off);
        E.write(off);
        D.write(off);
        C.write(off);
        break;
      case 'B': 
        Serial1.println("B");
        B.write(on);
        A.write(off);
        G.write(off);
        nF.write(off);
        E.write(off);
        D.write(off);
        C.write(off);
        break;
      case 'C': 
        Serial1.println("C");
        B.write(off);
        A.write(on);
        G.write(off);
        nF.write(off);
        E.write(off);
        D.write(off);
        C.write(off);
        break;
      case 'D': 
        Serial1.println("D");
        B.write(on);
        A.write(on);
        G.write(on);
        nF.write(on);
        E.write(on);
        D.write(on);
        C.write(off);
        break;
      case 'E': 
        Serial1.println("E");
        B.write(on);
        A.write(on);
        G.write(on);
        nF.write(on);
        E.write(on);
        D.write(off);
        C.write(off);
        break;
      case 'F': 
        Serial1.println("F");
        B.write(on);
        A.write(on);
        G.write(on);
        nF.write(on);
        E.write(off);
        D.write(off);
        C.write(off);
        break;
      case 'G': 
        Serial1.println("G");
        B.write(on);
        A.write(on);
        G.write(on);
        nF.write(off);
        E.write(off);
        D.write(off);
        C.write(off);
        break;
    }
  }
  //  if (key != NO_KEY) {
  //    Serial1.println(key);
  //    memory = memory + key;
  //  }
  
  //delay(1000); // this speeds up the simulation
  //String memory = "";
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
keypad1:R1
keypad1:R2
keypad1:R3
keypad1:R4
keypad1:C1
keypad1:C2
keypad1:C3
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
servo1:GND
servo1:V+
servo1:PWM
servo2:GND
servo2:V+
servo2:PWM
servo3:GND
servo3:V+
servo3:PWM
servo4:GND
servo4:V+
servo4:PWM
servo5:GND
servo5:V+
servo5:PWM
servo6:GND
servo6:V+
servo6:PWM
servo7:GND
servo7:V+
servo7:PWM
servo8:GND
servo8:V+
servo8:PWM
servo9:GND
servo9:V+
servo9:PWM
servo10:GND
servo10:V+
servo10:PWM