@@ -87,7 +87,7 @@ AdafruitIO_Feed *frontDoor = io.feed("front-door");
87
87
// `motion-detector` feed
88
88
AdafruitIO_Feed *motionFeed = io.feed(" motion-detector" );
89
89
// `home-alarm` feed
90
- AdafruitIO_Feed *alarm = io.feed(" home-alarm" );
90
+ AdafruitIO_Feed *homeAlarm = io.feed(" home-alarm" );
91
91
// 'tvoc' feed
92
92
AdafruitIO_Feed *tvocFeed = io.feed(" tvoc" );
93
93
// 'eco2' feed
@@ -106,7 +106,7 @@ void setup() {
106
106
io.connect ();
107
107
108
108
// attach a message handler for the `home-alarm` feed
109
- alarm ->onMessage (handleAlarm);
109
+ homeAlarm ->onMessage (handleAlarm);
110
110
// subscribe to lighting feeds and register message handlers
111
111
indoorLights->onMessage (indoorLightHandler);
112
112
outdoorLights->onMessage (outdoorLightHandler);
@@ -159,7 +159,14 @@ void loop(){
159
159
void playAlarmAnimation () {
160
160
// plays the alarm piezo buzzer and turn on/off neopixels
161
161
Serial.println (" ALARM TRIGGERED!" );
162
- tone (piezoPin, 220 , 2 );
162
+
163
+ #if defined(ARDUINO_ARCH_ESP32)
164
+ // ESP32 doesn't use native tone() function
165
+ ledcWriteTone (piezoPin, 220 );
166
+ #else
167
+ tone (piezoPin, 220 , 2 );
168
+ #endif
169
+
163
170
for (int i=0 ; i<JEWEL_PIXEL_COUNT; ++i) {
164
171
strip.setPixelColor (i, 255 , 0 , 0 );
165
172
}
@@ -295,4 +302,4 @@ void getTime() {
295
302
Serial.print (minutes);
296
303
Serial.print (" :" );
297
304
Serial.println (seconds);
298
- }
305
+ }
0 commit comments