-
Fototrend
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
Zoja™
őstag
Uraim, megjött a Wemos D1-em, amivel ma tudtam kicsit játszani.
Egy relé kapcsolgatásával kezdtem az ismerkedést, de valamiért fordítva működik.
Alapból bekapcsolt helyzetből indul, ON-ra kikapcsol, OFF-ra pedig be.

Itt a kód, ha vetnétek rá egy pillantást, hogy mi a hiba azt nagyon megköszönném.

// Import required libraries
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
#include "Timer.h"
#include <aREST.h>
#include <aREST_UI.h>
// Create aREST instance
aREST_UI rest = aREST_UI();
// WiFi parameters
const char* ssid = "*********"; //Change the stars with your SSID
const char* password = "********"; //Change the stars with your password
Timer t;
IPAddress ip(192,168,0,109); //The static IP you'd like your lamp to get from the router
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
// The port to listen for incoming TCP connections
#define LISTEN_PORT 80
// Create an instance of the server
WiFiServer server(LISTEN_PORT);
// Variables to be exposed to the API
int ledControl(String command);
void checkwithPing()
{
Serial.print("Pinging ip ");
Serial.println(gateway);
if(Ping.ping(gateway)) {
Serial.println("Success!!");
Serial.println(Ping.averageTime());
} else {
Serial.println("Error :(");
ESP.reset();
}
}
//SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP --
//SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP -- SETUP --
void setup()
{
// Start Serial
Serial.begin(115200);
// Set the title
rest.title("8/61 ");
// Create button to control pin 5
rest.button(5);
// Function to be exposed
rest.function("led", ledControl);
// Give name and ID to device
rest.set_id("1");
rest.set_name("esp8266");
// Connect to WiFi
WiFi.begin(ssid, password);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
t.every(10000, checkwithPing); //Check if connected every 10 seconds
}
void loop()
{
t.update();
// Handle REST calls
WiFiClient client = server.available();
if (!client) {
return;
}
while (!client.available()) {
delay(1);
}
rest.handle(client);
}
int ledControl(String command) {
// Print command
Serial.println(command);
// Get state from command
int state = command.toInt();
digitalWrite(5, state);
return 1;
}
Új hozzászólás Aktív témák
- Hardcore café
- Call of Duty: Black Ops 7
- Az AI-piac kivégezte a Micronhoz tartozó Crucialt
- Xiaomi 15T Pro - a téma nincs lezárva
- Rémisztő árakkal szembesülnek a notebookgyártók az új mobil platformoknál
- Redmi Pad 2 Pro / Poco Pad M1 - egy teszt, két lélek
- Melyik tápegységet vegyem?
- BestBuy topik
- Sorozatok
- Kiadta Sam Altman a parancsot: bajban a ChatGPT!
- További aktív témák...
- !!AKCIÓ!! Vadonatúj, bontatlan iScooter iX6 elektromos roller, 1 év gari 45 km/h
- Asus Prime MR120 argb
- iPhone 16 pro, 128GB eladó
- Acer 15.6",FullHD,core i3 8145U(4x3,9Ghz)MX230 2/4GB DDR5VGA,8-20GB RAM,SSD,szép állapot,Win.11
- Új Gamer PC - Ryzen 7 5800X / RX 9060 XT 16GB / B550M WIFI / 32GB RAM / 1TB M.2 NVMe SSD / 650W
- LG 27GR83Q-B - 27" IPS / QHD 2K / 240Hz & 1ms / NVIDIA G-Sync / FreeSync / DisplayHDR 400
- Macbook Air M2 15" 8GB 256GB 100%
- Mini Pc HP ProDesk 600 G2 G3 G4 /// 6-8. gen //// i3 / i5 /// garancia /// Budapest / MPL / Foxpost
- BESZÁMÍTÁS! MSI B450 R5 5600X 32GB DDR4 512GB SSD RTX 3080 10GB Zalman Z1 Plus Cooler Master 750W
- BESZÁMÍTÁS! Sony PlayStation 5 Slim 1TB SSD digital konzol garanciával hibátlan működéssel
Állásajánlatok
Cég: BroadBit Hungary Kft.
Város: Budakeszi
Cég: ATW Internet Kft.
Város: Budapest



ekkold
