Ich habe ein seltsames Problem und ich bin mir nicht sicher, was es verursacht. Vielleicht kann einer von euch sehen, was ich falsch mache.Arduino, Ethernet.begin (Mac) verhindern LED hoch
Das Problem ist die Funktion Ethernet.begin (Mac) - Es verhindert, dass die LED leuchtet, wenn die Taste gedrückt wird.
Ethernet ist enthalten, weil ich es später verwenden muss. Ich habe gerade den Code geändert, um das Auffinden des Fehlers zu erleichtern.
Es funktioniert gut, wenn ich Ethernet.begin (mac)
Dies ist mein Code zu deaktivieren:
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//byte ip[] = { 192, 168, 1, 104 };
char server[] = "b2b.as";
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
//Ethernet.begin(mac, ip);
Ethernet.begin(mac);
Serial.begin(9600);
delay(1000);
Serial.println(Ethernet.localIP());
Serial.println();
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
wo ist die Deklaration Ihrer 'Ethernet'? – Roljhon
was meinst du? vermisse ich etwas? –
Welches Modell von Arduino verwenden Sie? – Roljhon