code formatting whe...
Clear all

code formatting when posting  


Active Member
Joined: 6 months ago
Posts: 12
2020-02-28 1:34 pm  


String answer;
String msg = "Do you want me to light the red, yellow, or blue LED?";

#define red 22
#define blue 24
#define green 26

void setup() {
  // put your setup code here, to run once:
  pinMode(red, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(green, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly:
  while (Serial.available() == 0) {

  answer = Serial.readString();

  if (answer == "red") {
    digitalWrite (red, HIGH);
    digitalWrite (blue, LOW);
    digitalWrite (green, LOW);
  if (answer == "blue") {
    digitalWrite (blue, HIGH);
    digitalWrite (red, LOW);
    digitalWrite (green, LOW);
  if (answer == "green") {
    digitalWrite (green, HIGH);
    digitalWrite (red, LOW);
    digitalWrite (blue, LOW);



My skills include being able to move slowly forward in time, and if I really concentrate, I can sometimes tell what I'm thinking.