Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void callback(char* topic, byte* payload, unsigned int length) {
- String topicStr = topic;
- if (topicStr == "domek/schodiste/set/")
- {
- // Deserializace JSON
- DeserializationError error = deserializeJson(doc, payload);
- if (error) {
- Serial.print(F("deserializeJson() failed: "));
- Serial.println(error.f_str());
- return;
- }
- int smer = doc["smer"];
- int rychlost = doc["rychlost"];
- int cas = doc["cas"];
- int intenzita = doc["intenzita"];
- Serial.print("Směr: ");
- Serial.println(smer);
- Serial.print("Rychlost: ");
- Serial.println(rychlost);
- Serial.print("Doba svitu: ");
- Serial.println(cas);
- int schod=0;
- if (smer==1){ //smer zespoda nahoru
- for (int i = 0; i < 15; i++) { //rozsvitit
- schod=i+1;
- if (int(doc["schody"][i])==1){
- rozsvit(schod,intenzita);
- delay (rychlost);
- }
- }
- delay (cas); //doba svitu
- for (int i = 0; i < 15; ++i) { //zhasnout
- schod=i+1;
- zhasni(schod);
- delay (rychlost);
- }
- }else if (smer==2){ //smer zhora dolu
- for (int j = 14; j > -1; j--) {//rozsvitit
- schod=j+1;
- if (int(doc["schody"][j])==1){
- rozsvit(schod,intenzita);
- delay (rychlost);
- }
- }
- delay (cas); //doba svitu
- for (int j = 14; j > -1; j--) {//zhasnout
- schod=j+1;
- zhasni(schod);
- delay (rychlost);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement