Go Down

Topic: Controlling 2 leds (Read 434 times) previous topic - next topic

Mikvage

Hello guys I have a problem with this code,I need help,this code is specified for controlling one led through web server,but i want to control two led,I tried and tried but i failed.If any one can help me to add the code for another led but not to change the code just to add. I will be thankful,and please he/she can send the modified code through this email

michaelmuxh69@gmail.com

The code is in the attachment.


ieee488

Learn how to show your code using code tags.


.

anbu123

Your code is not opening for me.Add code using Code tags

PaulS

Quote
If any one can help me to add the code for another led but not to change the code just to add. I will be thankful
You have code today:
Code: [Select]
/* Dynamically generate the LED toggle link, based on its current state (on or off)*/
  char ledText[80];
 
  if (ledState) {
    strcpy(ledText, "LED is on. <a href=\"/?led=0\">Turn it OFF!</a>");
  }

  else {
    strcpy(ledText, "LED is OFF. <a href=\"/?led=1\">Turn it ON!</a>");
  }
 
  ledState = digitalRead(ledPin);

It seems pretty obvious that, to control two LEDs, you need two hyperlinks, two states, and two pins.

And, of course, you need different values in the led= lines, to distinguish which LED to control.

Why you are reading the state again after formatting the hyperlinks is a bit of a mystery.
The art of getting good answers lies in asking good questions.

Mikvage

#4
Jun 14, 2018, 02:38 pm Last Edit: Jun 14, 2018, 02:42 pm by Mikvage
So how do i add those hyperlinks,states and pins am new in programming can you help me to add(I mean rewriting the code) and send it to me please! am so in need of it ;)

And how do I use code tags? please I need your help guys.

Go Up