// edited 20.48
/*
Pelatihan IoT3 - 14 Internet of Things (IoT) DTS PROA Batch 3
(Digitalent Scholarship Professional Academy)
created 28 Agustus 2022
by Muhammad Sudarsono
modified 28 Agustus 2022
Copyright © 2022 Indobot Academy
*/
#include <WiFi.h>
#include <time.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Servo.h>
// OLED Setting
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
// WiFi Setting
#define WIFI_SSID "Wokwi-GUEST"
#define WIFI_PASSWORD ""
#define JST 3600*9
#define LDR_PIN 12 // pin LDR
#define SERVO_PIN 4 // pin Servo
#define PUSH_BUTTON 27 // pin Pushbutton
#define LED_PIN 15 // pin Switch
#define SWITCH_BUTTON 2 // Variabel yang menampung Nilai Switch 0
int buttonStatus = 0; // Variabel yang menampung Nilai Pusbaten 0
int switchStatus = 0;
Servo servoMotor;
void setup() {
pinMode(LDR_PIN, INPUT); //Inialisasi LDR
pinMode(PUSH_BUTTON, INPUT); //Inialisasi Pusbaten
pinMode(SWITCH_BUTTON, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT); //Inialisasi Led
Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// Clear the buffer.
display.clearDisplay();
display.setTextColor(WHITE);
Kelompok();
// WiFi starting
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while(WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(500);
}
ConnectWIFI();
Serial.println();
Serial.print("Attempting to connect to SSID: ");
Serial.println(WIFI_SSID);
Serial.printf("Connected, IP address: ");
Serial.println(WiFi.localIP());
ConnectWIFI();
servoMotor.attach(SERVO_PIN);
// NTP start
configTime( JST, 0, "ntp.nict.jp", "ntp.jst.mfeed.ad.jp");
delay(1000);
}
void loop() {
Transmisi();
}