Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "arduino_secrets.h"
- #include "thingProperties.h"
- String out = "Terjadwal:";
- String outa = "0";
- String outb = "0";
- String outc = "0";
- String outd = "0";
- bool terjadwal = true;
- void setup() {
- pinMode(D1, OUTPUT);
- pinMode(D2, OUTPUT);
- pinMode(D3, OUTPUT);
- pinMode(D4, OUTPUT);
- pinMode(D5, OUTPUT);
- pinMode(D6, OUTPUT);
- pinMode(D7, OUTPUT);
- pinMode(D8, OUTPUT);
- digitalWrite(D1, HIGH);
- digitalWrite(D2, HIGH);
- digitalWrite(D3, HIGH);
- digitalWrite(D4, HIGH);
- digitalWrite(D5, HIGH);
- digitalWrite(D6, HIGH);
- digitalWrite(D7, HIGH);
- digitalWrite(D8, HIGH);
- Serial.begin(9600);
- delay(1500);
- initProperties();
- ArduinoCloud.begin(ArduinoIoTPreferredConnection);
- setDebugMessageLevel(2);
- ArduinoCloud.printDebugInfo();
- }
- void loop() {
- ArduinoCloud.update();
- if (a.isActive()) {
- if (terjadwal) {
- digitalWrite(D1, LOW);
- outa = "1";
- }
- } else {
- if (terjadwal) {
- digitalWrite(D1, HIGH);
- outa = "0";
- }
- }
- if (b.isActive()) {
- if (terjadwal) {
- digitalWrite(D2, LOW);
- outb = "1";
- }
- } else {
- if (terjadwal) {
- digitalWrite(D2, HIGH);
- outb = "0";
- }
- }
- if (c.isActive()) {
- if (terjadwal) {
- digitalWrite(D3, LOW);
- outc = "1";
- }
- } else {
- if (terjadwal) {
- digitalWrite(D3, HIGH);
- outc = "0";
- }
- }
- if (d.isActive()) {
- if (terjadwal) {
- digitalWrite(D4, LOW);
- outd = "1";
- }
- } else {
- if (terjadwal) {
- digitalWrite(D4, HIGH);
- outd = "0";
- }
- }
- out1 = out + outa + "." + outb + "." + outc + "." + outd;
- }
- void onAChange() {
- }
- void onBChange() {
- }
- void onCChange() {
- }
- void onDChange() {
- }
- void onOut1Change() {
- if (out1 == "T" || out1 == "t") {
- terjadwal = true;
- out = "Terjadwal:";
- }
- if (out1 == "M" || out1 == "m") {
- terjadwal = false;
- out = "Manual:";
- }
- if (!terjadwal) {
- if (out1 == "A1" || out1 == "a1" || out2 == "V" || out2 == "v") {
- digitalWrite(D1, LOW);
- outa = "1";
- }
- if (out1 == "A0" || out1 == "a0" || out2 == "X" || out2 == "x") {
- digitalWrite(D1, HIGH);
- outa = "0";
- }
- if (out1 == "B1" || out1 == "b1" || out2 == "V" || out2 == "v") {
- digitalWrite(D2, LOW);
- outb = "1";
- }
- if (out1 == "B0" || out1 == "b0" || out2 == "X" || out2 == "x") {
- digitalWrite(D2, HIGH);
- outb = "0";
- }
- if (out1 == "C1" || out1 == "c1" || out2 == "V" || out2 == "v") {
- digitalWrite(D3, LOW);
- outc = "1";
- }
- if (out1 == "C0" || out1 == "c0" || out2 == "X" || out2 == "x") {
- digitalWrite(D3, HIGH);
- outc = "0";
- }
- if (out1 == "D1" || out1 == "d1" || out2 == "V" || out2 == "v") {
- digitalWrite(D4, LOW);
- outd = "1";
- }
- if (out1 == "D0" || out1 == "d0" || out2 == "X" || out2 == "x") {
- digitalWrite(D4, HIGH);
- outd = "0";
- }
- }
- out1 = out + outa + "." + outb + "." + outc + "." + outd;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement