c_cpp switch_scenarios.ino

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp switch_scenarios.ino相关的知识,希望对你有一定的参考价值。


int scenarioSelector = 10000;

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop() {


  if (Serial.available() > 0) {
    char key = Serial.read();

    if (key == '0') {
      scenarioSelector = 0;
      Serial.println("selected Scenario 0");

    } else if (key == '1') {
      scenarioSelector = 1;
      Serial.println("selcted Scenario 1");

    } else if (key == '2') {
      scenarioSelector = 2;
      Serial.println("seected Scenario 2");

    }

  }





  switch (scenarioSelector) {
    case 0:


      scenario0();




      break;
    case 1:


      Serial.println("in Scenario 1");



      break;
    case 2:


      Serial.println("in Scenario 2");

      break;

    case 3:

      break;

  }
}


void scenario0() {
  Serial.println("in Scenario 0");
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);

  // do something onyl with the LED
}
void scenario1() {

  // do something with LED and LDR

}

以上是关于c_cpp switch_scenarios.ino的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 127.单词阶梯

c_cpp MOFSET

c_cpp MOFSET

c_cpp 31.下一个排列

c_cpp string→char *

c_cpp 54.螺旋矩阵