This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define timeSeconds 10 | |
// Tentukan GPIO untuk LED dan Sensor Gerak PIR | |
const int led = 26; | |
const int motionSensor = 27; | |
// Variabel tambahan | |
unsigned long now = millis(); | |
unsigned long lastTrigger = 0; | |
boolean startTimer = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Konstanta, tidak akan berubah. | |
const int ledPin = 26; // Nomor pin LED | |
// Variabel yang akan berubah | |
int ledState = LOW; // Mulai dengan LED mati | |
// Variabel memegang waktu | |
unsigned long previousMillis = 0; // Waktu terakhir LED diperbarui | |
// Konstanta untuk interval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int val = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
val = hallRead(); // Membaca nilai sensor efek Hall | |
Serial.println(val); // Mencetak hasil ke serial monitor | |
delay(1000); // Menambahkan jeda 1 detik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serial.println(potValue); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
potValue = analogRead(potPin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serial.begin(115200); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int potPin = 7; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int potPin = 7; // Potentiometer terhubung ke GPIO 7 (Analog ADC1_CH6) | |
// Variabel untuk menyimpan nilai potensiometer | |
int potValue = 0; | |
void setup() { | |
Serial.begin(115200); | |
delay(1000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
analogRead(GPIO); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ledcAttachPin(ledPin2, ledChannel); | |
ledcAttachPin(ledPin3, ledChannel); |
NewerOlder