fabianmoronzirfas
6/12/2015 - 9:50 AM

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

}