# How to make Timer Off without relay (Code)

**URL:** <https://forum.arduino.cc/t/how-to-make-timer-off-without-relay-code/1016875>\
**Category:** Programming\
**Created:** [July 28, 2022, 4:46am UTC](https://forum.arduino.cc/t/how-to-make-timer-off-without-relay-code/1016875 "2022-07-28T04:46:40Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [July 28, 2022, 3:56pm UTC](https://forum.arduino.cc/t/how-to-make-timer-off-without-relay-code/1016875/6 "2022-07-28T15:56:03Z")

</div>

Hi @iqbalts ,

welcome to the Arduino-Forum

> [@iqbalts](#):
>
> i still have a problem with my simulation, the lamp doesn't turned off after 5 sec. Is my wiring correct?

I don't use tinkercad.  
it is just a simulation but I assume at some point in time you build a real circuit.  
**NEVER** connect something bigger than a sensor or a resistor-with-LED **directly** to an IO-pin. It is very likely that the device like your lamp will draw too much current and destroy the microcontroller.

The IO-pin that shall switch on/off the lamp must be connected to the base of a transistor  
the transistor then can be connected to the **coil** of the relay. You have only one end of the relay-coil connected. The second is missing.

As using a relay requires an additional transistor simply use a resistor and an LED for your simulation. lighting up the LED makes the switching of the IO-pin visible too.

Your code uses IO-pin 1. The wiring uses IO-pin 13.

For switching off the lamp you need some kind of timing.  
Your code has no timing yet.  
There is a timing-option that is easy to use but very limited in where it can be applied  
This option uses delay(). if you want to stumple over a lot of hurdles with more complex programs use delay()

If you want to be able to use timing professionally skip delay() and learn non-blocking timing.  
I advertise my own tutorial for learning it

> [@Example-code for timing based on millis() easier to understand through the use of example-numbers / avoiding delay()](https://forum.arduino.cc/t/example-code-for-timing-based-on-millis-easier-to-understand-through-the-use-of-example-numbers-avoiding-delay/974017):
>
> non-blocking timing. Execute code only from time to time. There are a lot of different ways to learn programming. This thread wants to add another approach that is different to the yet existing ones. UPDATE 06.01.2023 if you are mainly interested in applying non-blocking timing you can do a quick read of this short tutorial / demonstration If you are intersted in understanding the details how it works go on reading here. I use an everyday analogon in this post to explain the basic principle …

best regards Stefan

---

_[View the full topic](https://forum.arduino.cc/t/how-to-make-timer-off-without-relay-code/1016875)._
