#define B_button_pin 1
#define B_led_pin 20
#define R_button_pin 2
#define R_led_pin 18

void setup() {
  // initialize digital pins for LEDS as an output and buttons as INPUTS
  pinMode(B_led_pin, OUTPUT);
  pinMode(B_button_pin, INPUT_PULLUP);
  pinMode(R_led_pin, OUTPUT);
  pinMode(R_button_pin, INPUT_PULLUP);
  Serial1.begin(115200);  // opens serial port, sets data rate to 115200 bps
  Serial1.println("Input B to turn blue LED and R to turn red LED");
}

bool B_button_up = true; // bool holds one of two values, true or false
bool R_button_up = true;


// the setup function runs once when you press reset or power the board
void loop() {
  if (Serial1.available()) {
    char comdata = char(Serial1.read());
    if (comdata == 'B') {
      digitalWrite(B_led_pin, HIGH);
      Serial1.print("you typed: ");
      Serial1.println(comdata);
      delay(500);
      digitalWrite(B_led_pin, LOW);
    }
    if (comdata == 'R') {
      digitalWrite(R_led_pin, HIGH);
      Serial1.print("you typed: ");
      Serial1.println(comdata);
      delay(500);
      digitalWrite(R_led_pin, LOW);
    }
  }
  // Check Blue Button
  if (digitalRead(B_button_pin) == LOW && B_button_up) {
    digitalWrite(B_led_pin, HIGH);
    Serial1.println("blue button down");
    B_button_up = false;
  }
  if (digitalRead(B_button_pin) == HIGH && !B_button_up) {
    digitalWrite(B_led_pin, LOW);
    Serial1.println("blue button up");
    B_button_up = true;
  }
  // Check Red Button
  if (digitalRead(R_button_pin) == LOW && R_button_up) {
    digitalWrite(R_led_pin, HIGH);
    Serial1.println("red button down");
    R_button_up = false;
  }
  if (digitalRead(R_button_pin) == HIGH && !R_button_up) {
    digitalWrite(R_led_pin, LOW);
    Serial1.println("red button up");
    R_button_up = true;
  }
  delay(50); // Simple debounce delay for button presses
}
$abcdeabcde151015202530354045505560fghijfghij
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT