Генератор прошивки - пример скетча

#include <EEPROM.h>
 
bool started=false;
void setup() {
started=true;
Init();
Serial.begin(115200);
}
 
void loop() { 
Trigger1();
Trigger2();
Trigger3();
Trigger4();
Trigger5();
Trigger6();
 
}
 
//Action1, Action2
bool Trigger1Activated=false;
bool Trigger1(){
 if (Trigger1Activated){
  return true;
 }else
 { 
  if (Sensor1()){
   Trigger1Activated=true;
   Serial.println("Trigger1 Activated");
   Trigger1DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger1DoAction(){
Trigger1Activated=true;
//******************************************
Action1();
Action2();
 
//******************************************
}
//Action3
bool Trigger2Activated=false;
bool Trigger2(){
 if (Trigger2Activated){
  return true;
 }else
 { 
  if (Sensor2()){
   Trigger2Activated=true;
   Serial.println("Trigger2 Activated");
   Trigger2DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger2DoAction(){
Trigger2Activated=true;
//******************************************
Action3();
 
//******************************************
}
//Action4
bool Trigger3Activated=false;
bool Trigger3(){
 if (Trigger3Activated){
  return true;
 }else
 { 
  if (Sensor3()){
   Trigger3Activated=true;
   Serial.println("Trigger3 Activated");
   Trigger3DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger3DoAction(){
Trigger3Activated=true;
//******************************************
Action4();
 
//******************************************
}
//Action5
bool Trigger4Activated=false;
bool Trigger4(){
 if (Trigger4Activated){
  return true;
 }else
 { 
  if (Sensor4()){
   Trigger4Activated=true;
   Serial.println("Trigger4 Activated");
   Trigger4DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger4DoAction(){
Trigger4Activated=true;
//******************************************
Action5();
 
//******************************************
}
//Action13
bool Trigger5Activated=false;
bool Trigger5(){
 if (Trigger5Activated){
  return true;
 }else
 { 
  if (Trigger2()){
   Trigger5Activated=true;
   Serial.println("Trigger5 Activated");
   Trigger5DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger5DoAction(){
Trigger5Activated=true;
//******************************************
Action13();
 
//******************************************
}
//Action14, Action 15
bool Trigger6Activated=false;
bool Trigger6(){
 if (Trigger6Activated){
  return true;
 }else
 { 
  if (Sensor5()&Trigger5()){
   Trigger6Activated=true;
   Serial.println("Trigger6 Activated");
   Trigger6DoAction();
   return true;
  }
  return false;
 } 
 return false;
}
 
void Trigger6DoAction(){
Trigger6Activated=true;
//******************************************
Action14();
Action15();
 
//******************************************
}
 
 
//
bool Sensor1()
{
 int Sensor1Pin=41;
 pinMode(Sensor1Pin, INPUT_PULLUP);
 int sensorVal = digitalRead(Sensor1Pin);
 if (sensorVal == HIGH) {return true;}else{return false;}
}
 
//
bool Sensor2()
{
 int Sensor2Pin=39;
 pinMode(Sensor2Pin, INPUT_PULLUP);
 int sensorVal = digitalRead(Sensor2Pin);
 if (sensorVal == LOW) {return true;}else{return false;}
}
 
//
bool Sensor3()
{
 int Sensor3Pin=33;
 pinMode(Sensor3Pin, INPUT_PULLUP);
 int sensorVal = digitalRead(Sensor3Pin);
 if (sensorVal == LOW) {return true;}else{return false;}
}
 
//
bool Sensor4()
{
 int Sensor4Pin=35;
 pinMode(Sensor4Pin, INPUT_PULLUP);
 int sensorVal = digitalRead(Sensor4Pin);
 if (sensorVal == LOW) {return true;}else{return false;}
}
 
//
bool Sensor5()
{
 int Sensor5Pin=37;
 pinMode(Sensor5Pin, INPUT_PULLUP);
 int sensorVal = digitalRead(Sensor5Pin);
 if (sensorVal == LOW) {return true;}else{return false;}
}
 
 
//
void Action1()
{ 
bool debug=true;
//1bb0810d-b9c2-4170-8db9-8f39c6d7db54
 
 
 
 
 
//1bb0810d-b9c2-4170-8db9-8f39c6d7db54
  if (debug) {
    Serial.println("DoAction Action1");
  }
}
 
 
//
void Action2()
{ 
bool debug=true;
//946d3af0-944b-4aa3-8be8-0e692b12cf1a
 
 
 
Serial.println("pl5play 1.mp3");
 
 
 
//946d3af0-944b-4aa3-8be8-0e692b12cf1a
  if (debug) {
    Serial.println("DoAction Action2");
  }
}
 
 
//
void Action3()
{ 
bool debug=true;
//9c4df9ef-770d-4548-8a88-2611f937f6bb
 
 
 
//9c4df9ef-770d-4548-8a88-2611f937f6bb
  if (debug) {
    Serial.println("DoAction Action3");
  }
}
 
 
//
void Action4()
{ 
bool debug=true;
//00269d9d-f19b-4597-96e0-fb02ca2908cf
 
 
 
//00269d9d-f19b-4597-96e0-fb02ca2908cf
  if (debug) {
    Serial.println("DoAction Action4");
  }
}
 
 
//
void Action5()
{ 
bool debug=true;
//7fc31f0c-a692-4ad2-8856-98d31f847859
 
 
 
 
//7fc31f0c-a692-4ad2-8856-98d31f847859
  if (debug) {
    Serial.println("DoAction Action5");
  }
}
 
 
//
void Action13()
{ 
bool debug=true;
//2bb7297f-2af0-4d88-9168-7fd71e3308b0
 
 
 
 
 
 
//2bb7297f-2af0-4d88-9168-7fd71e3308b0
  if (debug) {
    Serial.println("DoAction Action13");
  }
}
 
 
//
void Action14()
{ 
bool debug=true;
//bb45c5d7-48e2-4ed0-958e-308692c72347
 
 
 
 
//bb45c5d7-48e2-4ed0-958e-308692c72347
  if (debug) {
    Serial.println("DoAction Action14");
  }
}
 
 
//
void Action15()
{ 
bool debug=true;
//624c11db-c190-4165-8f6a-0744cec4ac09
 
 
 
Serial.println("playsound win.mp3");
 
 
//624c11db-c190-4165-8f6a-0744cec4ac09
  if (debug) {
    Serial.println("DoAction Action15");
  }
}
 
 
//Инициализация
void Init()
{ 
bool debug=true;
//ae2557dc-f776-45a6-8097-a26dfd5f9f52
 
 
 
 
//ae2557dc-f776-45a6-8097-a26dfd5f9f52
  if (debug) {
    Serial.println("DoAction Init");
  }
}
 
Отправить комментарий

Популярные сообщения