- gban: Ingyen kellene, de tegnapra
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- gerner1
- Argos: Szeretem az ecetfát
- Luck Dragon: Asszociációs játék. :)
- sziku69: Fűzzük össze a szavakat :)
- btz: Internet fejlesztés országosan!
- hdanesz: Hyundai Ioniq 28kWh - Első benyomások - második felvonás
- sziku69: Szólánc.
- koxx: Bloons TD5 - Tower Defense játék
-
LOGOUT
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
Hirdetés
- LG 65C2 - 65" OLED evo - 4K 120Hz 1ms - NVIDIA G-Sync - FreeSync Premium - HDMI 2.1 - PS5 és Xbox!
- BESZÁMÍTÁS! HP ZBook 15 G6 munkaállomás - i7 9850H 16GB DDR4 RAM 512GB SSD Quadro T2000 4GB WIN10
- Lenovo ThinkPad X1 Carbon G8, i7-10510U, 16GB, 1TB SSD, 4K kijelző + WWAN (ELKELT)
- Bomba ár! Lenovo X1 Yoga 3rd - i5-8GEN I 8GB I 256GB SSD I 14" FHD Touch I W11 I CAM I Garancia!
- 2db Dell PowerEdge R740 2U Rack Szerver és 3db Netapp FAS2040 NAS
Állásajánlatok
Cég: PC Trade Systems Kft.
Város: Szeged
Cég: CAMERA-PRO Hungary Kft
Város: Budapest