Hello is there a way to act as a telnet server and connect the arduino uno with a pir sensor.
If the pir sensor is active then the led light's up for 20 seconds.
And if I send a command to the telnet server the led will stay on.
This is not possible in one loop. Is there another way to make this work?
What have you added to the Arduino Uno to connect it to internet ? An Ethernet Shield ?
This is a telnet server (I have not tried a telnet server myself yet) : Arduino Playground - Telnet
Or do you want to send commands via the usb cable to the Arduino Uno ?
For timing, sequences, delayed tasks, and more, the function millis() is used.
This is a simple example with millis() : https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
Instead of a delay, the sketch checks if it time to do something.
With the w5100 ethernet shield.
The problem is the telnet server needs the loop every second otherwise if I place the pir sensor also in the loop for trigger the led for 20 seconds then the telnet server don't recieve nothing for 20 seconds.
So your question is how to do several things at the same time.
As I wrote, with the Arduino the function millis() is used for that. It can be used for timing, for timed sequences, for delays, for delayed code, and so on.
The function millis() returns the time, and the sketch should not use a delay, but it should check if it is time to do something.