This file contains 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
void loop() { | |
potValue = analogRead(potPin); // membaca nilai potensiometer | |
Serial.println(potValue); // menampilkan nilai potensiometer pada Serial Monitor | |
delay(1000); | |
} |
This file contains 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 = 34; // pin potensiometer | |
int potValue = 0; // variabel untuk menyimpan nilai potensiometer | |
void setup() { | |
Serial.begin(115200); | |
pinMode(potPin, INPUT); // inisialisasi pin sebagai input | |
delay(1000); | |
} |
This file contains 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
// Menggunakan 3 pin GPIO untuk PWM | |
const int ledPin1 = 5; // Nomor pin LED pertama | |
const int ledPin2 = 22; // Nomor pin LED kedua | |
const int ledPin3 = 23; // Nomor pin LED ketiga | |
// Mengatur properti PWM | |
const int freq = 5000; // Frekuensi PWM 5 kHz | |
const int resolution = 8; // Resolusi PWM 8-bit | |
void setup() { |
This file contains 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
void loop() { | |
// Mengatur kecerahan LED dengan mengubah nilai dutycycle (0-255) | |
for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle++) { | |
ledcWrite(0, dutyCycle); // Mengirimkan nilai dutycycle ke pin LED | |
Serial.println(dutyCycle); // Mencetak nilai dutyCycle ke Serial Monitor | |
delay(10); // Tunggu selama 10ms | |
} | |
delay(1000); // Tunggu selama 1 detik | |
} |
This file contains 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
void setup() { | |
Serial.begin(115200); | |
ledcAttachPin(ledPin, 0); // Menyambungkan PWM ke pin LED | |
ledcSetup(ledChannel, freq, resolution); // Kanal PWM 0, frekuensi 5kHz, resolusi 8-bit | |
} |
This file contains 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
// mengatur properti PWM | |
const int freq = 5000; | |
const int ledChannel = 0; | |
const int resolution = 8; |
This file contains 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
// jumlah pin LED | |
const int ledPin = 5; // 5 sesuai dengan GPIO5 |
This file contains 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
// jumlah pin LED | |
const int ledPin = 5; // 5 sesuai dengan GPIO5 | |
// mengatur properti PWM | |
const int freq = 5000; | |
const int ledChannel = 0; | |
const int resolution = 8; | |
void setup() { | |
ledcAttachPin(ledPin, 0); // Menyambungkan PWM ke pin LED |
This file contains 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
ledcWrite(channel, dutycycle); |
This file contains 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(GPIO, channel); |
NewerOlder