I figured out how to make my Arduino into a web server pretty quickly, especially since the
example program does just that. What was hard was to go the other way, controlling it from a web page. I got that working finally by cobbling together bits and pieces of
this project and
this project. What I wanted was a couple of form input buttons that would turn on and off an LED. That's what this does. One issue I still have is the first time you submit the Arduino responds immediately but from then on you have a passed value in the URL and for some reason you have to click twice to get the Arduino to respond. Actually it does respond the first click but goes back to its previous state, then stays on the new state on the second click. Something more complicated is going on than I can yet understand. Anyway, it's cool and now I think lots of possibilities are opened up.
Well, I tried posting the code here but the WYSIWYG eats a lot of it, so here it is in a txt file,
linked here.
UPDATE: Ha, an anonymous reply (thanks!) solved my double-click problem. Add a break; after each digitalWrite which makes sense now:
if(c == '0') {
digitalWrite(9, LOW);break;
}
if(c == '1') {
digitalWrite(9, HIGH);
break;}
4 comments:
Don't know if you care or if you have already found it... But if you add 'break;' after each digitalWrite, you won't need to click twice.
Hey that is perfect, thanks! I had put this down for a while so I hadn't figured it out yet.
No problem. Thanks for posting your code!
can i get info on how to control 8 leds.
thanks
Allan
Post a Comment