Simple relay question

Hello,

Im really sorry im confused on this topic can someone help me find a relay for the following job please? I have a touch sensor connected to an arduino, when pressed I need the arduino to switch a relay which turns on 12v leds, I need the relay to stay switched on (leds stay on) till the switch is pressed again? Not sure if the arduino is even needed in any of this but I dont know enough about electronics. Could someone help me find a suitable relay for this please?

Thank you

what's wrong with a plain old switch on the power supply cord? do you really need the touch sensor?

Hi @espnewb

You could do what you are explaining, it would just be more complicated, and more expensive than a switch.

You would need an Arduino, a relay, a touch sensor, and some wires.

Here is the code you would need:

#define relay 3
#define touch A0

#define touchLimit 800 //out of 1023

int Touch;

boolean flag = false;

void setup() {
  pinMode(relay, OUTPUT);
  pinMode(touch, INPUT);
}

void loop() {
  Touch = analogRead(touch);
  if (Touch >= touchLimit){
    flag = !flag;
    while (Touch >= touchLimit);
    delay(200);                 //debounce
  }
  if (flag == 1){
    digitalWrite(relay, HIGH);
  }
  else if (flag == 0){
    digitalWrite(relay, LOW);
  }
}

Change the relay number at the top to the correct pin you have it attached to. Same with the touch sensor. You can also change the touchLimit definition.

I hope this helps!

In theory a logic level N-channel MOSFET + TTP223 + a linear regulator to power the TTP + a few caps should be all that is needed. From my experience the TTP get sometimes stuck in "touched state" and needs a power cycle to realize there is no touch.

It most certainly is not!

Since the TTP223 has a "toggle" option.

Solder blob the "B" pads.

Cant use a plain switch as its for an infinity mirror the switch is to go behind a piece of glass :slight_smile:

Thank you for your help and input all its actually finding a suitable relay that I'm really stuck on, something that can be triggered by 3v and capable of turning on 12v, need it to stay turned on till its triggered again been a long long time since I even worked on relays so can't remember what to even look for had a look on ebay just searching for relays 3v and got stuck and confused lol

Hang on! :astonished:

You wish to control 12 V, so you have 12 V available. What on earth does 3 V have to do with it?

5 V relay modules are readily available, connect directly to the TTP223 which operates on either 3 or 5 V, so what's the concern?

Thank u Paul B,

I have a 12v led driver for the leds I need to turn this on and off using a touch switch, which I think I can only connect 3v or 5v to, so I was going to use a 5v arduino connected to the switch, when switch is touched it turns on relay/other something... which switches on the 12v to the leds, I can't connect either the switch or the arduino directly to 12v :slight_smile:

So it's now a moving target. :roll_eyes:

Show (Web link) the LED driver you have and the touch switch module you have. Is it the one I cited or the blue one?

Then and only then can we work out how to connect them.

A SRD-12VDC-SL-C relay would work fine. It works with 5V but I'm not sure if it works with 3.3V. Why 3.3V? The Arduino outputs 5V on a digital pin except for the 3.3v pro mini.

I think we have determined a few things.

  1. An Arduino is inappropriate.
  2. If a relay is required, then it will need to be a relay module which includes the driver transistor.
  3. We have yet to hear any reason why 3 V is involved. :roll_eyes:
  4. We are yet to know the actual details of the project; until we hear them, it is all conjectural.

Sorry PaulB I've probably wrote the original post all wrong, i haven't got a touch sensor yet, I just have a couple of led drivers lying around, im looking on suggestions on how to achieve the following

I just want some leds behind a piece of glass, have some sort of touch sensor/switch behind the glass that turns on the leds and press again to turn them off, I know technically not an arduino but I was going to use something like a esp32 or even a d1 mini as its cheap and cheerful :slight_smile: I could use 5v leds and I have another psu available already for 5v, however I just don't know how to make a circuit to do all of that, hope that makes sense?

Your first task will be to see if the touch sensor will work at all from behind glass.

There is no reason it would not; the tricky matter is arranging the electrode on the back of the glass.

OK as noted, the touch sensor I cited - with the Aliexpress link - it the most straightforward way of doing this, using an Arduino or ESP is just making things unnecessarily difficult.

To determine the best way of connecting the touch sensor, we need to know about these LED drivers and what LEDs you wish to use with them. "Know about" means a Web link. :grin:

I'm open to suggestions for anything I need, including the led strip, I just need cool white :slight_smile:
I would prefer ebay.co.uk
This is the sensor I found
https://www.ebay.co.uk/itm/273886688670?_trkparms=ispr%3D1&hash=item3fc4eb359e:g:uR0AAOSwLO5hdyAK&amdata=enc%3AAQAGAAACkPYe5NmHp%252B2JMhMi7yxGiTJkPrKr5t53CooMSQt2orsSlHY%252FYTip4QFVjNQrCEJt6k1IUUmN%252BqAayaUhR4kOPoReLE76hKd0Gv%252Bz4gtSkQRkS1iR880PQ%252F1an2I0cYsSoLLNLoVtj2xkaF6KH5iY2fx3sIKV08SPW57OQqewUyjR59anp%252FbOEev3buVrjMNv%252Bd1FkBZh5hVmdGrWGpCZTJKT522d6UXh54SwVMIPsghiRc%252F4dTQceIDTryfCwJ6y3SRmr4kR2DwHZVZ%252BzoTI4n4HYhAFuA53So7V7atSxSSMb9JxyBVt2yB63VHG96C7EFb0Bi00Byfvqk6Qki1cyhtvcN31OQZcFAw6%252FHCOO7Y8E05Vu0hQ8O9Ssoebi6tqs79YT4ygKRf9cSa4j906Zo7vj%252B8Pvzq8eDHznYvWsp%252B%252B7IxMNgre8I1DlsqixOFw5%252F2agiX6qCdT%252BKCC5Vko%252BKGCRn64J%252BtB2lltBi8AKVI79Ox42xZwAupbqPUiIZchcPT1gZvaXQyc1y97cfxYHTA4VR80DzDDAE16pdyGd6fJPD0bS9r19%252BtmwJ25o1DT5

I've got a regulated 5v power supply which is already used for some ws2812 leds however it could also drive this if i used a 5v strip sorry I dont have links for that as I ordered it ages ago, its just one of those silver caged psu's

This is in the description section of your link:
Module can be installed in such as surface plastic, glass of non-metallic materials.

What is your LED driver? A link or name would be fine.


These are the 12v led drivers i have, their from another project i only need one i think the smaller 2.5a would should be sufficient for the amount of leds I need i measured exactly 2.24 meters

Here is a schematic for connections:

Schematic_Touch LED Strip_2021-12-18.pdf (28.3 KB)

Thank u kgray9 I could kiss u :slight_smile: thats amazing however should I be using a relay then cos read their bad and they blow up over time and its better to use a mosfet or something else etc (read all that after I started this journey, lol)

Glad I could help :grinning:. A relay should be fine. You could change it out for a p-channel MOSFET though instead.