|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
Quote:
... Alright testing now. Accessed the webpage, serial printed... Code:
HTTP favicon.i,, Prints the same. No LED. Pressing "Off" Same thing. And no LED. When I press the buttons, the TX and RX leds blink on both the ethernet shield and the R3, and an LED I connected to pin 13 (it is not in the code though, it's just there to show me if the Arduino LED blinks) gets a little bit brighter when the TX and RX leds blink. Last edited by jwallace15 : 08-01-2013 at 11:14 AM. |
|
#2
|
||||
|
||||
|
Re: Arduino + Ethernet Shield Help
Quote:
What voltage and current is the power source rated for? Are you using the USB port for power? The potential code issues aside make sure that you are not fooling yourself by powering that assembly with a power source that is not sufficient. |
|
#3
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
Quote:
I know that it is sufficient, I recently made a sketch with my MEGA that had 15+ LED's that would scroll in a marquee and the delay could be adjusted from a trim pot (all the way down to a ~10ms delay). I also ran a servo off of the mega while doing that, and 3 more trim pots that could adjust the colour of an RGB LED. |
|
#4
|
|||
|
|||
|
Re: Arduino + Ethernet Shield Help
Can you add some print statements after the conditional logic steps in your code, and tell us what they give you?
I wonder if favicon.i is an icon? I hope not, because that would not make any sense. It's good to see another person that loves trains. Last edited by daniel_dsouza : 08-01-2013 at 12:14 PM. Reason: i like trains |
|
#5
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
Quote:
and say the led is off if the Off button is pressed? EDIT: ^ I added that sort of statement and when I press either the on of off buttons nothing is printed. ![]() http://www.chiefdelphi.com/forums/at...9&d=1346106255 (as of last year. Much has changed since then. MUCH.) Last edited by jwallace15 : 08-01-2013 at 12:34 PM. |
|
#6
|
||||
|
||||
|
Re: Arduino + Ethernet Shield Help
I put my Arduino Ethernet Shield R3 onto my Arduino Duo R3.
I cut a network cable in half. Made an ethernet 'cross-over cable' like so: Orange/White (one half) - Green/White (the other half) White/Orange (one half) - White/Green (the other half) Vice-versa I used Scotch Tape as an insulator after twisting wires together. MacGyvering during lunch....check. Good thing that was a high quality dollar store cable ($1.34). I put my 'cross-over cable' into my laptop (Dell E6400...yes I have several laptops) ethernet port. I put the other end into the Arduino Ethernet Shield. I disabled IPV6 (blah) on my laptop wired ethernet interface. Set my wired connection in Windows 7 to: 192.168.1.131 Looked at the supplied code and it uses: 192.168.1.130 Set the gateway as: 192.168.1.1 Set the netmask to: 255.255.255.0 Loaded up your stored page in Firefox. Regardless of what webpage button I press (On/Off) I get "HTTP" out the serial monitor. When I get a chance I'll check the output pins. However I do not get this: Care to clarify if you are using Internet Exploder....I mean Internet Explorer ![]() I have version 1.05 stable of the Arduino software. Last edited by techhelpbb : 08-01-2013 at 02:48 PM. |
|
#7
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
Nope, Chrome. I openly admitted to using IE at robotics last year and recieved a major lashing for such blasphemy. Then I downloaded Chrome.
|
|
#8
|
||||
|
||||
|
Re: Arduino + Ethernet Shield Help
I only get the 'favicon.i' if the serial monitor is open when the board first connects. Other than that just "HTTP" out of the serial monitor.
It did not appear on my DMM that either pin 7 or 8 was toggling with the webpage button presses (not sure if it's one or zero oriented). Will look into it more later. What I suspect is wrong here is that: 1. If you look there is only one call to serial to output from this code. 2. What you should see is what is in the buffer. 3. When you alter the form it fires a POST event. 4. That should cause the page to reload (with the same content). 5. During that post event parameters follow. 6. We both only see "HTTP". 7. However this is a POST so look at this link: http://www.jmarshall.com/easy/http/#postmethod (Link altered to something more related and friendly) 8. Therefore when the code reloads and tries to parse these parameters...it can not find what is not in the buffer. 9. Therefore the page simply reloads but does not change the pins (it thinks it's the first time you loaded it). 10. This *might* have worked for someone at some point but this is likely time sensitive. 11. The browser is doing all the work to display the HTML form. 12. When the browser toggles something it's just a silly drawing to the browser. 13. Even if this was a slider (it's a button) it would likely slide as you might expect. 14. Even if the browser does not successfully communicate the change it will tend to draw the changes. 15. HTTP is stateless so unless you put something more intelligent like Javascript in there you can't ask the browser after the fact what happened without another HTML form submission. 16. If your HTML forms never send valid data you are trapped in a vicious loop where things *appear* to be happening. This is a typical problem for web applications of any sort. Often form submissions recall the same code and that code needs to get parameters (either GET or POST). If that code does not get parameters HTTP is stateless so it thinks you were *never there before*. So since I am not the student here ![]() Put a serial print statement *inside* the conditional that toggles the pin. See if it ever prints. You sort of did this already above just put *only* the print statement not any additional conditionals. Then we can go from there. BTW when was this book you have written? Look at the copyright date. It's this book right: http://shop.oreilly.com/product/9780596802486.do Whistles innocently: https://bugzilla.mozilla.org/show_bug.cgi?id=260500 Last edited by techhelpbb : 08-02-2013 at 12:54 AM. |
|
#9
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
Quote:
|
|
#10
|
||||
|
||||
|
Re: Arduino + Ethernet Shield Help
Try my suggestion above.
In the conditional already in the example code just try to print anything out the serial port. Things change and when someone writes a *tiny* webserver they sometimes forget that they control the part they write. They do not control the browser part that is written by someone to whom they have no immediate contact. So let's think about this: What happens when the browser part does something different then it did before? How does the example written in a hard copy book evolve when the authors and editors of the book can't predict the future? It doesn't. This code is obsolete (for people with current browsers) but it's actually not terribly hard to fix it. So let's do this step by step. Start with my request above. Tell us if you ever see that line print. Last edited by techhelpbb : 08-01-2013 at 06:01 PM. |
|
#11
|
|||||
|
|||||
|
Re: Arduino + Ethernet Shield Help
So in the code line...
Code:
while(client.findUntil("PinD", "\n\r"))
{
int val = client.parseInt();
pinMode(8, OUTPUT);
digitalWrite(8, val);
}
Code:
while(client.findUntil("PinD", "\n\r"))
{
int val = client.parseInt();
pinMode(8, OUTPUT);
digitalWrite(8, val);
if(val == 1)
{
Serial.print("The LED is on")
}
else
{
Serial.print("The LED is off")
}
}
|
|
#12
|
||||
|
||||
|
Re: Arduino + Ethernet Shield Help
Somewhere you've lost a line...I highlighted it red.
The line you want to add is shown in green. Code:
if(strcmp(buffer,"POST ") == 0)
{
client.find("\n\r");
while(client.findUntil("PinD", "\n\r"))
{
int pin = client.parseInt();
int val = client.parseInt();
pinMode(pin, OUTPUT);
digitalWrite(pin, val);
Serial.println("I saw the POST and toggled the pin!")
}
}
Just add the one green line to the original code. Be back in 2 or so hours....gotta go to a MORT thing..... Last edited by techhelpbb : 08-01-2013 at 06:50 PM. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|