 So this right here is a sound sensor. We can also call it a microphone, but I think with arduino's and sound sensors They're usually not really good. They have record really crappy frequencies nothing near a professional microphone So we call them sound sensors due to the effect Just like most arduino Modules it has a positive a negative and then in this case we have two different signal wires We've got the yellow which is a digital and the one that has nothing on it here Which is an analog digital is always very minimal information It's usually just high or low one or zero versus analog where you get a whole scale of results So I'm guessing analog you would use to get exactly how high the sound is or what kind of frequencies you're getting out of the Mic we're digital what we're gonna do is we're just gonna see if it's loud or not using this blue box here We're gonna change the sensitivity of the sound module and then from there We can tell it went to trigger and tell the yellow wire. Hey, something's loud Now I don't want to just do that and just put on the screen one or zero loud or not whatever be pretty boring So I have this little fan module right here And when I clap or when I make a loud noise I want the fan to turn on and then the next time there's a loud noise I want it to turn off all you're gonna need is the three cables for your sound sensor And then my fan module comes with two wires already soldered in but you probably just need to Then all you need is an Arduino and you're ready to go the sound sensor Like always is gonna plug into the five-volt with the red cable. So that's right over here And then we're gonna plug into the ground right next to it And then the yellow cable is gonna go into any of the digital pins. I'm gonna put it into seven We're gonna take our fan module here. I have a piece of tape because it keeps falling over I'm gonna tape to the table here quickly We're gonna plug in the ground into a ground port Then we're gonna plug in power Into Let's say pin number six. I just have to plug in my Arduino Into my computer and now we can see everything has power if I turn off my LED in my room here We could see there's one red light on our sound sensor And I'm gonna actually take it and rub my finger across the microphone And you can see that LED there is flashing on and off It's currently flashing when I hear is a really loud sound which in this case is My finger smashing on the mic kind of like if I did this We're gonna open up the Arduino editor and we're right away gonna jump into it just make sure you go to tools and Ports and choose the right port in this case. I'm on port six where my Arduino's plugged in if you get errors about your board Just make sure you're choosing the right board First thing we're gonna do is we're gonna tell it what ports things are plugged into so we have our sound sensor And that is plugged into Port number seven so we're just gonna do that and then we have our fan which is plugged into 126 we're also gonna want to hold a value called the boolean So that's like a true or false and we're gonna call that fan status And that's pretty much going to be if the fans on or not So if this is true fan will turn on if it's false fan will turn off Then we got to go and tell the board that we have two pins that we're going to be using so we use this thing called pin mode We're gonna take our sound sensor. So let's just copy paste that And let's copy paste this line do that We're gonna have to tell the pin mode how we're gonna use the pin So in this case the sound sensor pin is gonna be an input While this is going to be an output because we're putting out power to the fan Just make sure you end with so many colons and that's all you need to do in there Next step is to put stuff in our loop. This is what loops once the original setup function runs So the setup is just the initial things that happen right away when the app starts or when the machine starts So the computer starts whatever you want to call it and the loop is what loops over and over and over as it's on So here we have a couple things to do first thing we have to do is pull the results from our sound sensor every X amount of time. So I'm gonna go and make a value here called data And we're going to be doing digital read since it's the digital module and grab sound Sensor and then we're gonna go and right away jump into our if statement where we're gonna check if our data is Equal to one so one would be loud We're hearing noise and then if we went if data equals zero it would be when the mic is quiet So one thing you can also do is just Make it so that if data equals one turn on the fan if data equals zero turn off the fan And then you'd have to scream into the mic consistently. We're just going to check fan status. Whoops right over here if fan status equals false We're going to tell it to take fan status And turn it into true and Then we have to use our digital right and Tell it to take the fan that's plugged into port number six and Put it on high so high is because it's an output port. We're going to be telling it to put out power You can see here. We're reading From an input port right sound sensor is our input port, but now we're going to be output We're going to be using our output port. So we're going to be out porting power using digital right So if we had an LED on the same pin, we would use digital right Digital right is when you're putting out power through a digital port now all we got to do is tell it else So if it's not data one, then we need to take fan status make it equal to false and Oops So what we have working right now? Well, I should go first and I don't delay Let's make it a 10th of a millisecond a 10th of a second What's happening in the sound sensor? It's going to tell us one or zero higher low if it's loud or not If it's loud We're going to check if fan status is on or off if the current if the fan is currently on We're going to go into the else and turn it off if the fan is currently off We're going to go into here and we're going to turn it on and we're also going to set our flag here Fan status to be true or on because on the next time we're going to have to turn it off So what we're doing with this fan status is just keeping on the side a Value that we can look at and it won't get reset when the whole loop happens because as you know If you don't know when you run a loop anything between the loop brackets gets reset on the next iteration So if you want to keep something You know, you want to keep a note about something that is inside the loop You're going to want to hold it outside the loop We got these brackets right here and fan status is not inside of them So it won't get reset every time the loop resets now All we got to do is compile and send that to our Arduino. It seems like it's working. Let's go to the Arduino quickly and Test it all out. First thing you want to do is make sure this fan is taped down This fan is a little buggy. So hopefully it doesn't forget. Oh, I must activate it there So the fan is currently spinning and if I go to the microphone again and make some noise on it Oh, it turns off if I go and I guess it's not loud enough. Oops. I'm bending it No, I'm turning it on and off. There we go. Now it's on whoo finally It's really goddamn hot here in Canada. So this useless fan. I wish it did something All right, so we got some air going we put our fingers on it You can see it stops and starts again, and we're gonna take our sensor and just Turn it off. Boom. Beautiful If you're interested in learning more about sensors more about our aduinos Or you just want to see me build funny robots where I torture myself Look at my recent videos. I made a video where I connected a taser to my arm and twitch check and trolled it Ah Nice fuck off dude. You're killing me The video where I took a Roomba and it made dirt on the floor and there we go. It works It's alive. Oh No A bunch of really cool sensor videos where you can learn a bunch of things if you want to see any of this stuff Comment below maybe let me know. Hey, I'm working currently with a Magnetic sensor and I don't know how it works or how to use it. Can you please teach me? And I'll make a video about that this video helped you out Please give it a like and we subscribe to the channel and I'll see you in tomorrow's stream Where we'll finish our LED clock that we're building that's taken us way too long. Thanks for being here everyone. I really appreciate it