Skip to content

Commit 5621a0e

Browse files
authored
Update Zigbee_On_Off_Light.ino
1 parent 893f57f commit 5621a0e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

examples/arduino-zigbee-light/src/Zigbee_On_Off_Light.ino

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,28 @@
3232

3333
#include "Zigbee.h"
3434

35-
#define LED_PIN RGB_BUILTIN
36-
#define BUTTON_PIN 9 // ESP32-C6/H2 Boot button
35+
/* Zigbee light bulb configuration */
3736
#define ZIGBEE_LIGHT_ENDPOINT 10
37+
uint8_t led = RGB_BUILTIN;
38+
uint8_t button = BOOT_PIN;
3839

3940
ZigbeeLight zbLight = ZigbeeLight(ZIGBEE_LIGHT_ENDPOINT);
4041

4142
/********************* RGB LED functions **************************/
4243
void setLED(bool value) {
43-
digitalWrite(LED_PIN, value);
44+
digitalWrite(led, value);
4445
}
4546

4647
/********************* Arduino functions **************************/
4748
void setup() {
4849
Serial.begin(115200);
49-
while (!Serial) {
50-
delay(10);
51-
}
50+
5251
// Init LED and turn it OFF (if LED_PIN == RGB_BUILTIN, the rgbLedWrite() will be used under the hood)
53-
pinMode(LED_PIN, OUTPUT);
54-
digitalWrite(LED_PIN, LOW);
52+
pinMode(led, OUTPUT);
53+
digitalWrite(led, LOW);
5554

5655
// Init button for factory reset
57-
pinMode(BUTTON_PIN, INPUT_PULLUP);
56+
pinMode(button, INPUT_PULLUP);
5857

5958
//Optional: set Zigbee device name and model
6059
zbLight.setManufacturerAndModel("Espressif", "ZBLightBulb");
@@ -82,11 +81,11 @@ void setup() {
8281

8382
void loop() {
8483
// Checking button for factory reset
85-
if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed
84+
if (digitalRead(button) == LOW) { // Push button pressed
8685
// Key debounce handling
8786
delay(100);
8887
int startTime = millis();
89-
while (digitalRead(BUTTON_PIN) == LOW) {
88+
while (digitalRead(button) == LOW) {
9089
delay(50);
9190
if ((millis() - startTime) > 3000) {
9291
// If key pressed for more than 3secs, factory reset Zigbee and reboot

0 commit comments

Comments
 (0)