Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Cara koneksi ESP32R4 - USB TTL
- * Pastikan RXD - RXD
- * TXD - TXD
- * GND - GND
- * ESP32_PIN - No Connection ( ikut 3.3V dari Alat). Alat dari Power supply
- * ESP32_PIN - 3.3V - Cabut Penguhubung 3.3V ke ESP32_PIN. Power Supply mati
- */
- /* Cara Download
- * 1. Klik Tombol Download di Arduino IDE
- * 2. Bersamaan Itu Tekan dan Tahan tombol Rst dan Prog di alat
- * 3. Lepas Tombol Reset dan tetap tekan tombol prog sampai Proses Download dimulai
- * 4. Setelah Proses download dimulai lepas tombol Prog
- * 5. Klik RST agar ESP32 berubah dalam mode Programming ke Mode running,
- * 6. PENTING : Pastikan Ikuti Langkah 5, jika tidak Program yang diupload tidak akan dijalankan
- */
- #define RLY1 25
- #define RLY2 26
- #define RLY3 32
- #define RLY4 33
- #define BTN1 34
- #define BTN2 35
- #define BTN3 36
- #define BTN4 39
- void setup() {
- pinMode(RLY1, OUTPUT);
- pinMode(RLY2, OUTPUT);
- pinMode(RLY3, OUTPUT);
- pinMode(RLY4, OUTPUT);
- pinMode(BTN1, INPUT_PULLUP);
- pinMode(BTN2, INPUT_PULLUP);
- pinMode(BTN3, INPUT_PULLUP);
- pinMode(BTN4, INPUT_PULLUP);
- Serial.begin(9600);
- }
- void loop() {
- if (digitalRead(BTN1) == LOW) {
- digitalWrite(RLY1, HIGH); // turn the RLY1 on (HIGH is the voltage level)
- Serial.println("RLY1 ON");
- } else {
- digitalWrite(RLY1, LOW); // turn the RLY1 off by making the voltage LOW
- Serial.println("RLY1 OFF");
- }
- if (digitalRead(BTN2) == LOW) {
- digitalWrite(RLY2, HIGH); // turn the RLY1 on (HIGH is the voltage level)
- Serial.println("RLY2 ON");
- } else {
- digitalWrite(RLY2, LOW); // turn the RLY1 off by making the voltage LOW
- Serial.println("RLY2 OFF");
- }
- if (digitalRead(BTN3) == LOW) {
- digitalWrite(RLY3, HIGH); // turn the RLY1 on (HIGH is the voltage level)
- Serial.println("RLY3 ON");
- } else {
- digitalWrite(RLY3, LOW); // turn the RLY1 off by making the voltage LOW
- Serial.println("RLY3 OFF");
- }
- if (digitalRead(BTN4) == LOW) {
- digitalWrite(RLY4, HIGH); // turn the RLY1 on (HIGH is the voltage level)
- Serial.println("RLY4 ON");
- } else {
- digitalWrite(RLY4, LOW); // turn the RLY1 off by making the voltage LOW
- Serial.println("RLY4 OFF");
- }
- delay(50); // wait for a second
- }
Add Comment
Please, Sign In to add comment