How to make a capacitive touch sensor switch out of anything metal using an Arduino

How to make a capacitive touch sensor switch out of anything metal using an Arduino

SUBTITLE'S INFO:

Language: English

Type: Robot

Number of phrases: 284

Number of words: 2137

Number of symbols: 8905

DOWNLOAD SUBTITLES:

DOWNLOAD AUDIO AND VIDEO:

SUBTITLES:

Subtitles generated by robot
00:00
[Music] [Music] hello and welcome to the Z Hut I'm J and today we're gonna take a look at how to use an Arduino to turn almost any piece of metal into a capacitive touch sensor which means when you touch it it will read the change in capacitance and you can use it say as a switch which is how I get it hooked up here so as you see when I touch it the LED comes on I
00:36
touched again and it turns off now this is just a little piece of aluminum and I fold it over a couple of times make it Tom have a little stiffness to it but other things can be used as well and as you can see I touched the lead do it as well and even though there's this little plastic coating over the alligator clip I'm still close enough to it where it's detecting the capacitance change and setting it off now in the software and when we get to that I'll show you you
01:08
could eliminate that if you only want it to turn on when it's touched but I have the sensitivity not as sensitive so I can show you demonstrate this on a few different items so you can see here I've got a larger sheet and I just have to get close to it and it's detecting the capacitance I mean this this is really detecting but Tom say you don't want something that big there is a penny and a penny who
01:49
works really good because you can solder to it so you could use pennies and you could do an array and have multiple you can use more one than one capacitive touch sensor on the Arduino and if no once again when we get to the sketch the programming I will show you how to add more but for the demonstration I only have one one last little demonstration and then we'll look at how it's put together this is a rain sensor gauge and it's just two grids and when a raindrop gets on it will detect it
02:20
now I have the alligator clip clipped to both once again you could use something like that so like I said pretty much anything that's matter you can use you could hook this up to your car and in the program and set it to detect it it's touched you could connect this to a lamp whenever you touch the lay-up anywhere that was metal it would turn the lineup on and off lots of applications but for today I just
02:52
have it hooked up as a switch and let's just get down how this is put together as you can see it is actually pretty simple there's only really two components besides the piece of metal that you're gonna need now the LED is optional I have a non digital pin 13 which also has you can see on the Arduino board also has an LED on there but I just added an external one to make it easier to see for this demonstration otherwise besides
03:22
your Dino bard you need a 10 mega ohm mega with an m1 that is optimal if you don't have a 10 Meg I've got some 5.5 Meg's they worked as well you don't really want to get much lower than out here gonna start having difficulty setting this up if at all possible use a 10 Meg if this is actually designed in the library in the sin scene to with a 10 mega ohm the best but like I said you can't use slightly smaller and
03:54
slightly bigger and that's just going between that resistors going between digital pen farm and digital pen sex and then also on digital pen sex we have the alligator clip here which connects to our metal device that is how simple is this it's all done in software except for that one little resistor right there alright let's go over the computer and take a look at the sketch for this and I'll show you how you can modify that to
04:28
add more sensors and also how to set the level because like I said when I had this connected you didn't have to be very close to it to set it off I will show you in the sketch how we can change that value the sensing value so that you would actually have to physically touch this before it would so I'll catch you at the computer in just a second okay I've got the arduino ide opened up here now the first thing we're gonna need to do is get our library I'm assuming you probably don't already have this library
04:59
so go on your sketch include libraries manage libraries this will take a moment to come up there we go then in the search box here you're gonna put in capacitive sensor I just copied the capacitive sensor off the library name right here put that in and it should be the first one that comes up it's this one here the one bike by Paul Badger and Paul straw agent not too sure that's correctly pronounce it
05:38
but this is the library we want right here so once you've installed that now I already have it installed so I'm just gonna close out of here so we're gonna include that right here then next we need to give a name to that particular sensor and as I said you can't have more than one and then we also needed to find pins it's on I just called mine sensor and pen for that's the transmit pin that one your you'll use with the other ones
06:08
as well I guess I haven't tried different trying to change it to a different pen I suppose I should have but I'll leave that you'd experiment with but Tom and then I got the second number here this is the the receive pen basically the the one that the the alligator clip is on mine or it's where your piece of metal is connected I guess it's what I'm trying to say if you want to have more sensors what you do is just
06:40
simply copy that and then paste it in and then so the next one we want to have different names so I'll just call it sensor 2 and then for this one let's say use pin 5 so just remember to use the for the same now I tried up to 3 it works fine I'm imagining you can use more if after the 3 you're having problems try using a different transmit pen for the other ones but all right let's get moving on here next we have a lawn and we're
07:15
calling value and that's what we're gonna use to read the sensor so again if you're having more sensors you'll want to have a of Altoona Val 3 and so on and so on and we're using a long because the number can get very large depending on how big of a metal object you connect this to it does make a difference then I have an integer here and it's pls just short for position and that's just keeping track of if the LED was off and on down here
07:46
in our if statements so it knows when I touch it if it should turn that led off and on then of course we're defined an LED on pin 13 and the void setup we're doing our serial begin now this is just for testing once you get everything set up you can't comment that out then we have our pin mode from LED that's an output of cars now and avoid loops or we have fun so we're taking our Val our long hear valve and we're setting that to do a read off of the capacitive
08:17
sensor and we're putting that reading into Val then we're serial printing valve now once again this is for testing and setting it up once you're done you'd want to comment this out most sense running the serial monitor and printing if you're not anything's connected to it it's just a waste waste it's drawing power to Mike on the Arduino microcontroller that you don't need to and I just have it set up your if statement and else if and it's turning the LED off and on and we're just doing
08:49
I'm just checking if the value is greater than equal to a thousand and that's the reading we're getting from the sensor it turns it on or here if it's on it turns it off and then a deep out said I got a delay of 500 in there that's just so you have enough time to touch it and get your and take your finger off of it so it doesn't turn off and on a real play it off either way and then I have a delay down here and this is just to make things run smoothly of
09:18
10 but I'm gonna change this real quick and I'm gonna change it so that we can see better here with the serial monitor cuz I'm gonna demonstrate the serial monitor now and how to change our veil you set our value here depending on the size of the metal item that you have connected to it so I'm gonna go ahead and upload that should go pretty quick all right it's done uploading let's open
09:53
up the serial monitor now right now I have a piece of tinfoil connected to it and you can see that it jumps around a little bit but for the most part I think the highest I've seen so far here is 133 so you could go ahead for this piece of tinfoil I probably recommend putting a value of our own Oh a thousand actually we're good because that way see here
10:23
there's my hand about five six inches away from it you see how it goes out so if you had it set at 400 you'd only have to get five inches within distance of this and it would turn on or turn off well my hand is drifting away and I'll get a get even closer and now I'm hovering within like an inch no half an inch and you can see I just barely maybe a quarter not even a quarter puppy
10:56
Varela around an eighth to a quarter and it's turning off and on and there's me touching it I'm holding my hand not a great no so let me grab that plate you know connect ear all right now you can see this plate when I'm nowhere near it it's close to the floor it's running around 400 and I
11:35
don't got this sitting I got it sitting on a piece of carpet so the static electricity is messing with it at us a little bit here bear is touching it and there's not as you can see the value is hired for the most part than the aluminum foil but once again this bigger piece of metal it's kind of giving me a hard time because we're on a piece of carpet there
12:06
is the penny connected to it and there's my finger bout half an inch or so away from it there untouched it so I think you get the idea just plug connect your piece of metal to your pin pin six or five or whatever one you're using for the sensor take a look at what it's reading when you're not touching it then take a look to get when you're touching it come up with a number
12:40
between there that works for you everybody's gonna have their preferences you might want it set you know so that you're within an inch of it now remember if you have to have electrical conductivity to the connection to the metal object but afterwards you could paint it and that's another thing because you wouldn't be directly touching the metal touching the paint it's insulated but still detect the change of capacitance so there's again we're selecting the proper value is going to be left up to you it just
13:11
depends on the piece of metal that you're connecting to I hope that makes sense if you have any questions feel free to leave a comment I will try to get back to you as soon as possible so what they act on I hope you found this information useful he did please give us a thumbs up don't forget to subscribe and with that we'll just say I hope you have a great day and remember they have fun building

DOWNLOAD SUBTITLES: