File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
examples/adafruitio_09_analog_out Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ AdafruitIO_Feed *analog = io.feed("analog");
28
28
29
29
void setup () {
30
30
31
+ // set up led pin as an analog output
32
+ #if defined(ARDUINO_ARCH_ESP32)
33
+ // ESP32 pinMode()
34
+ ledcAttachPin (LED_PIN, 1 );
35
+ ledcSetup (1 , 1200 , 8 );
36
+ #else
37
+ pinMode (LED_PIN, OUTPUT);
38
+ #endif
39
+
31
40
// start the serial connection
32
41
Serial.begin (115200 );
33
42
@@ -53,7 +62,6 @@ void setup() {
53
62
// we are connected
54
63
Serial.println ();
55
64
Serial.println (io.statusText ());
56
- analog->get ();
57
65
58
66
}
59
67
@@ -77,6 +85,13 @@ void handleMessage(AdafruitIO_Data *data) {
77
85
78
86
Serial.print (" received <- " );
79
87
Serial.println (reading);
80
- analogWrite (LED_PIN, reading);
88
+
89
+
90
+ // write the current 'reading' to the led
91
+ #if defined(ARDUINO_ARCH_ESP32)
92
+ ledcWrite (1 , reading); // ESP32 analogWrite()
93
+ #else
94
+ analogWrite (LED_PIN, reading);
95
+ #endif
81
96
82
97
}
You can’t perform that action at this time.
0 commit comments