lampu jomok#2 — Arduino Uno simulation

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by kiybiy36.

Components

Sketch code

#include <Wire.h>

// Kita membuat class "Bypass" mandiri agar sistem Valxio tidak menggunakan library yang rusak
class ValxioLCD {
  private:
    uint8_t _addr;
  public:
    ValxioLCD(uint8_t addr) { _addr = addr; }
    
    void begin() {
      Wire.begin();
      // Mengirim perintah inisialisasi dasar HD44780 lewat I2C
      sendCmd(0x03); delay(5);
      sendCmd(0x03); delay(5);
      sendCmd(0x03); delay(1);
      sendCmd(0x02); // Mode 4-bit
      
      sendCmd(0x28); // 2 baris / font 5x8 (LCD 20x4 menggunakan arsitektur ini)
      sendCmd(0x0C); // Display ON, Cursor OFF
      sendCmd(0x06); // Entry mode set
      clear();
    }
    
    void clear() {
      sendCmd(0x01); // Perintah clear display
      delay(2);
    }
    
    void printStr(const char* str) {
      while (*str) {
        sendData(*str++);
      }
    }
    
    void sendCmd(uint8_t cmd) {
      transmit((cmd & 0xF0), 0);
      transmit(((cmd << 4) & 0xF0), 0);
    }
    
    void sendData(uint8_t val) {
      transmit((val & 0xF0), 1);
      transmit(((val << 4) & 0xF0), 1);
    }
    
    void transmit(uint8_t nibble, uint8_t rs) {
      // 0x08 adalah bit untuk mengaktifkan Backlight otomatis
      uint8_t base = nibble | 0x08 | rs; 
      Wire.beginTransmission(_addr);
      Wire.write(base | 0x04); // Enable HIGH
      Wire.endTransmission();
      delayMicroseconds(1);
      
      Wire.beginTransmission(_addr);
      Wire.write(base & ~0x04); // Enable LOW
      Wire.endTransmission();
      delayMicroseconds(50);
    }
};

// Menginisialisasi LCD bypass pada alamat I2C 0x27
ValxioLCD lcd(0x27);

const int pinLED2 = 2;
const int pinLED3 = 3;
const int pinLED4 = 4;

void setup() {
  pinMode(pinLED2, OUTPUT);
  pinMode(pinLED3, OUTPUT);
  pinMode(pinLED4, OUTPUT);

  lcd.begin();
  lcd.printStr("=== VALXIO SYSTEM ===");
  delay(2000);
  lcd.clear();
}

void loop() {
  // ==========================================
  // FASE 1: Menyala Bergantian per Pin (1 Detik, Jeda 1 Detik)
  // ==========================================
  
  // LED PIN 2 MENYALA
  lcd.clear();
  lcd.printStr("HIDUP JOKOWI!");
  digitalWrite(pinLED2, HIGH);
  delay(1000);
  digitalWrite(pinLED2, LOW);
  delay(1000);

  // LED PIN 3 MENYALA
  lcd.clear();
  lcd.printStr("ANTEK ANTEK ASING");
  digitalWrite(pinLED3, HIGH);
  delay(1000);
  digitalWrite(pinLED3, LOW);
  delay(1000);

  // LED PIN 4 MENYALA
  lcd.clear();
  lcd.printStr("SAYA AKAN LAWAN");
  digitalWrite(pinLED4, HIGH);
  delay(1000);
  digitalWrite(pinLED4, LOW);
  delay(1000);
}

More projects by kiybiy36