// # Esp8266 & Arduino uno
#include <Arduino.h>
#include <vector>
#ifdef ESP826
#define relay1 D1
#define relay2 D2
#elif defined(ESP32)
#define relay1 2
#define relay2 4
#else
#define relay1 2
#define relay2 3
#endif
// class Lampu{
// private:
// int pin;
// int kl = 0;
// std::vector<int> jw;
// public:
// Lampu(int pin, std::vector<int> jw){
// this->pin = pin;
// this->jw = jw;
// pinMode(this->pin, OUTPUT);
// }
// void run(boolean isUpsite = false){
// digitalWrite(this->pin, isUpsite ? (!this->jw[this->kl]) : !(!this->jw[this->kl]));
// this->kl++;
// if(this->kl > sizeof(this->jw) / sizeof(this->jw[0])) this->kl = 0;
// }
// };
// std::vector<int> relay1jw = {1, 1, 1, 0, 0, 0, 0};
// std::vector<int> relay2jw = {1, 1, 1, 1, 1, 1, 0, 0, 0};
int relay1jw[] = {1, 1, 1, 0, 0, 0, 0};
int relay2jw[] = {1, 1, 1, 1, 1, 1, 0, 0, 0};
int relay1kl = 0;
int relay2kl = 0;
// Lampu lamp1(relay1, relay1jw);
// Lampu lamp2(relay2, relay2jw);
void run(int relayPin, int *relaykl, int relayjw[], bool isUpside = false) {
bool status = isUpside ? (!relayjw[*relaykl]) : !(!relayjw[*relaykl]);
digitalWrite(relayPin, status);
*relaykl = *relaykl + 1;
if (*relaykl >= sizeof(relayjw) / sizeof(relayjw[0])) *relaykl = 0;
}
void setup(){
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
}
void loop(){
run(relay1, &relay1kl, relay1jw, false);
run(relay2, &relay2kl, relay2jw, true);
// lamp1.run();
// lamp2.run(true);
// digitalWrite(relay1, (!relay1jw[relay1kl]));
// digitalWrite(relay2, !(!relay2jw[relay2kl]));
// relay1kl++;
// relay2kl++;
// if(relay1kl > sizeof(relay1jw) / sizeof(relay1jw[0])) relay1kl = 0;
// if(relay2kl > sizeof(relay2jw) / sizeof(relay2jw[0])) relay2kl = 0;
delay(800);
}