-
Mobilarena
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
- Kodi és kiegészítői magyar nyelvű online tartalmakhoz (Linux, Windows)
- Háztartási gépek
- E-roller topik
- AMD Navi Radeon™ RX 9xxx sorozat
- Delta Force (2024)
- Xbox Series X|S
- Autós topik
- Projektor topic
- Steam, GOG, Epic Store, Humble Store, Xbox PC Game Pass, Origin Access, uPlay+, Apple Arcade felhasználók barátságos izgulós topikja
- Windows Phone felhasználók OFF topikja
- További aktív témák...
- Playstation 5 lemezes - Gran Turismo 7, Tony Hawk's Pro Skater 1-2 eladó!
- ROG Ally (2023) RC71L + JSAUX HB1201S
- Vadonatúj, bontatlan iPhone AIR 256GB fekete és kék KÁRTYAFÜGGETLEN! 1 év Apple garancia!
- 3D nyomtatás kiváló minőségben / számlával / akár 9 színnel / széles anyagválaszték,
- HP,15.6",250 G6,8.gen.core i5 (8X4,0Ghz)8-32GB RAM,256GB-1TB SSD,nagyon jó akku,Win.11,szép
- BESZÁMÍTÁS! ASUS ROG STRIX SCAR 15 Gamer notebook - i9 12900H 16GB DDR5 1TB SSD RTX 3070Ti 8GB WIN11
- Hp Zbook 15 G5 15,6" FHD/ i7-8850H, 32GB, 512GB SSD, Quadro P2000, Magyar- Win11
- Apple iPhone SE 2022 / 256GB / Kártyafüggetlen / 12Hó Garancia
- Gamer PC-Számítógép! Csere-Beszámítás! I7 6700 / RTX 3050 / 32GB DDR4 / 512 SSD!
- Apple iPhone 13 Pro Max 128GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest