diff --git a/consoleModuleArdByte.ino b/consoleModuleArdByte.ino new file mode 100644 index 0000000..99b9411 --- /dev/null +++ b/consoleModuleArdByte.ino @@ -0,0 +1,108 @@ +#include +#include +#include +#include + +#include // Добавляем необходимые библиотеки +#include "DHT.h" + +#define SizeRegisterModules 20 + +DHT dht(A0, DHT11); + +int IDarg = 0; +String ParsedCommand[SizeRegisterModules]; + +int adding; + +void ShowError(String errorMessage){ + Serial.println("Error: \n "+errorMessage); +} + +void ShowMessage(String type, String Message){ + Serial.println("["+type+"] "+Message); +} + +char getCharCommand(){ + if (Serial.available() > 0) { + char cmdraw = Serial.read(); + if (cmdraw > 0) return cmdraw; + } + return '?'; +} + +void mainL(String *args){ + /*if(args[0] == "RGB") { + if(args[1] == "lamp") { + if(args[2] == "RED") { + if(args[3] == "ON") { + digitalWrite(4,HIGH); + } else { + digitalWrite(4,LOW); + } + } + } + }*/ + if(args[0] == "data") { + if(args[1] == "get") { + if(args[2] == "temp") { + float t = dht.readTemperature(); + Serial.print("температура:"); + Serial.println(t); + } + if(args[2] == "vlag") { + float h = dht.readHumidity(); + Serial.print("Влажность:"); + Serial.println(h); + } + if(args[2] == "more") { + if(args[3] == "temp") { + int i; + String prom = args[5]; + int data = prom.toInt(); + prom = args[4]; + int timer = prom.toInt(); + timer = timer*1000; + int data2 = data + 1; + for(i=1;i"); +} + +void loop() { + char CharCommand = getCharCommand(); + if (CharCommand != ';' && CharCommand != '?'){ + Serial.print(CharCommand); + if (CharCommand == ' '){ + IDarg++; + }else{ + ParsedCommand[IDarg] += CharCommand; + } + }else if(CharCommand == ';'){ + Serial.println(" "); + mainL(ParsedCommand); + IDarg = 0; + for (int i = 0;i<=20;i++) {ParsedCommand[i]="";} + Serial.print(">"); + } +}