Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:laboratoare:2022:lab3 [2023/10/23 19:22]
dan.tudose
iothings:laboratoare:2022:lab3 [2025/03/13 19:34] (current)
andreea.miu [SPIFFS Webserver] add ledPin tip
Line 9: Line 9:
  
 Run this example code on your board, but replace the SSID and PASSWORD fields with your own. Run this example code on your board, but replace the SSID and PASSWORD fields with your own.
-<code C webserver.ino ​|h Blsa>+<code C webserver.ino>​
 // Load Wi-Fi library // Load Wi-Fi library
 #include <​WiFi.h>​ #include <​WiFi.h>​
Line 227: Line 227:
 const char* ssid     = "​REPLACE_WITH_YOUR_SSID";​ const char* ssid     = "​REPLACE_WITH_YOUR_SSID";​
 const char* password = "​REPLACE_WITH_YOUR_PASSWORD";​ const char* password = "​REPLACE_WITH_YOUR_PASSWORD";​
- 
-const int output = 14; //red led 
  
 String sliderValue = "​0";​ String sliderValue = "​0";​
Line 234: Line 232:
 // setting PWM properties // setting PWM properties
 const int freq = 5000; const int freq = 5000;
-const int ledChannel ​0;+const int ledPin ​14// red led
 const int resolution = 8; const int resolution = 8;
  
Line 260: Line 258:
     return;     return;
   }   }
-  // configure LED PWM functionalitites 
-  ledcSetup(ledChannel,​ freq, resolution);​ 
   ​   ​
-  // attach the channel to the GPIO to be controlled +  // configure LED PWM & attach the channel to the GPIO to be controlled 
-  ​ledcAttachPin(outputledChannel);+  ​ledcAttach(ledPinfreq, resolution);
   ​   ​
-  ledcWrite(ledChannel, sliderValue.toInt());​+  ledcWrite(ledPin, sliderValue.toInt());​
  
   // Connect to Wi-Fi   // Connect to Wi-Fi
Line 292: Line 288:
       sliderValue = inputMessage;​       sliderValue = inputMessage;​
       Serial.println(sliderValue.toInt());​       Serial.println(sliderValue.toInt());​
-      ledcWrite(ledChannel, 255 - sliderValue.toInt());​+      ledcWrite(ledPin, 255 - sliderValue.toInt());​
     }     }
     else {     else {
Line 309: Line 305:
 } }
 </​code>​ </​code>​
 +
 +<note tip>
 +Change the //ledPin// according to your board version. ​
 +
 +For the GREEN boards: Red - GPIO25, Green - GPIO26, Blue - GPIO27
 +
 +For the BLUE boards: Red - GPIO14, Green - GPIO13, Blue - GPIO15
 +</​note>​
  
  
Line 371: Line 375:
  
 == Assignment == == Assignment ==
-<​note>​ Modify the webserver sketch to receive data from the other two sliders in the webpage and control the other two PWM channels (13 - green and 15 - blue).</​note>​+<​note>​ Modify the webserver sketch to receive data from the other two sliders in the webpage and control the other two PWM channels (green and blue).</​note>​
  
 === Live charts === === Live charts ===
iothings/laboratoare/2022/lab3.1698078162.txt.gz · Last modified: 2023/10/23 19:22 by dan.tudose
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0