Ostry:
...I can't make this working after only uploading to the boards.
Thats worth of a big sigh from me. I'll tell you why in a minute
Ostry:
Should line 74 be 'pinMode(ledPin, INPUT);' rather then 'pinMode(ledPin, OUTPUT);' as it is now ?
Now, that's worthy of more than a sigh from me. It's a gasp. (Really: My flabber is totally gasted).
Ostry:
I am just starting
OK, now we have something I can work with. I mean, no one was born knowing this stuff, right? I am hopeful that you will accept the following criticism as my attempt to get you started, and not any kind of flame or other personal attack.
So, how's I got started with Arduino:
I looked at the very first test program example, the famous "Blink" sketch. In the current Arduino release there are, by my reckoning, a grand total of 19 lines. Two lines are blank, eight lines are comments and nine lines are code. (Two of the lines have a single '}' brace. That's part of the code.) I also looked at Arduino reference material on the arduino.cc web site. Now, I will admit to have done some amount of programming over the years, but this Arduino stuff was brand new, and I looked at a lot of reference material before ordering the board. (I also ordered a "starter kit" that had a solderless breadboard, a handful of LEDS and resistors, a light-dependent resistor and some jumper wires.)
Anyhow when the hardware arrived, I was ready to go!
I had made sure that I knew exactly what every line of code does in the example sketch. I looked up pinMode and digitalWrite. The comments were helpful. I plugged the Duemilanove into the a USB port on my computer. I started the Arduino IDE and used the menu to locate the "Blink" sketch. I compiled the sketch and uploaded to my Duemilanove. The LED marked "L" blinked at a rate of about one second on and one second off. It did this repeatedly until I unplugged the USB cable.
Next step: I wanted to make a different LED blink. I decided to try Pin 9 instead of Pin 13. Now, here's the tricky part: If you don't have a degree in Electrical Engineering or Computer Engineering, and if you don't read the right reference material you might not realize that the correct way is to put a resistor "in series" with the LED. What value of resistor? You can do some searches on this forum or on the Arduino "playground" or about a million other places on the web. (I looked at the Duemilanove schematic.) Bottom line, here's the way I connected the new LED:
Arduino pin 9 ---> 1 K Ohm resistor ---> Anode of LED
and
Cathode of LED ---> Arduino Ground.
After making the connections I plugged in the Duemilanove again. The "L" led (on Pin 13) did its blinky thing, because the old sketch stays in program memory after you unplug the power. When power is connected again, it the old program continues to execute until you upload a new sketch.
Next...
I opened the "Blink" sketch and everywhere there was "13" I changed it to "9"
Now, when I uploaded the modified sketch, my new LED (on Pin 9) blinked and the "L" LED (Pin 13) on the board stayed dark.
I went through the agonizing details for this simple step because I'm thinking you didn't do anything like that. If you had, you wouldn't have asked the flabbergasting question about the pinMode instruction. The LED is connected to a pin that is operating in Output mode so that it can cause current to flow through the LED (or not) to make the LED be illuminated (or not).
I hate to repeat myself, but I am not trying to disparage you or to discourage your efforts to learn something new that is really, really neat. (Well, this stuff is fun when it works, and I think that's neat.) I am trying to get you to think sequentially instead of starting with zero knowledge and jumping to a "do it from scratch" remote control pair of programs.
Don't get me wrong; it's always OK to ask questions (Really: I think it's always OK), but I personally think that anyone would be out of his/her mind to start a project with two (not one but two) Ethernet Shields connected and programmed in such a way that a switch at one board could cause an LED on the other board to go on and off.
I'm thinking that the Arduino developers didn't put in any kind of examples with two Ethernet Shields (on two different Arduino boards) because many (most?) beginners don't have two Arduinos, each with its own Ethernet Shield. Furthermore, people have enough problems getting just one of the furshuliggener things to work, let alone two.
I mean, that's a great project, in my opinion, and it's still amazing to me that a processor with such limited resources as an ATmega328 can perform useful network operations with a standard Ethernet protocol like UDP. Really. It's a great project, and I hope you can stick with it and learn enough to get satisfactory results. Really.
Now as far as my first sigh at the top of this response:
I try (really try) hard (really hard) not to publish sketches that don't work. That's not to say that I never make a mistake. It wouldn't be the first time I was wrong. (Not even the first time today.)
But look at the information I gave you: I told you what version of Arduino software that I was using. I told you what Arduino boards I am using. I told you what versions of Ethernet Shields I was using. I told them how I hooked them up. Well, actually I didn't tell you the circuit connected to pin 9 of the output board, but I assumed you already knew how to hook up an LED. (I'm not sure whether that assumption was a mistake, but I accept the possibility that I should have spelled it out.)
After all, you are getting into some rather advanced territory when you go around hooking up Ethernet cables to use with your very own hardware and software.
Anyhow...
I showed you exactly what I saw in the serial port monitor windows for both boards. I told you that the LED goes on and off on the output board when it receives the UDP packets.
What do I get from you? "It doesn't work."
OK: What doesn't work? Does the input board respond to input from the serial port? Does it print a message that it is transmitting the command? What? The same kind of questions go for the output board. Exactly what works )or doesn't work)? Do the Ethernet Transmit/Receive LEDs on the Ethernet Shield blink briefly when you want to send the 'H' or 'L' message? What?
Furthermore:
What are you working with? (What software version? What Arduino boards? what Ethernet Shields? What?)
Also:
Have you done any of the Ethernet example programs? The WebServer? The ChatServer? Anything?
What happens when you connect an Ethernet cable from one of your shields to your network? Do any of the lights go on? If you run one of the Ethernet library example sketches, do the Ethernet Transmit/Receive LEDs blink? What?
If you haven't done an example with one Ethernet shield connected to your network, I personally think you are simply not going to understand what happens when you connect two of them (on different Arduino boards) together. Maybe I am wrong. I mean, different people have different ways of learning, just as different people have different ways of trying to help.
Regards,
Dave
Footnote:
"The opinions expressed here are not necessarily my own,
but those of the dang voices in my head."
---davekw7x