Loading...
Pages: 1 [2]   Go Down
Author Topic: multiple led webserver help  (Read 1827 times)
0 Members and 1 Guest are viewing this topic.
Hyderabad, India.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

man works awesome, ill need to find 5 leds now smiley-grin

i sincerely thank you for your help smiley
Logged

Leeds, UK
Offline Offline
God Member
*****
Karma: 35
Posts: 987
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It should be easy to adjust it to however many LEDs you need. Just change these lines:
Code:
#define numberOfLeds 5
int LED[numberOfLeds] = { 2,3,4,5,6}; //This would use digital2 to digital6, but you could choose any
char LedURL[numberOfLeds][numberOfLeds+1] ={ "10000", "01000", "00100", "00010", "00001"};

void homePage(){
...
}

For example, this would do 4:
Code:
#define numberOfLeds 4
int LED[numberOfLeds] = { 2,3,4,5}; //This would use digital2 to digital5, but you could choose any
char LedURL[numberOfLeds][numberOfLeds+1] ={ "1000", "0100", "0010", "0001"};

void homePage(){
  //There are 4 leds, so 4 hyperlinks.
  bfill.emit_p(PSTR("$F"
    "<meta http-equiv='refresh' content='5'/>"
    "<title>Ethercard LED</title>"
    "Turn LED$D <a href=\"?led=$S\">$S</a>"
    "Turn LED$D <a href=\"?led=$S\">$S</a>"
    "Turn LED$D <a href=\"?led=$S\">$S</a>"
    "Turn LED$D <a href=\"?led=$S\">$S</a>"),
  http_OK,
  (word)1,LedURL[0],(LedURL[0][0]=='1')?"ON":"OFF",
  (word)2,LedURL[1],(LedURL[1][1]=='1')?"ON":"OFF",
  (word)3,LedURL[2],(LedURL[2][2]=='1')?"ON":"OFF",
  (word)4,LedURL[3],(LedURL[3][3]=='1')?"ON":"OFF");
}

Glad it works smiley-grin
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good jobs man..its work.. Thank u very much..
Logged

Pages: 1 [2]   Go Up
Print
 
Jump to: