Sari la conținut
ELFORUM - Forumul electronistilor

Kreator

Membru activ
  • Număr conținut

    595
  • Înregistrat

  • Ultima Vizită

Contact Methods

  • Website URL
    https://cristinastac.wordpress.com/

Profile Fields

  • Locatie
    Baia Mare

Vizitatori Recenți Profil

1.174 citiri profil

Kreator's Achievements

Proficient

Proficient (10/14)

  • First Post
  • Collaborator
  • Posting Machine Rare
  • Conversation Starter
  • Dedicated

Recent Badges

  1. Kreator

    Ceas RGB WIFI

    Am mai bibilit codul de la ceas, in sensul ca l-am facut sa caute intre doua retele, si am scapat de o librarie pentru temperatura, iar acum afiseaza temperaturile negative in mod corect. Concret: la pornire, ceasul incearca sa se conecteze la ssid1 (la mine este reteaua wifi de la router), daca nu reuseste incearca sa se conecteze la ssid2 (in cazul meu, hotspot de pe telefonul mobil). Daca nu reuseste nici in acest caz, atunci ceasul porneste "offline". Conectarea la ssid1 este semnalizata prin aprinderea unui pct in stanga sus a ecranului, ial la ssid2 prin aprinderea unui pct in stanga jos a ecreanului, In mod offline - ecranul e fara puncte. Daca a pornit neconectat sau a pierdut reteaua si intre timp o retea din cele doua devine disponibila, atunci el se conecteaza la aceasta (cautarea se face din 10 in 10 secunde comutand intre cele doua ssid). Am ales aceasta modalitate deoarece ceasul va sta afara, pe terasa din curte unde de obicei nu "bate" wifi-ul, si atunci, daca vreau sa ma conectez la el pornesc hotspot-ul de pe mobil. Conectarea la modul am facut-o alocand static un IP functie de MAC si apoi forward IP:port pt conexiunea prin router, iar daca conexiunea e facuta cu hotspot, adresa de IP alocata ESP-ului se poate afla vizualizand detaliile dispozitivelor conectate la hotspot. Acum acest ceas functioneaza exact asa cum am vrut eu (chiar si cu delay-uri) . L.E. Se poate implementa si un update de ora de la un server UTC dar nu e cazul, precizia DS3231 este foarte buna, la modulele folosite sub un minut pe an. (dar la cat s-au scumpit modulele DS3221 - mai scumpe decat un ESP - aceasta varianta devine de luat in seama!!!) // CEAS RGB - varianta cu doua retele #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> #include <ESPAsyncWebServer.h> #include <Wire.h> #include <Adafruit_NeoPixel.h> #include <OneWire.h> // Pinul conectat la DS18b20 OneWire ds(D6); // Pinul conectat INPUT Data display #define LED_PIN D7 // Nr de leduri al display-ului #define LED_COUNT 256 // Intensitatea, 0 {min) to 255 {max) // #define BRIGHTNESS 5 // Set BRIGHTNESS to about 1/5 {max = 255) // DS3231_I2C_ADDRESS #define DS3231_I2C_ADDRESS 0x68 #define EEPROM_I2C_ADDRESS 0x57 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Replace with your network credentials const char* ssid1 = "*******"; //reteaua WiFi1 la care se conecteaza const char* password1 = "*******"; // parola pt conectare la retea WiFi1 const char* ssid2 = "*******"; //reteaua WiFi2 la care se conecteaza const char* password2 = "*******"; // parola pt conectare la retea WiFi2 String sliderValue1 = "128"; // valoare initiala pt slider1 String sliderValue2 = "128"; // valoare initiala pt slider2 String sliderValue3 = "128"; // valoare initiala pt slider3 String sliderValue4 = "5"; // valoare initiala pt slider4 String ora_new = "20"; // valoare initiala pt ora_new String minut_new = "05"; // valoare initiala pt minut_new String ora_change = "0"; // valoare initiala pt ora_change (daca se schimba ora trece in 1) String minut_change = "0"; // valoare initiala pt minut_change (daca se schimba minut trece in 1) String sliderValue1_new = "0"; String sliderValue2_new = "0"; String sliderValue3_new = "0"; String sliderValue4_new = "0"; String sliderValue1_change = "0"; // valoare initiala pt sliderValue1_change (daca se schimba ora trece in 1) String sliderValue2_change = "0"; // valoare initiala pt sliderValue2_change (daca se schimba minut trece in 1) String sliderValue3_change = "0"; // valoare initiala pt sliderValue3_change (daca se schimba minut trece in 1) String sliderValue4_change = "0"; // valoare initiala pt sliderValue4_change (daca se schimba minut trece in 1) String ora_val = "20"; // valoare initiala pt ora String minut_val = "14"; // valoare initiala pt minut const char* PARAM_INPUT1 = "value1"; //valoare folosita pentru cautarea valorii lui slider1 // vezi in xhr.open("GET", "/slider?value1="+sliderValue1, true); const char* PARAM_INPUT1_CHANGE = "value1_change"; //valoare folosita pentru alerta schimbarii slider1 // vezi in xhr.open("GET", "/slider?value1_change="+sliderValue1, true); const char* PARAM_INPUT2 = "value2"; //valoare folosita pentru cautarea valorii lui slider2 // vezi in xhr.open("GET", "/slider?value2="+sliderValue2, true); const char* PARAM_INPUT2_CHANGE = "value2_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value2_change="+sliderValue2, true); const char* PARAM_INPUT3 = "value3"; //valoare folosita pentru cautarea valorii lui slider3 // vezi in xhr.open("GET", "/slider?value3="+sliderValue3, true); const char* PARAM_INPUT3_CHANGE = "value3_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xxhr.open("GET", "/slider?value3_change="+sliderValue3, true); const char* PARAM_INPUT4 = "value4"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4="+sliderValue4, true); const char* PARAM_INPUT4_CHANGE = "value4_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4_change="+sliderValue4, true); const char* PARAM_INPUT_ORA = "value_ora"; //valoare folosita pentru cautarea valorii ora // vezi in /xhr.open("GET", "/slider?value_ora="+ora_new, true); const char* PARAM_INPUT_MINUT = "value_minut"; //valoare folosita pentru cautarea valorii minut // vezi in xhr.open("GET", "/slider?value_minut="+minut_new, true); // Create AsyncWebServer object on port 80 AsyncWebServer server(80); AsyncWebSocket ws("/ws"); byte rosu = 100, verde = 0, albastru = 50, BRIGHTNESS = 5; byte red, green, blue, umin, zmin, uhour, zhour; byte dsp_ora [32], dsp_th [32], dsp_tot[96]; byte ma[8], sa[8], za[8], uua[8], utmp[8], ztmp[8], stmp[8], ltmp[8], rtmp[8], mtmp[8]; byte dsp[32], dsp_tmp[32]; byte second, minute, hour, dp; byte th0, th1, tsgn, kt=0, k, k_con = 0; byte s0, s1, m0, m1, h0, h1; byte array_disp[256]; float t_read; int xxx; byte addr_DS[8]; //to hold 64-bit ROM Codes of DS18B20 byte data_temperature[9]; //buffer to hold data coming from Scratchpad memory of DS18B20 byte dsRes[] = {0x00, 0x00, 0x7F};//, 0x1F(0 R1 R0 11111)/0x3F/0x5F/0x7F for 9-10-11-12-bit Resolution byte x = 0, wifi_en = 0, wifi_prim = 0, fr_temp, t_sec = 0, t_secp = 0, wifi_id = 0, wifi_stat = 0; unsigned int t_rea, int_temp; // SET resolution of DS18B20 const byte resolution = 9; // 9-10-11-12-bit Resolution // Set LED GPIO const int ledPin1 = LED_BUILTIN; // pin atasat la INT RTC const byte interruptPin = D5; // litere si cifre const byte alfabet [17] [7]= {{126, 255, 195, 195, 255, 126, 0}, //0 { 1, 255, 255, 97, 32, 0, 0}, //1 { 99, 243, 219, 207, 199, 99, 0}, //2 { 102,255, 219, 219, 195, 102, 0}, //3 { 5, 255, 255, 101, 60 ,28, 0}, //4 { 78, 223, 211, 211, 251, 250, 0}, //5 { 78, 223, 211, 211, 255, 126, 0}, //6 {224, 240, 223, 207, 192, 192, 0}, //7 {110, 255, 219, 219, 255, 110, 0}, //8 {126, 255, 203, 203, 251, 114, 0}, //9 { 0, 0, 0, 0, 0, 0, 0}, //blank {102, 102, 0, 0, 0, 0, 0}, //dp {102, 195, 195, 195, 255, 126, 0}, //C {112, 248, 136, 248, 112, 0, 0}, //` {110, 255, 211, 211, 255, 255, 0}, //B { 48, 48, 24, 63, 63, 0, 0}, //r { 24, 24, 24, 0, 0, 0, 0},}; //- // Convert normal decimal numbers to binary coded decimal byte decToBcd(byte val) { return( (val/10*16) + (val%10) ); } // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte val) { return( (val/16*10) + (val%16) ); } byte readEEPROM(int deviceaddress, unsigned int eeaddress ) { byte rdata = 0xFF; Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.endTransmission(); delay(10); Wire.requestFrom(deviceaddress,1); if (Wire.available()) rdata = Wire.read(); return rdata; } // incepe serverul html const char index_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML><html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CEAS RGB</title> <style> html { font-family: Arial, Helvetica, sans-serif; display: inline-block; text-align: center; } h1 { font-size: 1.8rem; color: white; } p { font-size: 1.4rem; } .topnav { overflow: hidden; background-color: #034078; } body { margin: 0; } .content { padding: 30px; } .card-grid { max-width: 500px; margin: 0 auto; display: grid; grid-gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .card { background-color: white; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); } } .card-title { font-size: 1.2rem; font-weight: bold; color: #034078 } .state { font-size: 1.2rem; color:#1282A2; } .slider { -webkit-appearance: none; margin: 0 auto; width: 90%; height: 15px; border-radius: 10px; background: #C0C0C0; outline: none; } .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; border-radius: 50 ; background: #034078; cursor: pointer; } .switch { padding-left: 5; } </style> </head> <body> <div class="topnav"> <h1><span style="color:white">CEAS </span><span style="color:#ff3300">R</span><span style="color:#33cc33">G</span><span style="color:#3399ff">B</span></h1> </div> <p> </p> <span class="inlineinput"><input type="number" onchange="update_ora(this)" id="ora" value="%VAL_ORA%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300;font-weight: bold; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <span style='display: inline; font-size: 4rem ; text-align: center; color:#ff3300 ; font-weight: bold;'>:</span> <span class="inlineinput"> <input type="number" onchange="update_minut(this)" id="minut" value="%VAL_MINUT%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300; font-weight: bold;box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <div class="content"> <div class="card-grid"> <div class="card"> <p class="switch"> <input type="range" onchange="Slider1_change(this)" oninput="updateSlider1(this)" id="Sliderx1" min="0" max="255" value="%SLIDERVALUE1%" step="1" class="slider"></p> <p class="state"><span style='color:#ff0000; font-weight: bold;'>ROSU=<span id="textSlider1Value">%SLIDERVALUE1%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider2_change(this)" oninput="updateSlider2(this)" id="Sliderx2" min="0" max="255" value="%SLIDERVALUE2%" step="1" class="slider"></p> <p class="state"><span style='color:#33cc33; font-weight: bold;'>VERDE=<span id="textSlider2Value">%SLIDERVALUE2%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider3_change(this)" oninput="updateSlider3(this)" id="Sliderx3" min="0" max="255" value="%SLIDERVALUE3%" step="1" class="slider"></p> <p class="state"><span style='color:#0000ff; font-weight: bold;'>ALBASTRU=<span id="textSlider3Value">%SLIDERVALUE3%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider4_change(this)" oninput="updateSlider4(this)" id="Sliderx4" min="1" max="255" value="%SLIDERVALUE4%" step="1" class="slider"></p> <p class="state"><span style='color: #797979; font-weight: bold;'>STRALUCIRE=<span id="textSlider4Value">%SLIDERVALUE4%</span></p> </div> </div> </div> <script> function updateSlider1(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1="+sliderValue1, true); xhr.send(); } function Slider1_change(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1_change="+sliderValue1, true); xhr.send(); } function updateSlider2(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2="+sliderValue2, true); xhr.send(); } function Slider2_change(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2_change="+sliderValue2, true); xhr.send(); } function updateSlider3(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3="+sliderValue3, true); xhr.send(); } function Slider3_change(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3_change="+sliderValue3, true); xhr.send(); } function updateSlider4(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4="+sliderValue4, true); xhr.send(); } function Slider4_change(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4_change="+sliderValue4, true); xhr.send(); } function update_ora(element) { var ora_new = document.getElementById("ora").value; console.log(ora_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_ora="+ora_new, true); xhr.send(); } function update_minut(element) { var minut_new = document.getElementById("minut").value; console.log(minut_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_minut="+minut_new, true); xhr.send(); } </script> </body> </html> )rawliteral"; // sfarsitul serverului html // Replaces placeholder with button section in your web page String processor(const String& var){ //Serial.println(var); if (var == "SLIDERVALUE1"){ return sliderValue1; } if (var == "SLIDERVALUE2"){ return sliderValue2; } if (var == "SLIDERVALUE3"){ return sliderValue3; } if (var == "SLIDERVALUE4"){ return sliderValue4; } if (var == "VAL_ORA"){ return ora_val; } if (var == "VAL_MINUT"){ return minut_val; } return String(); } void setup(){ // Serial port for debugging purposes Serial.begin(115200); Wire.begin(D2, D1); ds.reset(); ds.search(addr_DS); //collect 64-bit ROM code from sensor (DS1)t switch (resolution) { case 9: dsRes[2] = 0x1F; break; case 10: dsRes[2] = 0x3F; break; case 11: dsRes[2] = 0x5F; break; case 12: dsRes[2] = 0x7F; break; } // init display strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); strip.clear(); strip.show(); delay(500); /// Square wave is output on the INT/SQW pin Wire.beginTransmission(DS3231_I2C_ADDRESS); // transmit to DS3231 I2C_ADDRESS = 0x68 Wire.write(byte(0x0E)); // transmit adress memory Wire.write(0); // sends 0 = square output to INT pin Wire.endTransmission(); // stop transmitting //// pinMode(interruptPin, INPUT); pinMode(LED_BUILTIN, OUTPUT); //setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) //setDS3231time(0, 9, 00, 7, 18, 04, 22); sliderValue1 = String(readEEPROM(EEPROM_I2C_ADDRESS, 1)); sliderValue2 = String(readEEPROM(EEPROM_I2C_ADDRESS, 2)); sliderValue3 = String(readEEPROM(EEPROM_I2C_ADDRESS, 3)); sliderValue4 = String(readEEPROM(EEPROM_I2C_ADDRESS, 4)); // Connect to Wi-Fi WiFi.setSleepMode(WIFI_NONE_SLEEP); WiFi.mode(WIFI_STA); // Se incearca conectarea la prima retea WiFi WiFi.begin(ssid1, password1); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.print("Se incearca conectarea la reteaua ");Serial.print(ssid1); Serial.print(". Incercarea nr. ");Serial.println(k_con + 1); k_con = k_con + 1; if (k_con == 10) { Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); Serial.print("Nu s-a conectat la ");Serial.println(ssid1); wifi_en = 0; wifi_stat = 0; break; } } if (WiFi.status() == WL_CONNECTED) { Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); Serial.print("Conectat la ");Serial.print(ssid1); Serial.print(" din "); Serial.print(k_con);Serial.println(" incercari."); wifi_en = 128; wifi_stat = 128; } // Se incearca conectarea la a doua retea WiFi if (wifi_en == 0) { k_con = 0; WiFi.begin(ssid2, password2); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.print("Se incearca conectarea la reteaua ");Serial.print(ssid2); Serial.print(". Incercarea nr. ");Serial.println(k_con + 1); k_con = k_con + 1; if (k_con == 10) { Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); Serial.print("Nu s-a conectat la ");Serial.println(ssid2); wifi_en = 0; wifi_stat = 0; break; } } if (WiFi.status() == WL_CONNECTED) { Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); Serial.print("Conectat la ");Serial.print(ssid2); Serial.print(" din "); Serial.print(k_con);Serial.println(" incercari."); wifi_en = 128; wifi_stat = 1; } } // daca nu s-a reusit conectarea la nici o retea, se porneste in mod offline send_web_page(); } void conv_temp_without_adress(){ ds.write(0x4E); ds.write_bytes(dsRes, 3); //set resolution bit //---------------------------------------------- ds.reset(); //bring 1-Wire into idle state ds.write(0xCC); //slect with DS-1 with address addr_DS ds.write(0x44); //conversion command } void read_temp_without_adress(){ ds.reset(); ds.write(0xCC); //selectimg the desired DS18B20 ds.write(0xBE); //Function command to read Scratchpad Memory (9Byte) ds.read_bytes(data_temperature, 9); //data comes from DS and are saved into buffer data[8] //------------------------------------------------------------ unsigned int rawTemp = (int)(data_temperature[1] << 4); //upper 4-bit of integer part of temperature byte n = data_temperature[0]; //n = lower 4-bit of integer part and 4-bit fractional part of temperature data_temperature[0] = data_temperature[0] >> 4; //lower 4-bit integer part of temperature rawTemp = rawTemp | (int)data_temperature[0]; //8-bit (including sign bit) integer part of temperature t_read = (float)rawTemp + 0.5 * bitRead(n, 3) + 0.25 * bitRead(n, 2) + 0.125 * bitRead(n, 1) + 0.0625 * bitRead(n, 0); //temp in float format t_rea = t_read; fr_temp = t_rea & 0x0F; //Serial.print("t_rea = ");Serial.println(t_rea); //Serial.print("fr_temp = ");Serial.println(fr_temp); if (bitRead(t_rea, 15)) { // daca e negativ int_temp = t_rea >> 4; int_temp = int_temp | 0xF000; for(int i = 0; i <= 15; i++) { bitWrite(int_temp, i, !bitRead(int_temp, i)); } tsgn = 16; if (!fr_temp ) { int_temp = int_temp + 1; } } else { int_temp = t_rea; tsgn = 10; } //Serial.print("int_temp = ");Serial.println(int_temp); th0 = int_temp / 10; th1 = int_temp % 10; } void send_web_page() { // Print ESP Local IP Address Serial.println(WiFi.localIP()); // Route for root / web page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); }); // Send a GET request to <ESP_IP>/slider?value=<inputMessage> server.on("/slider", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessageslider1; String inputMessageslider2; String inputMessageslider3; String inputMessageslider4; String inputMessageora; String inputMessageminut; // GET input1 value on <ESP_IP>/slider1?value1=<inputMessageslider1> if (request->hasParam(PARAM_INPUT1)) { inputMessageslider1 = request->getParam(PARAM_INPUT1)->value(); sliderValue1 = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } if (request->hasParam(PARAM_INPUT1_CHANGE)) { sliderValue1_change = "1"; inputMessageslider1 = request->getParam(PARAM_INPUT1_CHANGE)->value(); sliderValue1_new = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } // GET input1 value on <ESP_IP>/slider2?value2=<inputMessageslider2> if (request->hasParam(PARAM_INPUT2)) { inputMessageslider2 = request->getParam(PARAM_INPUT2)->value(); sliderValue2 = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } if (request->hasParam(PARAM_INPUT2_CHANGE)) { sliderValue2_change = "1"; inputMessageslider2 = request->getParam(PARAM_INPUT2_CHANGE)->value(); sliderValue2_new = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } // GET input1 value on <ESP_IP>/slider3?value3=<inputMessageslider3> if (request->hasParam(PARAM_INPUT3)) { inputMessageslider3 = request->getParam(PARAM_INPUT3)->value(); sliderValue3 = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT3_CHANGE)) { sliderValue3_change = "1"; inputMessageslider3 = request->getParam(PARAM_INPUT3_CHANGE)->value(); sliderValue3_new = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT4)) { inputMessageslider4 = request->getParam(PARAM_INPUT4)->value(); sliderValue4 = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } if (request->hasParam(PARAM_INPUT4_CHANGE)) { sliderValue4_change = "1"; inputMessageslider4 = request->getParam(PARAM_INPUT4_CHANGE)->value(); sliderValue4_new = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } // GET input1 value on <ESP_IP>/slider4?value4=<inputMessageslider4> if (request->hasParam(PARAM_INPUT_ORA)) { ora_change = "1"; inputMessageora = request->getParam(PARAM_INPUT_ORA)->value(); ora_new = inputMessageora; } else { inputMessageora = "No message sent"; } if (request->hasParam(PARAM_INPUT_MINUT)) { minut_change = "1"; inputMessageminut = request->getParam(PARAM_INPUT_MINUT)->value(); minut_new = inputMessageminut; } else { inputMessageminut = "No message sent"; } request->send(200, "text/plain", "OK"); }); // Start server server.begin(); } void I2Cwrite(byte ID, byte adress, byte value) { Wire.beginTransmission(ID); //select ID device Wire.write(adress); // move pointer to adress address Wire.write(value); // sends value Wire.endTransmission(); } void I2CRead(uint8_t ID, uint8_t adress, byte *xxx) { Wire.beginTransmission(ID); Wire.write(adress); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom((uint8_t) ID, (uint8_t) 1); // request seven bytes of data from DS3231 starting from register 00h *xxx = Wire.read(); } void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231 Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set next input to start at the seconds register Wire.write(decToBcd(second)); // set seconds Wire.write(decToBcd(minute)); // set minutes Wire.write(decToBcd(hour)); // set hours Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday) Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31) Wire.write(decToBcd(month)); // set month Wire.write(decToBcd(year)); // set year (0 to 99) Wire.endTransmission(); } void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) { Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.write(data); delay(10); Wire.endTransmission(); delay(10); } void read_RTC() { Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom(DS3231_I2C_ADDRESS, 3); // request seven bytes of data from DS3231 starting from register 00h second = bcdToDec(Wire.read() & 0x7f); s0 = second /10; s1 = second %10; minute = bcdToDec(Wire.read()); m0 = minute/10; m1 = minute %10; hour = bcdToDec(Wire.read() & 0x3f); h0 = hour/10; h1 = hour %10; if (hour <= 9) { ora_val = "0" + String(hour); } else { ora_val = String(hour); } if (minute <= 9) { minut_val = "0" + String(minute); } else { minut_val = String(minute); } } //Prepare hour data void prepare_to_show_hour(byte m, byte s_, byte z_, byte u_i, byte dp1){ for(int i = 0; i <= 31; i++) { dsp_ora [i] = 0; } for(int i=0; i<=2; i++) { if (dp ==1) { dsp_ora [i+14] = alfabet [11] [i]; } else { dsp_ora [i+14] = alfabet [10] [i]; } } for(int i = 0; i <= 5; i++) { dsp_ora [i] = alfabet [u_i] [i]; dsp_ora [i+7] = alfabet [z_] [i]; dsp_ora [i+17] = alfabet [s_] [i]; dsp_ora [i+24] = alfabet [m] [i]; } dsp_ora [31] = wifi_id; for(int i = 0; i <= 31; i++) { dsp_tot[i] = dsp_ora [i] ; dsp_tot[i+64] = dsp_ora [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_ora [j], i%8); array_disp[i] = bt; } } // Prepare Temperature data void prepare_to_show_temp(byte tsgn, byte iz_, byte iu){ for(int i = 0; i <= 31; i++) { dsp_th [i] = 0; } for(int i = 0; i <= 5; i++) { dsp_th [i+1] = alfabet [12] [i]; dsp_th [i+8] = alfabet [13] [i]; dsp_th [i+14] = alfabet [iu] [i]; dsp_th [i+21] = alfabet [iz_] [i]; dsp_th [i+28] = alfabet [tsgn] [i]; } dsp_th [31] = wifi_id; for(int i = 0; i <= 31; i++) { dsp_tot[i+32] = dsp_th [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_th [j], i%8); array_disp[i] = bt; array_disp[255] = bitRead(wifi_en, 0); } } void tranz_display(byte kk) { for(byte i = 0; i <= 31; i++) { dsp_tmp[i] = dsp_tot[i+64 - kk]; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_tmp[j], i%8); array_disp[i] = bt; } } void read_sliders() { rosu = sliderValue1.toInt(); verde = sliderValue2.toInt(); albastru = sliderValue3.toInt(); BRIGHTNESS= sliderValue4.toInt(); } void change_controls(){ if (ora_change.toInt() == 1) { ora_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 2, decToBcd(ora_new.toInt())); } if (minut_change.toInt() == 1) { minut_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 1, decToBcd(minut_new.toInt())); I2Cwrite(DS3231_I2C_ADDRESS, 0, 0); } if (sliderValue1_change.toInt() == 1) { sliderValue1_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 1, sliderValue1_new.toInt()); } if (sliderValue2_change.toInt() == 1) { sliderValue2_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 2, sliderValue2_new.toInt()); } if (sliderValue3_change.toInt() == 1) { sliderValue3_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 3, sliderValue3_new.toInt()); } if (sliderValue4_change.toInt() == 1) { sliderValue4_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 4, sliderValue4_new.toInt()); } } void show_data(){ read_sliders(); strip.setBrightness(BRIGHTNESS); dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); for(int i=0; i<=255; i++) { // For each pixel in strip... byte k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; byte bt = array_disp[i]; red = rosu * bt ; green = verde * bt ; blue = albastru * bt ; if (k <=7) { strip.setPixelColor(i, red,green,blue); // Set pixel's color (in RAM) } else { strip.setPixelColor(k1, red,green,blue); // Set pixel's color (in RAM) } } strip.show(); } void show_hour(){ prepare_to_show_hour(h0, h1, m0, m1, dp); prepare_to_show_temp(tsgn, th0, th1); tranz_display(0); show_data(); } void show_hour_to_temp(){ dp = 1; for(int yy = 0; yy <= 32; yy++) { tranz_display(yy); show_data(); delay(40); } } void show_temp(){ tranz_display(32); show_data(); for(int yy = 0; yy <= 300; yy++) { show_data(); delay(1); } } void show_temp_to_hour(){ for(int yy = 0; yy <= 32; yy++) { tranz_display(yy+32); show_data(); delay(40); } } void loop() { if (dp != digitalRead(interruptPin)) { //Serial.println( ESP.getFreeHeap()); if (WiFi.status() == WL_CONNECTED) { wifi_en =128; if (wifi_prim == 0) { Serial.println("ESP is now conected!!!"); Serial.print("IP adress = "); Serial.println(WiFi.localIP()); wifi_prim = 1 ; wifi_id = wifi_stat; } } else { wifi_en =0; if (wifi_prim == 1) { Serial.println("ESP is disconected!!!"); wifi_prim = 0 ; wifi_id = 0; } // daca e deconectat, la 10 sec se comuta intre cele doua retele t_sec = (second/10) % 2; if (t_sec != t_secp) { t_secp = t_sec; Serial.println("Se schimba reteaua"); if (t_sec) { Serial.print("Se incearca conectarea la reteaua ");Serial.println(ssid1); WiFi.begin(ssid1, password1); wifi_stat = 128; } else{ Serial.print("Se incearca conectarea la reteaua ");Serial.println(ssid2); WiFi.begin(ssid2, password2); wifi_stat = 1; } } } kt = kt + 1; if (kt == 28) { kt = 0; } dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); if ((kt % 4) == 0) { conv_temp_without_adress(); } else { if ((kt % 4) == 2) { read_temp_without_adress(); } } } change_controls(); read_RTC(); show_hour(); if (dp == 1) { if ((second == 5) || (second == 25) || (second == 45)) { show_hour_to_temp(); show_temp(); show_temp_to_hour(); } } ws.cleanupClients(); }
  2. Kreator

    Ceas RGB WIFI

    Datasheetul spune ca dupa orice operatie de scriere trebuie sa astepti tWR = 10 ms ca sa poti scrie din nou in el: BYTE WRITE: A write operation requires two 8-bit data word addresses following the device address word and acknowledgment. Upon receipt of this address, the EEPROM will again respond with a zero and then clock in the first 8-bit data word. Following receipt of the 8-bit data word, the EEPROM will output a zero and the addressing device, such as a microcontroller, must terminate the write sequence with a stop condition. At this time the EEPROM enters an internally-timed write cycle, tWR, to the nonvolatile memory. All inputs are disabled during this write cycle and the EEPROM will not respond until the write is complete.
  3. Kreator

    Ceas RGB WIFI

    Am rescris codul (dupa cum m-am priceput) sa porneasca cu sau fara legatura la WiFi si am eliminat necesitatea bibliotecii "DallasTemperature". Cum sa-l fac sa se reconecteze automat cand pierde legatuta WiFi? #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> #include <ESPAsyncWebServer.h> #include <Wire.h> #include <Adafruit_NeoPixel.h> #include <OneWire.h> // Pinul conectat la DS18b20 OneWire ds(D6); // Pinul conectat INPUT Data display #define LED_PIN D7 // Nr de leduri al display-ului #define LED_COUNT 256 // Intensitatea, 0 {min) to 255 {max) // #define BRIGHTNESS 5 // Set BRIGHTNESS to about 1/5 {max = 255) // DS3231_I2C_ADDRESS #define DS3231_I2C_ADDRESS 0x68 #define EEPROM_I2C_ADDRESS 0x57 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Replace with your network credentials const char* ssid = "xxxxx"; //reteaua WiFi la care se conecteaza const char* password = "xxxxx"; // parola pt conectare la retea String sliderValue1 = "128"; // valoare initiala pt slider1 String sliderValue2 = "128"; // valoare initiala pt slider2 String sliderValue3 = "128"; // valoare initiala pt slider3 String sliderValue4 = "5"; // valoare initiala pt slider4 String ora_new = "20"; // valoare initiala pt ora_new String minut_new = "05"; // valoare initiala pt minut_new String ora_change = "0"; // valoare initiala pt ora_change (daca se schimba ora trece in 1) String minut_change = "0"; // valoare initiala pt minut_change (daca se schimba minut trece in 1) String sliderValue1_new = "0"; String sliderValue2_new = "0"; String sliderValue3_new = "0"; String sliderValue4_new = "0"; String sliderValue1_change = "0"; // valoare initiala pt sliderValue1_change (daca se schimba ora trece in 1) String sliderValue2_change = "0"; // valoare initiala pt sliderValue2_change (daca se schimba minut trece in 1) String sliderValue3_change = "0"; // valoare initiala pt sliderValue3_change (daca se schimba minut trece in 1) String sliderValue4_change = "0"; // valoare initiala pt sliderValue4_change (daca se schimba minut trece in 1) String ora_val = "20"; // valoare initiala pt ora String minut_val = "14"; // valoare initiala pt minut const char* PARAM_INPUT1 = "value1"; //valoare folosita pentru cautarea valorii lui slider1 // vezi in xhr.open("GET", "/slider?value1="+sliderValue1, true); const char* PARAM_INPUT1_CHANGE = "value1_change"; //valoare folosita pentru alerta schimbarii slider1 // vezi in xhr.open("GET", "/slider?value1_change="+sliderValue1, true); const char* PARAM_INPUT2 = "value2"; //valoare folosita pentru cautarea valorii lui slider2 // vezi in xhr.open("GET", "/slider?value2="+sliderValue2, true); const char* PARAM_INPUT2_CHANGE = "value2_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value2_change="+sliderValue2, true); const char* PARAM_INPUT3 = "value3"; //valoare folosita pentru cautarea valorii lui slider3 // vezi in xhr.open("GET", "/slider?value3="+sliderValue3, true); const char* PARAM_INPUT3_CHANGE = "value3_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xxhr.open("GET", "/slider?value3_change="+sliderValue3, true); const char* PARAM_INPUT4 = "value4"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4="+sliderValue4, true); const char* PARAM_INPUT4_CHANGE = "value4_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4_change="+sliderValue4, true); const char* PARAM_INPUT_ORA = "value_ora"; //valoare folosita pentru cautarea valorii ora // vezi in /xhr.open("GET", "/slider?value_ora="+ora_new, true); const char* PARAM_INPUT_MINUT = "value_minut"; //valoare folosita pentru cautarea valorii minut // vezi in xhr.open("GET", "/slider?value_minut="+minut_new, true); // Create AsyncWebServer object on port 80 AsyncWebServer server(80); AsyncWebSocket ws("/ws"); byte rosu = 100, verde = 0, albastru = 50, BRIGHTNESS = 5; byte red, green, blue, umin, zmin, uhour, zhour; byte dsp_ora [32], dsp_th [32], dsp_tot[96]; byte ma[8], sa[8], za[8], uua[8], utmp[8], ztmp[8], stmp[8], ltmp[8], rtmp[8], mtmp[8]; byte dsp[32], dsp_tmp[32]; byte second, minute, hour, dp; byte th0, th1, tsgn, kt=0, k, k_con = 0; byte s0, s1, m0, m1, h0, h1; byte array_disp[256]; float t_read; int xxx; byte addr_DS[8]; //to hold 64-bit ROM Codes of DS18B20 byte data_temperature[9]; //buffer to hold data coming from Scratchpad memory of DS18B20 byte dsRes[] = {0x00, 0x00, 0x7F};//, 0x1F(0 R1 R0 11111)/0x3F/0x5F/0x7F for 9-10-11-12-bit Resolution byte x = 0; // SET resolution of DS18B20 const byte resolution = 9; // 9-10-11-12-bit Resolution // Set LED GPIO const int ledPin1 = LED_BUILTIN; // pin atasat la INT RTC const byte interruptPin = D5; // litere si cifre const byte alfabet [17] [7]= {{126, 255, 195, 195, 255, 126, 0}, //0 { 1, 255, 255, 97, 32, 0, 0}, //1 { 99, 243, 219, 207, 199, 99, 0}, //2 { 102,255, 219, 219, 195, 102, 0}, //3 { 5, 255, 255, 101, 60 ,28, 0}, //4 { 78, 223, 211, 211, 251, 250, 0}, //5 { 78, 223, 211, 211, 255, 126, 0}, //6 {224, 240, 223, 207, 192, 192, 0}, //7 {110, 255, 219, 219, 255, 110, 0}, //8 {126, 255, 203, 203, 251, 114, 0}, //9 { 0, 0, 0, 0, 0, 0, 0}, //blank {102, 102, 0, 0, 0, 0, 0}, //dp {102, 195, 195, 195, 255, 126, 0}, //C {112, 248, 136, 248, 112, 0, 0}, //` {110, 255, 211, 211, 255, 255, 0}, //B { 48, 48, 24, 63, 63, 0, 0}, //r { 24, 24, 24, 0, 0, 0, 0}}; //- // Convert normal decimal numbers to binary coded decimal byte decToBcd(byte val) { return( (val/10*16) + (val%10) ); } // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte val) { return( (val/16*10) + (val%16) ); } byte readEEPROM(int deviceaddress, unsigned int eeaddress ) { byte rdata = 0xFF; Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.endTransmission(); delay(10); Wire.requestFrom(deviceaddress,1); if (Wire.available()) rdata = Wire.read(); return rdata; } // incepe serverul html const char index_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML><html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CEAS RGB</title> <style> html { font-family: Arial, Helvetica, sans-serif; display: inline-block; text-align: center; } h1 { font-size: 1.8rem; color: white; } p { font-size: 1.4rem; } .topnav { overflow: hidden; background-color: #034078; } body { margin: 0; } .content { padding: 30px; } .card-grid { max-width: 500px; margin: 0 auto; display: grid; grid-gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .card { background-color: white; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); } } .card-title { font-size: 1.2rem; font-weight: bold; color: #034078 } .state { font-size: 1.2rem; color:#1282A2; } .slider { -webkit-appearance: none; margin: 0 auto; width: 90%; height: 15px; border-radius: 10px; background: #C0C0C0; outline: none; } .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; border-radius: 50 ; background: #034078; cursor: pointer; } .switch { padding-left: 5; } </style> </head> <body> <div class="topnav"> <h1><span style="color:white">CEAS </span><span style="color:#ff3300">R</span><span style="color:#33cc33">G</span><span style="color:#3399ff">B</span></h1> </div> <p> </p> <span class="inlineinput"><input type="number" onchange="update_ora(this)" id="ora" value="%VAL_ORA%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300;font-weight: bold; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <span style='display: inline; font-size: 4rem ; text-align: center; color:#ff3300 ; font-weight: bold;'>:</span> <span class="inlineinput"> <input type="number" onchange="update_minut(this)" id="minut" value="%VAL_MINUT%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300; font-weight: bold;box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <div class="content"> <div class="card-grid"> <div class="card"> <p class="switch"> <input type="range" onchange="Slider1_change(this)" oninput="updateSlider1(this)" id="Sliderx1" min="0" max="255" value="%SLIDERVALUE1%" step="1" class="slider"></p> <p class="state"><span style='color:#ff0000; font-weight: bold;'>ROSU=<span id="textSlider1Value">%SLIDERVALUE1%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider2_change(this)" oninput="updateSlider2(this)" id="Sliderx2" min="0" max="255" value="%SLIDERVALUE2%" step="1" class="slider"></p> <p class="state"><span style='color:#33cc33; font-weight: bold;'>VERDE=<span id="textSlider2Value">%SLIDERVALUE2%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider3_change(this)" oninput="updateSlider3(this)" id="Sliderx3" min="0" max="255" value="%SLIDERVALUE3%" step="1" class="slider"></p> <p class="state"><span style='color:#0000ff; font-weight: bold;'>ALBASTRU=<span id="textSlider3Value">%SLIDERVALUE3%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider4_change(this)" oninput="updateSlider4(this)" id="Sliderx4" min="1" max="255" value="%SLIDERVALUE4%" step="1" class="slider"></p> <p class="state"><span style='color: #797979; font-weight: bold;'>STRALUCIRE=<span id="textSlider4Value">%SLIDERVALUE4%</span></p> </div> </div> </div> <script> function updateSlider1(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1="+sliderValue1, true); xhr.send(); } function Slider1_change(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1_change="+sliderValue1, true); xhr.send(); } function updateSlider2(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2="+sliderValue2, true); xhr.send(); } function Slider2_change(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2_change="+sliderValue2, true); xhr.send(); } function updateSlider3(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3="+sliderValue3, true); xhr.send(); } function Slider3_change(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3_change="+sliderValue3, true); xhr.send(); } function updateSlider4(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4="+sliderValue4, true); xhr.send(); } function Slider4_change(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4_change="+sliderValue4, true); xhr.send(); } function update_ora(element) { var ora_new = document.getElementById("ora").value; console.log(ora_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_ora="+ora_new, true); xhr.send(); } function update_minut(element) { var minut_new = document.getElementById("minut").value; console.log(minut_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_minut="+minut_new, true); xhr.send(); } </script> </body> </html> )rawliteral"; // sfarsitul serverului html // Replaces placeholder with button section in your web page String processor(const String& var){ //Serial.println(var); if (var == "SLIDERVALUE1"){ return sliderValue1; } if (var == "SLIDERVALUE2"){ return sliderValue2; } if (var == "SLIDERVALUE3"){ return sliderValue3; } if (var == "SLIDERVALUE4"){ return sliderValue4; } if (var == "VAL_ORA"){ return ora_val; } if (var == "VAL_MINUT"){ return minut_val; } return String(); } void setup(){ // Serial port for debugging purposes Serial.begin(115200); Wire.begin(D2, D1); ds.reset(); ds.search(addr_DS); //collect 64-bit ROM code from sensor (DS1)t switch (resolution) { case 9: dsRes[2] = 0x1F; break; case 10: dsRes[2] = 0x3F; break; case 11: dsRes[2] = 0x5F; break; case 12: dsRes[2] = 0x7F; break; } // init display strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); strip.clear(); strip.show(); delay(500); /// Square wave is output on the INT/SQW pin Wire.beginTransmission(DS3231_I2C_ADDRESS); // transmit to DS3231 I2C_ADDRESS = 0x68 Wire.write(byte(0x0E)); // transmit adress memory Wire.write(0); // sends 0 = square output to INT pin Wire.endTransmission(); // stop transmitting //// pinMode(interruptPin, INPUT); pinMode(LED_BUILTIN, OUTPUT); //setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) //setDS3231time(0, 9, 00, 7, 18, 04, 22); sliderValue1 = String(readEEPROM(EEPROM_I2C_ADDRESS, 1)); sliderValue2 = String(readEEPROM(EEPROM_I2C_ADDRESS, 2)); sliderValue3 = String(readEEPROM(EEPROM_I2C_ADDRESS, 3)); sliderValue4 = String(readEEPROM(EEPROM_I2C_ADDRESS, 4)); // Connect to Wi-Fi WiFi.setSleepMode(WIFI_NONE_SLEEP); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); k_con = k_con + 1; Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); if (k_con == 10) { Serial.println("Fara conexiune la WiFi"); break; } } if (WiFi.status() == WL_CONNECTED) { Serial.print("WiFi.status() = ");Serial.println(WiFi.status()); Serial.print("WL_CONNECTED = ");Serial.println(WL_CONNECTED); send_web_page(); Serial.println("Conectat la WiFi"); } } void conv_temp_without_adress(){ ds.write(0x4E); ds.write_bytes(dsRes, 3); //set resolution bit //---------------------------------------------- ds.reset(); //bring 1-Wire into idle state ds.write(0xCC); //slect with DS-1 with address addr_DS ds.write(0x44); //conversion command } void read_temp_without_adress(){ ds.reset(); ds.write(0xCC); //selectimg the desired DS18B20 ds.write(0xBE); //Function command to read Scratchpad Memory (9Byte) ds.read_bytes(data_temperature, 9); //data comes from DS and are saved into buffer data[8] //------------------------------------------------------------ unsigned int rawTemp = (int)(data_temperature[1] << 4); //upper 4-bit of integer part of temperature byte n = data_temperature[0]; //n = lower 4-bit of integer part and 4-bit fractional part of temperature data_temperature[0] = data_temperature[0] >> 4; //lower 4-bit integer part of temperature rawTemp = rawTemp | (int)data_temperature[0]; //8-bit (including sign bit) integer part of temperature t_read = (float)rawTemp + 0.5 * bitRead(n, 3) + 0.25 * bitRead(n, 2) + 0.125 * bitRead(n, 1) + 0.0625 * bitRead(n, 0); //temp in float format xxx = t_read; if (xxx < 0) { tsgn = 16; xxx = -xxx; } else { tsgn = 10; } th0 = xxx / 10; th1 = xxx % 10; } void send_web_page() { // Print ESP Local IP Address Serial.println(WiFi.localIP()); // Route for root / web page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); }); // Send a GET request to <ESP_IP>/slider?value=<inputMessage> server.on("/slider", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessageslider1; String inputMessageslider2; String inputMessageslider3; String inputMessageslider4; String inputMessageora; String inputMessageminut; // GET input1 value on <ESP_IP>/slider1?value1=<inputMessageslider1> if (request->hasParam(PARAM_INPUT1)) { inputMessageslider1 = request->getParam(PARAM_INPUT1)->value(); sliderValue1 = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } if (request->hasParam(PARAM_INPUT1_CHANGE)) { sliderValue1_change = "1"; inputMessageslider1 = request->getParam(PARAM_INPUT1_CHANGE)->value(); sliderValue1_new = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } // GET input1 value on <ESP_IP>/slider2?value2=<inputMessageslider2> if (request->hasParam(PARAM_INPUT2)) { inputMessageslider2 = request->getParam(PARAM_INPUT2)->value(); sliderValue2 = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } if (request->hasParam(PARAM_INPUT2_CHANGE)) { sliderValue2_change = "1"; inputMessageslider2 = request->getParam(PARAM_INPUT2_CHANGE)->value(); sliderValue2_new = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } // GET input1 value on <ESP_IP>/slider3?value3=<inputMessageslider3> if (request->hasParam(PARAM_INPUT3)) { inputMessageslider3 = request->getParam(PARAM_INPUT3)->value(); sliderValue3 = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT3_CHANGE)) { sliderValue3_change = "1"; inputMessageslider3 = request->getParam(PARAM_INPUT3_CHANGE)->value(); sliderValue3_new = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT4)) { inputMessageslider4 = request->getParam(PARAM_INPUT4)->value(); sliderValue4 = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } if (request->hasParam(PARAM_INPUT4_CHANGE)) { sliderValue4_change = "1"; inputMessageslider4 = request->getParam(PARAM_INPUT4_CHANGE)->value(); sliderValue4_new = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } // GET input1 value on <ESP_IP>/slider4?value4=<inputMessageslider4> if (request->hasParam(PARAM_INPUT_ORA)) { ora_change = "1"; inputMessageora = request->getParam(PARAM_INPUT_ORA)->value(); ora_new = inputMessageora; } else { inputMessageora = "No message sent"; } if (request->hasParam(PARAM_INPUT_MINUT)) { minut_change = "1"; inputMessageminut = request->getParam(PARAM_INPUT_MINUT)->value(); minut_new = inputMessageminut; } else { inputMessageminut = "No message sent"; } request->send(200, "text/plain", "OK"); }); // Start server server.begin(); } void I2Cwrite(byte ID, byte adress, byte value) { Wire.beginTransmission(ID); //select ID device Wire.write(adress); // move pointer to adress address Wire.write(value); // sends value Wire.endTransmission(); } void I2CRead(uint8_t ID, uint8_t adress, byte *xxx) { Wire.beginTransmission(ID); Wire.write(adress); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom((uint8_t) ID, (uint8_t) 1); // request seven bytes of data from DS3231 starting from register 00h *xxx = Wire.read(); } void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231 Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set next input to start at the seconds register Wire.write(decToBcd(second)); // set seconds Wire.write(decToBcd(minute)); // set minutes Wire.write(decToBcd(hour)); // set hours Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday) Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31) Wire.write(decToBcd(month)); // set month Wire.write(decToBcd(year)); // set year (0 to 99) Wire.endTransmission(); } void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) { Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.write(data); delay(10); Wire.endTransmission(); delay(10); } void read_RTC() { Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom(DS3231_I2C_ADDRESS, 3); // request seven bytes of data from DS3231 starting from register 00h second = bcdToDec(Wire.read() & 0x7f); s0 = second /10; s1 = second %10; minute = bcdToDec(Wire.read()); m0 = minute/10; m1 = minute %10; hour = bcdToDec(Wire.read() & 0x3f); h0 = hour/10; h1 = hour %10; if (hour <= 9) { ora_val = "0" + String(hour); } else { ora_val = String(hour); } if (minute <= 9) { minut_val = "0" + String(minute); } else { minut_val = String(minute); } } //Prepare hour data void prepare_to_show_hour(byte m, byte s_, byte z_, byte u_i, byte dp1){ for(int i = 0; i <= 31; i++) { dsp_ora [i] = 0; } for(int i=0; i<=2; i++) { if (dp ==1) { dsp_ora [i+14] = alfabet [11] [i]; } else { dsp_ora [i+14] = alfabet [10] [i]; } } for(int i = 0; i <= 5; i++) { dsp_ora [i] = alfabet [u_i] [i]; dsp_ora [i+7] = alfabet [z_] [i]; dsp_ora [i+17] = alfabet [s_] [i]; dsp_ora [i+24] = alfabet [m] [i]; } for(int i = 0; i <= 31; i++) { dsp_tot[i] = dsp_ora [i] ; dsp_tot[i+64] = dsp_ora [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_ora [j], i%8); array_disp[i] = bt; } } // Prepare Temperature data void prepare_to_show_temp(byte tsgn, byte iz_, byte iu){ for(int i = 0; i <= 31; i++) { dsp_th [i] = 0; } for(int i = 0; i <= 5; i++) { dsp_th [i+1] = alfabet [12] [i]; dsp_th [i+8] = alfabet [13] [i]; dsp_th [i+14] = alfabet [iu] [i]; dsp_th [i+21] = alfabet [iz_] [i]; dsp_th [i+28] = alfabet [tsgn] [i]; } for(int i = 0; i <= 31; i++) { dsp_tot[i+32] = dsp_th [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_th [j], i%8); array_disp[i] = bt; } } void tranz_display(byte kk) { for(byte i = 0; i <= 31; i++) { dsp_tmp[i] = dsp_tot[i+64 - kk]; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_tmp[j], i%8); array_disp[i] = bt; } } void read_sliders() { rosu = sliderValue1.toInt(); verde = sliderValue2.toInt(); albastru = sliderValue3.toInt(); BRIGHTNESS= sliderValue4.toInt(); } void change_controls(){ if (ora_change.toInt() == 1) { ora_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 2, decToBcd(ora_new.toInt())); } if (minut_change.toInt() == 1) { minut_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 1, decToBcd(minut_new.toInt())); I2Cwrite(DS3231_I2C_ADDRESS, 0, 0); } if (sliderValue1_change.toInt() == 1) { sliderValue1_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 1, sliderValue1_new.toInt()); } if (sliderValue2_change.toInt() == 1) { sliderValue2_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 2, sliderValue2_new.toInt()); } if (sliderValue3_change.toInt() == 1) { sliderValue3_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 3, sliderValue3_new.toInt()); } if (sliderValue4_change.toInt() == 1) { sliderValue4_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 4, sliderValue4_new.toInt()); } } void show_data(){ read_sliders(); strip.setBrightness(BRIGHTNESS); dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); for(int i=0; i<=255; i++) { // For each pixel in strip... byte k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; byte bt = array_disp[i]; red = rosu * bt ; green = verde * bt ; blue = albastru * bt ; if (k <=7) { strip.setPixelColor(i, red,green,blue); // Set pixel's color (in RAM) } else { strip.setPixelColor(k1, red,green,blue); // Set pixel's color (in RAM) } } strip.show(); } void show_hour(){ prepare_to_show_hour(h0, h1, m0, m1, dp); prepare_to_show_temp(tsgn, th0, th1); tranz_display(0); show_data(); } void show_hour_to_temp(){ dp = 1; for(int yy = 0; yy <= 32; yy++) { tranz_display(yy); show_data(); delay(40); } } void show_temp(){ tranz_display(32); show_data(); for(int yy = 0; yy <= 300; yy++) { show_data(); delay(1); } } void show_temp_to_hour(){ for(int yy = 0; yy <= 32; yy++) { tranz_display(yy+32); show_data(); delay(40); } } void loop() { if (dp != digitalRead(interruptPin)) { //Serial.println( ESP.getFreeHeap()); kt = kt + 1; if (kt == 28) { kt = 0; } dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); if ((kt % 4) == 0) { conv_temp_without_adress(); } else { if ((kt % 4) == 2) { read_temp_without_adress(); } } } change_controls(); read_RTC(); show_hour(); if (dp == 1) { if ((second == 5) || (second == 25) || (second == 45)) { show_hour_to_temp(); show_temp(); show_temp_to_hour(); } } ws.cleanupClients(); }
  4. Kreator

    Ceas RGB WIFI

    Daca tot am avut ceva timp liber de sarbatorile pascale, am facut un upgrade la ceasul de aici , in sensul ca display-ul este un panel RGB cu WS2812B ca acesta comandat de un Wemos D1 mini. Schema e mai jos (desenata cum e moda acum ) Culoarea si intensitatea luminoasa a display-ului se schimba prin cele 4 slidere, iar ora si minutul prin modificarea casetelor corespunzatoare. Prin combinatia celor trei slidere care comanda culorile se obtine o paleta cromatica destul de variata. Tranzitia de la ora la temperatura si invers se face prin efect de scroll. Valorile corespunzatoare culorilor RGB si intensitatii luminoase sunt salvate in memoria AT24C32 si incarcate automat la pornire. Sketch-ul folosit e urmatorul, nu dati cu parul daca nu e optimizat si uneori e redundant, nu sunt programator, nici macar cu studii de electronica dar orice observatii constructive sunt binevenite. Doritorii pot modifica Sketch-ul asfel incat culorile sa se schimbe automat, efect de curcubeu, sau alte efecte dorite. #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> #include <ESPAsyncWebServer.h> #include <Wire.h> #include <Adafruit_NeoPixel.h> #include <OneWire.h> #include <DallasTemperature.h> // Pinul conectat la DS18b20 #define oneWireBus D6 // Setup a oneWire instance to communicate with any OneWire devices OneWire oneWire(oneWireBus); // Pass our oneWire reference to Dallas Temperature sensor DallasTemperature sensors(&oneWire); DeviceAddress insideThermometer; // Pinul conectat INPUT Data display #define LED_PIN D7 // Nr de leduri al display-ului #define LED_COUNT 256 // Intensitatea, 0 {min) to 255 {max) // #define BRIGHTNESS 5 // Set BRIGHTNESS to about 1/5 {max = 255) // DS3231_I2C_ADDRESS #define DS3231_I2C_ADDRESS 0x68 #define EEPROM_I2C_ADDRESS 0x57 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Replace with your network credentials const char* ssid = "*********"; //reteaua WiFi la care se conecteaza const char* password = "********"; // parola pt conectare la retea String sliderValue1 = "128"; // valoare initiala pt slider1 String sliderValue2 = "128"; // valoare initiala pt slider2 String sliderValue3 = "128"; // valoare initiala pt slider3 String sliderValue4 = "5"; // valoare initiala pt slider4 String ora_new = "20"; // valoare initiala pt ora_new String minut_new = "05"; // valoare initiala pt minut_new String ora_change = "0"; // valoare initiala pt ora_change (daca se schimba ora trece in 1) String minut_change = "0"; // valoare initiala pt minut_change (daca se schimba minut trece in 1) String sliderValue1_new = "0"; String sliderValue2_new = "0"; String sliderValue3_new = "0"; String sliderValue4_new = "0"; String sliderValue1_change = "0"; // valoare initiala pt sliderValue1_change (daca se schimba ora trece in 1) String sliderValue2_change = "0"; // valoare initiala pt sliderValue2_change (daca se schimba minut trece in 1) String sliderValue3_change = "0"; // valoare initiala pt sliderValue3_change (daca se schimba minut trece in 1) String sliderValue4_change = "0"; // valoare initiala pt sliderValue4_change (daca se schimba minut trece in 1) String ora_val = "20"; // valoare initiala pt ora String minut_val = "14"; // valoare initiala pt minut const char* PARAM_INPUT1 = "value1"; //valoare folosita pentru cautarea valorii lui slider1 // vezi in xhr.open("GET", "/slider?value1="+sliderValue1, true); const char* PARAM_INPUT1_CHANGE = "value1_change"; //valoare folosita pentru alerta schimbarii slider1 // vezi in xhr.open("GET", "/slider?value1_change="+sliderValue1, true); const char* PARAM_INPUT2 = "value2"; //valoare folosita pentru cautarea valorii lui slider2 // vezi in xhr.open("GET", "/slider?value2="+sliderValue2, true); const char* PARAM_INPUT2_CHANGE = "value2_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value2_change="+sliderValue2, true); const char* PARAM_INPUT3 = "value3"; //valoare folosita pentru cautarea valorii lui slider3 // vezi in xhr.open("GET", "/slider?value3="+sliderValue3, true); const char* PARAM_INPUT3_CHANGE = "value3_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xxhr.open("GET", "/slider?value3_change="+sliderValue3, true); const char* PARAM_INPUT4 = "value4"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4="+sliderValue4, true); const char* PARAM_INPUT4_CHANGE = "value4_change"; //valoare folosita pentru cautarea valorii lui slider4 // vezi in xhr.open("GET", "/slider?value4_change="+sliderValue4, true); const char* PARAM_INPUT_ORA = "value_ora"; //valoare folosita pentru cautarea valorii ora // vezi in /xhr.open("GET", "/slider?value_ora="+ora_new, true); const char* PARAM_INPUT_MINUT = "value_minut"; //valoare folosita pentru cautarea valorii minut // vezi in xhr.open("GET", "/slider?value_minut="+minut_new, true); // Create AsyncWebServer object on port 80 AsyncWebServer server(80); AsyncWebSocket ws("/ws"); byte rosu = 100, verde = 0, albastru = 50, BRIGHTNESS = 5; byte red, green, blue, umin, zmin, uhour, zhour; byte dsp_ora [32], dsp_th [32], dsp_tot[96]; byte ma[8], sa[8], za[8], uua[8], utmp[8], ztmp[8], stmp[8], ltmp[8], rtmp[8], mtmp[8]; byte dsp[32], dsp_tmp[32]; byte second, minute, hour, dp; byte th0, th1, tsgn, kt=0, k; byte s0, s1, m0, m1, h0, h1; byte array_disp[256]; float t_read; int xxx; // Set LED GPIO const int ledPin1 = LED_BUILTIN; // pin atasat la INT RTC const byte interruptPin = D5; // litere si cifre const byte alfabet [17] [7]= {{126, 255, 195, 195, 255, 126, 0}, //0 { 1, 255, 255, 97, 32, 0, 0}, //1 { 99, 243, 219, 207, 199, 99, 0}, //2 { 102,255, 219, 219, 195, 102, 0}, //3 { 5, 255, 255, 101, 60 ,28, 0}, //4 { 78, 223, 211, 211, 251, 250, 0}, //5 { 78, 223, 211, 211, 255, 126, 0}, //6 {224, 240, 223, 207, 192, 192, 0}, //7 {110, 255, 219, 219, 255, 110, 0}, //8 {126, 255, 203, 203, 251, 114, 0}, //9 { 0, 0, 0, 0, 0, 0, 0}, //blank {102, 102, 0, 0, 0, 0, 0}, //dp {102, 195, 195, 195, 255, 126, 0}, //C {112, 248, 136, 248, 112, 0, 0}, //` {110, 255, 211, 211, 255, 255, 0}, //B { 48, 48, 24, 63, 63, 0, 0}, //r { 24, 24, 24, 0, 0, 0, 0}}; //- // Convert normal decimal numbers to binary coded decimal byte decToBcd(byte val) { return( (val/10*16) + (val%10) ); } // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte val) { return( (val/16*10) + (val%16) ); } byte x = 0; byte readEEPROM(int deviceaddress, unsigned int eeaddress ) { byte rdata = 0xFF; Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.endTransmission(); delay(10); Wire.requestFrom(deviceaddress,1); if (Wire.available()) rdata = Wire.read(); return rdata; } // incepe serverul html const char index_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML><html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CEAS RGB</title> <style> html { font-family: Arial, Helvetica, sans-serif; display: inline-block; text-align: center; } h1 { font-size: 1.8rem; color: white; } p { font-size: 1.4rem; } .topnav { overflow: hidden; background-color: #034078; } body { margin: 0; } .content { padding: 30px; } .card-grid { max-width: 500px; margin: 0 auto; display: grid; grid-gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .card { background-color: white; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); } } .card-title { font-size: 1.2rem; font-weight: bold; color: #034078 } .state { font-size: 1.2rem; color:#1282A2; } .slider { -webkit-appearance: none; margin: 0 auto; width: 90%; height: 15px; border-radius: 10px; background: #C0C0C0; outline: none; } .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; border-radius: 50 ; background: #034078; cursor: pointer; } .switch { padding-left: 5; } </style> </head> <body> <div class="topnav"> <h1><span style="color:white">CEAS </span><span style="color:#ff3300">R</span><span style="color:#33cc33">G</span><span style="color:#3399ff">B</span></h1> </div> <p> </p> <span class="inlineinput"><input type="number" onchange="update_ora(this)" id="ora" value="%VAL_ORA%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300;font-weight: bold; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <span style='display: inline; font-size: 4rem ; text-align: center; color:#ff3300 ; font-weight: bold;'>:</span> <span class="inlineinput"> <input type="number" onchange="update_minut(this)" id="minut" value="%VAL_MINUT%" style='display: inline; width: 120px; font-size:4rem ; text-align: center; color:#ff3300; font-weight: bold;box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); class="slider"'/></span> <div class="content"> <div class="card-grid"> <div class="card"> <p class="switch"> <input type="range" onchange="Slider1_change(this)" oninput="updateSlider1(this)" id="Sliderx1" min="0" max="255" value="%SLIDERVALUE1%" step="1" class="slider"></p> <p class="state"><span style='color:#ff0000; font-weight: bold;'>ROSU=<span id="textSlider1Value">%SLIDERVALUE1%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider2_change(this)" oninput="updateSlider2(this)" id="Sliderx2" min="0" max="255" value="%SLIDERVALUE2%" step="1" class="slider"></p> <p class="state"><span style='color:#33cc33; font-weight: bold;'>VERDE=<span id="textSlider2Value">%SLIDERVALUE2%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider3_change(this)" oninput="updateSlider3(this)" id="Sliderx3" min="0" max="255" value="%SLIDERVALUE3%" step="1" class="slider"></p> <p class="state"><span style='color:#0000ff; font-weight: bold;'>ALBASTRU=<span id="textSlider3Value">%SLIDERVALUE3%</span></p> </div> <div class="card"> <p class="switch"> <input type="range" onchange="Slider4_change(this)" oninput="updateSlider4(this)" id="Sliderx4" min="1" max="255" value="%SLIDERVALUE4%" step="1" class="slider"></p> <p class="state"><span style='color: #797979; font-weight: bold;'>STRALUCIRE=<span id="textSlider4Value">%SLIDERVALUE4%</span></p> </div> </div> </div> <script> function updateSlider1(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1="+sliderValue1, true); xhr.send(); } function Slider1_change(element) { var sliderValue1 = document.getElementById("Sliderx1").value; document.getElementById("textSlider1Value").innerHTML = sliderValue1; console.log(sliderValue1); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value1_change="+sliderValue1, true); xhr.send(); } function updateSlider2(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2="+sliderValue2, true); xhr.send(); } function Slider2_change(element) { var sliderValue2 = document.getElementById("Sliderx2").value; document.getElementById("textSlider2Value").innerHTML = sliderValue2; console.log(sliderValue2); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value2_change="+sliderValue2, true); xhr.send(); } function updateSlider3(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3="+sliderValue3, true); xhr.send(); } function Slider3_change(element) { var sliderValue3 = document.getElementById("Sliderx3").value; document.getElementById("textSlider3Value").innerHTML = sliderValue3; console.log(sliderValue3); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value3_change="+sliderValue3, true); xhr.send(); } function updateSlider4(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4="+sliderValue4, true); xhr.send(); } function Slider4_change(element) { var sliderValue4 = document.getElementById("Sliderx4").value; document.getElementById("textSlider4Value").innerHTML = sliderValue4; console.log(sliderValue4); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value4_change="+sliderValue4, true); xhr.send(); } function update_ora(element) { var ora_new = document.getElementById("ora").value; console.log(ora_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_ora="+ora_new, true); xhr.send(); } function update_minut(element) { var minut_new = document.getElementById("minut").value; console.log(minut_new); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value_minut="+minut_new, true); xhr.send(); } </script> </body> </html> )rawliteral"; // sfarsitul serverului html // Replaces placeholder with button section in your web page String processor(const String& var){ //Serial.println(var); if (var == "SLIDERVALUE1"){ return sliderValue1; } if (var == "SLIDERVALUE2"){ return sliderValue2; } if (var == "SLIDERVALUE3"){ return sliderValue3; } if (var == "SLIDERVALUE4"){ return sliderValue4; } if (var == "VAL_ORA"){ return ora_val; } if (var == "VAL_MINUT"){ return minut_val; } return String(); } void setup(){ // Serial port for debugging purposes Serial.begin(115200); Wire.begin(D2, D1); sensors.begin(); sensors.setResolution(9); // init display strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); strip.clear(); strip.show(); delay(500); /// Square wave is output on the INT/SQW pin Wire.beginTransmission(DS3231_I2C_ADDRESS); // transmit to DS3231 I2C_ADDRESS = 0x68 Wire.write(byte(0x0E)); // transmit adress memory Wire.write(0); // sends 0 = square output to INT pin Wire.endTransmission(); // stop transmitting //// pinMode(interruptPin, INPUT); pinMode(LED_BUILTIN, OUTPUT); //setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) //setDS3231time(0, 9, 00, 7, 18, 04, 22); sliderValue1 = String(readEEPROM(EEPROM_I2C_ADDRESS, 1)); sliderValue2 = String(readEEPROM(EEPROM_I2C_ADDRESS, 2)); sliderValue3 = String(readEEPROM(EEPROM_I2C_ADDRESS, 3)); sliderValue4 = String(readEEPROM(EEPROM_I2C_ADDRESS, 4)); // Connect to Wi-Fi send_web_page(); } void send_web_page() { WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } // Print ESP Local IP Address Serial.println(WiFi.localIP()); // Route for root / web page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); }); // Send a GET request to <ESP_IP>/slider?value=<inputMessage> server.on("/slider", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessageslider1; String inputMessageslider2; String inputMessageslider3; String inputMessageslider4; String inputMessageora; String inputMessageminut; // GET input1 value on <ESP_IP>/slider1?value1=<inputMessageslider1> if (request->hasParam(PARAM_INPUT1)) { inputMessageslider1 = request->getParam(PARAM_INPUT1)->value(); sliderValue1 = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } if (request->hasParam(PARAM_INPUT1_CHANGE)) { sliderValue1_change = "1"; inputMessageslider1 = request->getParam(PARAM_INPUT1_CHANGE)->value(); sliderValue1_new = inputMessageslider1; } else { inputMessageslider1 = "No message sent"; } // GET input1 value on <ESP_IP>/slider2?value2=<inputMessageslider2> if (request->hasParam(PARAM_INPUT2)) { inputMessageslider2 = request->getParam(PARAM_INPUT2)->value(); sliderValue2 = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } if (request->hasParam(PARAM_INPUT2_CHANGE)) { sliderValue2_change = "1"; inputMessageslider2 = request->getParam(PARAM_INPUT2_CHANGE)->value(); sliderValue2_new = inputMessageslider2; } else { inputMessageslider2 = "No message sent"; } // GET input1 value on <ESP_IP>/slider3?value3=<inputMessageslider3> if (request->hasParam(PARAM_INPUT3)) { inputMessageslider3 = request->getParam(PARAM_INPUT3)->value(); sliderValue3 = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT3_CHANGE)) { sliderValue3_change = "1"; inputMessageslider3 = request->getParam(PARAM_INPUT3_CHANGE)->value(); sliderValue3_new = inputMessageslider3; } else { inputMessageslider3 = "No message sent"; } if (request->hasParam(PARAM_INPUT4)) { inputMessageslider4 = request->getParam(PARAM_INPUT4)->value(); sliderValue4 = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } if (request->hasParam(PARAM_INPUT4_CHANGE)) { sliderValue4_change = "1"; inputMessageslider4 = request->getParam(PARAM_INPUT4_CHANGE)->value(); sliderValue4_new = inputMessageslider4; } else { inputMessageslider4 = "No message sent"; } // GET input1 value on <ESP_IP>/slider4?value4=<inputMessageslider4> if (request->hasParam(PARAM_INPUT_ORA)) { ora_change = "1"; inputMessageora = request->getParam(PARAM_INPUT_ORA)->value(); ora_new = inputMessageora; } else { inputMessageora = "No message sent"; } if (request->hasParam(PARAM_INPUT_MINUT)) { minut_change = "1"; inputMessageminut = request->getParam(PARAM_INPUT_MINUT)->value(); minut_new = inputMessageminut; } else { inputMessageminut = "No message sent"; } request->send(200, "text/plain", "OK"); }); // Start server server.begin(); } void I2Cwrite(byte ID, byte adress, byte value) { Wire.beginTransmission(ID); //select ID device Wire.write(adress); // move pointer to adress address Wire.write(value); // sends value Wire.endTransmission(); } void I2CRead(uint8_t ID, uint8_t adress, byte *xxx) { Wire.beginTransmission(ID); Wire.write(adress); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom((uint8_t) ID, (uint8_t) 1); // request seven bytes of data from DS3231 starting from register 00h *xxx = Wire.read(); } void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231 Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set next input to start at the seconds register Wire.write(decToBcd(second)); // set seconds Wire.write(decToBcd(minute)); // set minutes Wire.write(decToBcd(hour)); // set hours Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday) Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31) Wire.write(decToBcd(month)); // set month Wire.write(decToBcd(year)); // set year (0 to 99) Wire.endTransmission(); } void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) { Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); //writes the MSB Wire.write((int)(eeaddress & 0xFF)); //writes the LSB Wire.write(data); delay(10); Wire.endTransmission(); delay(10); } void read_RTC() { Wire.beginTransmission(DS3231_I2C_ADDRESS); Wire.write(0); // set DS3231 register pointer to 00h Wire.endTransmission(); Wire.requestFrom(DS3231_I2C_ADDRESS, 3); // request seven bytes of data from DS3231 starting from register 00h second = bcdToDec(Wire.read() & 0x7f); s0 = second /10; s1 = second %10; minute = bcdToDec(Wire.read()); m0 = minute/10; m1 = minute %10; hour = bcdToDec(Wire.read() & 0x3f); h0 = hour/10; h1 = hour %10; if (hour <= 9) { ora_val = "0" + String(hour); } else { ora_val = String(hour); } if (minute <= 9) { minut_val = "0" + String(minute); } else { minut_val = String(minute); } } void read_temperature() { t_read = sensors.getTempCByIndex(0); //Serial.println(t_read); xxx = t_read; if (xxx < 0) { tsgn = 16; xxx = -xxx; } else { tsgn = 10; } th0 = xxx / 10; th1 = xxx % 10; } //Prepare hour data void prepare_to_show_hour(byte m, byte s_, byte z_, byte u_i, byte dp1){ for(int i = 0; i <= 31; i++) { dsp_ora [i] = 0; } for(int i=0; i<=2; i++) { if (dp ==1) { dsp_ora [i+14] = alfabet [11] [i]; } else { dsp_ora [i+14] = alfabet [10] [i]; } } for(int i = 0; i <= 5; i++) { dsp_ora [i] = alfabet [u_i] [i]; dsp_ora [i+7] = alfabet [z_] [i]; dsp_ora [i+17] = alfabet [s_] [i]; dsp_ora [i+24] = alfabet [m] [i]; } for(int i = 0; i <= 31; i++) { dsp_tot[i] = dsp_ora [i] ; dsp_tot[i+64] = dsp_ora [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_ora [j], i%8); array_disp[i] = bt; } } // Prepare Temperature data void prepare_to_show_temp(byte tsgn, byte iz_, byte iu){ for(int i = 0; i <= 31; i++) { dsp_th [i] = 0; } for(int i = 0; i <= 5; i++) { dsp_th [i+1] = alfabet [12] [i]; dsp_th [i+8] = alfabet [13] [i]; dsp_th [i+14] = alfabet [iu] [i]; dsp_th [i+21] = alfabet [iz_] [i]; dsp_th [i+28] = alfabet [tsgn] [i]; } for(int i = 0; i <= 31; i++) { dsp_tot[i+32] = dsp_th [i] ; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_th [j], i%8); array_disp[i] = bt; } } void tranz_display(byte kk) { for(byte i = 0; i <= 31; i++) { dsp_tmp[i] = dsp_tot[i+64 - kk]; } for(int i=0; i<=255; i++) { // For each pixel in strip... k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; int bt = bitRead(dsp_tmp[j], i%8); array_disp[i] = bt; } } void read_sliders() { rosu = sliderValue1.toInt(); verde = sliderValue2.toInt(); albastru = sliderValue3.toInt(); BRIGHTNESS= sliderValue4.toInt(); } void change_controls(){ if (ora_change.toInt() == 1) { ora_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 2, decToBcd(ora_new.toInt())); } if (minut_change.toInt() == 1) { minut_change = "0"; I2Cwrite(DS3231_I2C_ADDRESS, 1, decToBcd(minut_new.toInt())); I2Cwrite(DS3231_I2C_ADDRESS, 0, 0); } if (sliderValue1_change.toInt() == 1) { sliderValue1_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 1, sliderValue1_new.toInt()); } if (sliderValue2_change.toInt() == 1) { sliderValue2_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 2, sliderValue2_new.toInt()); } if (sliderValue3_change.toInt() == 1) { sliderValue3_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 3, sliderValue3_new.toInt()); } if (sliderValue4_change.toInt() == 1) { sliderValue4_change = "0"; writeEEPROM(EEPROM_I2C_ADDRESS, 4, sliderValue4_new.toInt()); } } void show_data(){ read_sliders(); strip.setBrightness(BRIGHTNESS); dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); for(int i=0; i<=255; i++) { // For each pixel in strip... byte k = i % 16; byte j = i/8; byte k1 = 8*(j+1)-(i % 8) - 1; byte bt = array_disp[i]; red = rosu * bt ; green = verde * bt ; blue = albastru * bt ; if (k <=7) { strip.setPixelColor(i, red,green,blue); // Set pixel's color (in RAM) } else { strip.setPixelColor(k1, red,green,blue); // Set pixel's color (in RAM) } } strip.show(); } void show_hour(){ prepare_to_show_hour(h0, h1, m0, m1, dp); prepare_to_show_temp(tsgn, th0, th1); tranz_display(0); show_data(); } void show_hour_to_temp(){ dp = 1; for(int yy = 0; yy <= 32; yy++) { tranz_display(yy); show_data(); delay(40); } } void show_temp(){ tranz_display(32); show_data(); for(int yy = 0; yy <= 300; yy++) { show_data(); delay(1); } } void show_temp_to_hour(){ for(int yy = 0; yy <= 32; yy++) { tranz_display(yy+32); show_data(); delay(40); } } void loop() { if (dp != digitalRead(interruptPin)) { Serial.println( ESP.getFreeHeap()); kt = kt + 1; if (kt == 28) { kt = 0; } dp = digitalRead(interruptPin); digitalWrite(LED_BUILTIN, !dp); if ((kt % 4) == 0 ) { read_temperature(); } else { if ((kt % 4) == 2) { sensors.requestTemperatures(); } } } change_controls(); read_RTC(); show_hour(); if (dp == 1) { if ((second == 5) || (second == 25) || (second == 45)) { show_hour_to_temp(); show_temp(); show_temp_to_hour(); } } ws.cleanupClients(); } Have a fun!
  5. Kreator

    NodeMCU

    Buna ziua, Revin cu o problema de conexiune. Am activat serviciului Dinamic DNS oferit de RCS&RDS, si apoi am facut port forwarding dupa MAC la modulul ESP8266. Routerul este KAON Media AR4010N. intampin doua probleme: 1. Daca accesez din reteaua locala www.numeserver.go.ro:xxxx, nu pot accesa serverul, accesarea din reteaua locala se poate face doar cu IP. Daca accesez din exterior merge! Acelasi lucru l-am facut si in alta locatie cu un alt router dar acolo pot accesa www.numeserver.go.ro:xxxx si din reteaua locala si din exterior. Ce trebuie configurat in routerul KAON sa functioneze corect? 2. O exceptie de la ce am spus mai sus este un program care nu merge decat din reteaua locala (cu acces prin IP), Daca accesez din internet www.numeserver.go.ro:xxxx se incarca pagina, dar controalele nu functioneaza, iar apoi nu mai pot accesa serverul nici local, (eroare adress_unrechable). Totul revinee la normal prin reset la nodemcu. De ce se intampla asta? Daca e nevoie postez si programele folosite.
  6. @nico_2010 Ma joc cu un display LED_RGB conectat la un NodeMCU (de fapt e un ceas) si vreau sa-i schimb culoarea si sa-i setez ora de pe telefon.
  7. Multumesc mult, @Liviu M!!! Am inlocuit si merge exact cum mi-am dorit!
  8. Buna ziua, Am facut o pagina care are trei slide-uri. Va rog frumos sa-mi dati o idee cum se poate schimba culoarea unui text in html (rgb) in functie de valorile celor trei slide-uri. Mai jos este ce am incercat pana acum: <!DOCTYPE HTML><html><head> <title>Ceas curcubeu</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <head> <form action="/get"> <style> body {background-color:#ededfe;} h1 { text-align: center; color: #4CAF50; } h2 { text-align: center; color: rgb(1, 100, 50); } .slidecontainer1 { width: 50%; position:relative; margin-left:auto; margin-right:auto; text-align:center; } .slider1 { -webkit-appearance: none; width: 100%; height: 25px; background: #d3d3d3; outline: none; opacity: 0.7; -webkit-transition: .2s; transition: opacity .2s; } .slider1:hover { opacity: 1; } .slider1::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 25px; height: 25px; background: red; cursor: pointer; } .slider1::-moz-range-thumb { width: 25px; height: 25px; background: #04AA6D; cursor: pointer; } .slidecontainer2 { width: 50%; position:relative; margin-left:auto; margin-right:auto; text-align:center; } .slider2 { -webkit-appearance: none; width: 100%; height: 25px; background: #d3d3d3; outline: none; opacity: 0.7; -webkit-transition: .2s; transition: opacity .2s; } .slider2:hover { opacity: 1; } .slider2::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 25px; height: 25px; background: lime; cursor: pointer; } .slider2::-moz-range-thumb { width: 25px; height: 25px; background: #04AA6D; cursor: pointer; } .slidecontainer3 { width: 50%; position:relative; margin-left:auto; margin-right:auto; text-align:center; } .slider3 { -webkit-appearance: none; width: 100%; height: 25px; background: #d3d3d3; outline: none; opacity: 0.7; -webkit-transition: .2s; transition: opacity .2s; } .slider3:hover { opacity: 1; } .slider3::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 25px; height: 25px; background: blue; cursor: pointer; } .slider3::-moz-range-thumb { width: 25px; height: 25px; background: #04AA6D; cursor: pointer; } </style> </head> <body> <h1>Paleta culori</h1> <div class="slidecontainer1"> <input type="range" min="1" max="100" value="50" class="slider1" id="myRange1"> <p>Value: <span id="demo1"></span></p> </div> <div class="slidecontainer2"> <input type="range" min="1" max="100" value="50" class="slider2" id="myRange2"> <p>Value: <span id="demo2"></span></p> </div> <div class="slidecontainer3"> <input type="range" min="1" max="100" value="50" class="slider3" id="myRange3"> <p>Value: <span id="demo3"></span></p> </div> <h2 id="demo" >14:08</h2> <script> var ora = document.getElementById("demo"); var slider1 = document.getElementById("myRange1"); var output1 = document.getElementById("demo1"); output1.innerHTML = slider1.value; var slider2 = document.getElementById("myRange2"); var output2 = document.getElementById("demo2"); output2.innerHTML = slider2.value; var slider3 = document.getElementById("myRange3"); var output3 = document.getElementById("demo3"); output3.innerHTML = slider3.value; slider1.oninput = function() { output1.innerHTML = this.value; demo.style.color= 'rgb(255 , 0, 0)'; } slider2.oninput = function() { output2.innerHTML = this.value; } slider3.oninput = function() { output3.innerHTML = this.value; } </script> </body> </html> Problema este in linia : demo.style.color= 'rgb(255 , 0, 0)'; unde trebuie inlocuit "255,0 , 0" cu valorile (slider1, slider2, slider3) si nu stiu sintaxa. Va multumesc!
  9. Kreator

    Live war

    Ce-mi plac "AUR"-istii comunisti de pe aici!!! Oare de ce antivaccinistii sunt acum putinisti?
  10. Kreator

    Live war

    Da' ce de propagandisti putinisti sunt pe aici, n-am crezut vreodata... Si "AUR"-isti chiar. Multora le creste sufletul si le dau lacrimile cand dau de cutia cu KT315 primita cand faceau "stagiu" la Mockba.
  11. Pentru a nu amplifica distorsiunile primului AO trebuie conectat terminalul R8 de la iesirea primului AO in serie un C = C2 in punctul "c", si recalculat R8 si R9 ai factorul de amplificare al OP2 sa fie egal cu cel al lui OP1. Am facut ceva similar cu 2 LM3886 si am fost multumit de rezultat.
  12. Te-ai complicat... Nu e necesar U3 si U4. Se cupleaza iesirea U1 cu intrarea inversoare U2. Atentie, factorul de amplificare al celor doua AO trebuie sa fie egal. Asa trebuie facut (eu n-as pune R10 + C10, as recalcula R8 R9, da' cine sunt eu sa dau sfaturi).
  13. Buna ziua! Care este temperatura optima de functionare la acest tip de letcon? Multumesc! L.E. Offtopic. Daca tot sunt liber azi si mi-am achizitionat un JBC, m-am apucat de un proiect mai vechi lasat neterminat: combo Sursa de alimentare simetrica+ statie de lipit cu PIC1847.
  14. Buna seara! Va rog sa-mi spuneti daca pinout-ul unui JBC C245 din imaginea de mai jos este corect. si caror pini (sau culori ale firelor) din mufa handpice-ului ii corespund. Va multumesc!
×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări