- 3DMark03 eredmények
- DUNE médialejátszók topicja
- Milyen videókártyát?
- HiFi műszaki szemmel - sztereó hangrendszerek
- Milyen TV-t vegyek?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- LCD, plazma és projektoros TV-k hibái
- Milyen nyomtatót vegyek?
- AMD Ryzen 9 / 7 / 5 / 3 5***(X) "Zen 3" (AM4)
- AMD Navi Radeon™ RX 6xxx sorozat
-
PROHARDVER!
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
-
Saua
tag
Sziasztok,
Eredetileg egy LED-et lehet ki/be kapcsolni neten keresztül a ”Led1” utasítással. Ezt módosítottam, hogy egy nyomógombbal is működjön. A probléma, hogy a weboldara nem sikerül kiíratni a LED állapotát ha a gombbal kapcsolgatom.
Hogyan kellene módosítani a kódot?
/*
LED attached from pin 6 to ground
pushbutton attached to pin 2 from +5V
10K resistor attached to pin 2 from ground
*/
#include <SPI.h>
#include <Ethernet.h>
#include <String.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
byte ip[] = { 192, 168, 1, 202 };
EthernetServer server(80);
int led1 = 6;
int button = 2;
String readString = String(30) ;
boolean statusLed = false;
int buttonState; // bemeneti pin aktuális állapota
int lastButtonState = LOW; // bemeneti pin előző értéke
long lastDebounceTime = 0;
long debounceDelay = 50;
long prevido1; //előző idő eltárolására
void setup() {
pinMode(led1, OUTPUT);
pinMode(button, INPUT);
Serial.begin(9600);
Ethernet.begin(mac, ip);
}
void loop() {
EthernetClient client = server.available(); // Create a client connection
if (client) {
while (client.connected())
{
if (client.available ())
{
char c = client.read(); // Read char by char HTTP request
if (readString.length() < 30)
{
readString += (c) ;
}
if (c == '\n')
{
if(readString.indexOf("Led1")>=0)
{
if (statusLed) {
digitalWrite (led1, LOW) ;
statusLed = false;
} else {
digitalWrite (led1, HIGH) ;
statusLed = true;
}
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print ("<font size ='20'>");
if (statusLed) {
client.print("Led1 bekapcsolva");
} else {
client.print("Led1 kikapcsolva");
}
readString="";
delay(1); // give the web browser time to receive the data
client.stop();
}
}
}
}
//==============================
int reading = digitalRead(button);
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
statusLed = !statusLed;
digitalWrite(led1, statusLed);
}
}
}
lastButtonState = reading;
//==============================
}
Új hozzászólás Aktív témák
- Bontatlan Apple 96W USB C hálózati adapter (töltő) eladó
- 16GB RAM 1TB Háttér 10,1" NoName
- Chuwi HiPad Pro 8GB/128GB 10.8" 2K 8mag 2SIM Alu ház 7,5mm 450g
- BONTATLAN STEELSERIES TERMÉKEK BOMBA ÁRON! ÚJ, AZONNAL ÁTVEHETŐ!
- ASUS ROG Strix Scar 16 G634JZR i9-14900HX, 32GB DDR5, RTX 4080 (2027.08-ig garis)
- ÁRGARANCIA! Épített KomPhone Ryzen 7 9700X 32/64GB RAM RX 7800 XT 16GB GAMER PC termékbeszámítással
- LG 65QNED87T / 65" - 164 cm QNED / 4K UHD / 120Hz & 3ms / HDR 10 Pro / FreeSync Premium / HDMI 2.1
- LG 27GR93U-B - 27" IPS - UHD 4K - 144Hz 1ms - NVIDIA G-Sync - FreeSync Premium - HDR 400
- Telefon Felvásárlás!! iPhone 14/iPhone 14 Plus/iPhone 14 Pro/iPhone 14 Pro Max
- ÖRÖK GARANCIÁVAL - OLCSÓ, LEGÁLIS SZOFTVEREK 0-24 KÉZBESÍTÉSSEL - Windows - Office - LicencAruhaz.hu
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest