 In the last video I showed you how to use this simple button with an Arduino. And on this thing we had four different buttons which allowed us to control different things in our project. The problem is these buttons are super simple and they only have one input of control. Either it's being clicked or it's not being clicked. That's it. So for each button you'll only get one thing out of it. So you have to have a lot of buttons to figure out what you're doing. A good example of an issue like this is like keyboards. Keyboards they have one button per letter and then when you need more buttons you got to start doing commands and clicking one and three and then two and four and making different kind of inputs and all that garbage. But what if we want one button to do more than one thing or input more than one thing? We unfortunately cannot use these but I do have something we can use. It's going to be very hard to focus this thing but this right here is a force sensing resistor or what I call it is a force button. This is a type of sensor that changes its resistance when putting pressure or force on it. Think of it like a thin and sensitive button. When you press it the resistance decreases oops. So the harder this thing is being pressed the more the electricity is flowing through it and then the more power you're getting at the other pin right here and we can either read that on the Arduino and figure out a force number like from zero to 100%. A light to press can be maybe 20% 30% or we can use it for things that we want to add and remove very quickly with our finger. For example there's not a realistic or efficient example but let's say the room in your light was connected to one of these. As you push harder the light would get brighter and brighter and brighter and as you release the light would dim down and dim down. That's the purpose of a sensor like this and the nice thing about this is that we can either use it like a normal button click and unclick or we can use it with a range like a dimmer for a light. We're going to be building a demo with this sensor like we do with everything else so you're going to need a couple of different parts. First off you're going to need the force sensor then you're going to need some cables to plug it in you're going to need three of those. I recommend using a breadboard because we're going to have to do some wiring on this. Of course as always you're going to need an Arduino to connect everything and be able to read what's happening and you're going to need a 10k ohm resistor. Once you have all that we can get started with the demo. We're going to have to zoom in heavy while I do the wiring and then we'll unzoom later on. First thing you're going to have to do is take your force sensor and put it in any two slots on the breadboard. Just make sure that it's like this. So one slot next to another one and then we have those two rows all the way down. Then on the left side slot we're going to put a power cable which is going to go to 5 volt on the Arduino board. On the right side we're going to do a cable right there and it's going to go to a zero on the Arduino. This is going to be the cable we're reading information from so we're going to be putting power into our little button and then as we push we want to see how much power comes out. Then we're going to take our resistor and we're going to put it in the right side where we have that signal cable but we're going to put it after the signal cable. So we're going to go like this. I'm going to pass it on over here and then we're going to take our third cable and go from resistor to ground and the purpose of that is to create a pull down resistor. So I'll bring it close to the camera just so everyone can see exactly how it works. But we have our force button with a left and a right. The left is going here into the 5 volt. The right is going around here into a zero and then right here we have the resistor which goes to the third cable and the third cable goes around into the ground. If you want pause here just so you can copy it and we'll get started with plugging in the Arduino and getting on the code. For the code we're going to start with an empty project and we're going to do like always declaring our pins at the start. We're only using one pin in this example which is going to be a zero to be reading the information or how much electricity is coming through from the force button. Then since we're not using a display we're just going to write this to our console. So we're going to open up a console and then we're going to do our loop. In a loop as always you're going to be reading what information comes in through the pin and then we're going to do something with that information. So here we're just going to print out the raw output of our analog reading. This is usually a number between zero and a thousand and twenty three. That's what comes out out of the Arduino analog pin. Then we're going to create a little if-else statement here which is going to do different things depending on how much pressure we're getting. So zero to nine is going to be no pressure. From 10 to 200 we're going to get a light touch. From 200 to 500 we're going to get a light squeeze and from 500 to 800 we're going to get a medium squeeze and then anything after that is going to be a big squeeze. So now you see how with this one switch we can do five different things and we can continue to split it but at that point it would get complicated but we can split this up to at least three or four different pressures with one button whereas the other one we had four buttons and each one can only do one thing. So this one thing can equal four buttons. So we're going to save that. I'm just going to clean it up and I would like to upload it to the board and see if we can get any readings. I think it's going to be a little bit easier if I could put it down on the table. Yeah so I'm just light touching it on and off on and off. Now I'm going to give it a bit of a harder push light squeeze light squeeze light squeeze. Now let's see what happens if I push hard. Wow so it's actually really hard because I pushed hard and it only showed medium. Like right now I'm pushing with decent amount of force and now I'm pushing hard. So this definitely is definitely a lot more control than I thought. So I can make it like if I just give a light tap like this you know I could do one thing I can give a light squeeze you do another thing I can give a medium squeeze I could do a third thing or four thing I should say and then hard squeeze for a fifth thing. Now we should probably add a little delay at the end here just so that it doesn't update every millisecond you can see it's going to go one two three now I'm going to just touch it lightly let go so you see here we said for light touch it's got to be between 10 and 199 and we read 192 now if I do it again now we're at light squeeze 327 which fits between 200 and 500 now I'm going to clear this we'll do it one more time but with medium 564 which fits between 500 and 800 and then for hard squeeze I'm guessing if I squeeze as hard as I can wow it's not even at the max of 1000 I don't know if I can get it there with my fingers oh I think I unplugged it push it back in squeeze as hard as I can yeah so I'm not even maxing it out at 1023 I'm only at 880 and that's all we got for a force resistive sensor as you can see we connected it up to the board when I push light when I push harder when I push harder even harder and all the way hard the results change so with this one switch we could do five different things versus using our old panel we could do only four that's everything I got for you guys today if you enjoyed this video please give the video a like and subscribe to the channel if there's anything you want to see in a future video please let me know in the comments so I can start working on it and make a video about it in the future and if you have any problems or questions where you need a little bit more help check out our discord where we have people that can help you out with your code wiring whatever problems I guess that's it see you in the next one