1 00:00:00,270 --> 00:00:06,360 Hello. In this video tutorial we're 2 00:00:06,360 --> 00:00:07,680 going to learn how to use a 3 00:00:07,680 --> 00:00:10,560 buzzer a buzzer or a beeper is 4 00:00:10,560 --> 00:00:13,140 a device that produces sound the first 5 00:00:13,140 --> 00:00:14,580 thing we need to know is that 6 00:00:14,670 --> 00:00:16,470 there is a buzzer here in the 7 00:00:16,470 --> 00:00:20,070 library of components in spanish it's called 8 00:00:20,160 --> 00:00:20,700 "Piezo" 9 00:00:22,230 --> 00:00:23,490 and we're going to click and drag 10 00:00:23,490 --> 00:00:25,800 this to the protoboard so we're 11 00:00:25,800 --> 00:00:27,450 going to connect the beeper or buzzer 12 00:00:27,450 --> 00:00:29,760 to the arduino board and one of 13 00:00:29,760 --> 00:00:32,130 the connectors is going to be connected 14 00:00:32,130 --> 00:00:34,980 to the ground and the other one 15 00:00:35,040 --> 00:00:37,110 to whichever digital pen we want 16 00:00:38,520 --> 00:00:41,280 so for instance here it has been 17 00:00:41,280 --> 00:00:42,870 connected to pin twelve 18 00:00:47,520 --> 00:00:49,290 now to program it let's have a 19 00:00:49,290 --> 00:00:50,340 look at the code 20 00:00:56,640 --> 00:00:58,710 so this is the simplest way to 21 00:00:58,710 --> 00:01:01,380 program the buzzer we have used one 22 00:01:01,380 --> 00:01:03,540 of the blue output blocks from this 23 00:01:03,540 --> 00:01:04,319 set here 24 00:01:05,580 --> 00:01:07,530 and we use the one for "pasador" 25 00:01:07,563 --> 00:01:09,030 word meaning connector 26 00:01:14,070 --> 00:01:16,740 and we've connected it to number twelve 27 00:01:17,220 --> 00:01:20,550 and "tono" is the tone or frequency 28 00:01:20,550 --> 00:01:22,800 and it's going to be fifty hurts 29 00:01:23,640 --> 00:01:25,980 and it's going to make sound for 30 00:01:26,010 --> 00:01:27,960 half of a second and then we 31 00:01:27,960 --> 00:01:30,240 will wait for one second 32 00:01:30,240 --> 00:01:31,440 before we start again 33 00:01:34,530 --> 00:01:35,850 so that's where we have to wait 34 00:01:36,510 --> 00:01:38,760 but be careful because sound for half 35 00:01:38,760 --> 00:01:40,710 of a second and waiting for one 36 00:01:40,710 --> 00:01:42,600 more second does not mean that the 37 00:01:42,600 --> 00:01:44,370 whole program will last one and a 38 00:01:44,370 --> 00:01:49,170 half seconds because the moment that we 39 00:01:49,170 --> 00:01:51,810 start the sound we start the waiting 40 00:01:51,810 --> 00:01:52,800 to see 41 00:01:52,800 --> 00:01:54,660 that means that while we're waiting there 42 00:01:54,660 --> 00:01:57,840 is also sound continuing so here it 43 00:01:57,840 --> 00:01:59,790 means that we're going to be waiting 44 00:01:59,790 --> 00:02:02,010 for one second but during this second 45 00:02:02,190 --> 00:02:03,960 half of it will have sound 46 00:02:05,340 --> 00:02:08,280 so here we have a square wave 47 00:02:09,840 --> 00:02:11,400 half of the second is going to 48 00:02:11,400 --> 00:02:13,620 be sound and the second half will 49 00:02:13,620 --> 00:02:16,140 be no sound because we're waiting for 50 00:02:16,140 --> 00:02:18,180 that one second to finishing the 51 00:02:18,180 --> 00:02:18,630 program 52 00:02:27,120 --> 00:02:29,280 okay so if we start the simulation 53 00:02:39,000 --> 00:02:41,370 now let's change the frequency from fifty 54 00:02:41,430 --> 00:02:42,930 to one hundred hertz 55 00:02:44,940 --> 00:02:47,640 and try again it sounds different 56 00:02:49,980 --> 00:02:51,480 because the frequency is higher 57 00:02:53,280 --> 00:02:55,110 it sounds different because the frequency is 58 00:02:55,110 --> 00:02:57,840 high now let's try this instead of 59 00:02:57,840 --> 00:03:00,270 producing sound for half of a second 60 00:03:00,330 --> 00:03:02,340 let's do it for zero point seven 61 00:03:02,340 --> 00:03:03,000 seconds 62 00:03:04,770 --> 00:03:06,570 and that means that seventy percent of 63 00:03:06,570 --> 00:03:08,850 the time there will be sound during 64 00:03:08,910 --> 00:03:10,770 the seventy percent of the time we 65 00:03:10,770 --> 00:03:11,280 are waiting 66 00:03:14,340 --> 00:03:16,650 so let's produce this sound now again 67 00:03:22,260 --> 00:03:22,890 can you hear 68 00:03:24,090 --> 00:03:25,380 can you hear that there's a period 69 00:03:25,380 --> 00:03:27,360 of time while there's no sound and 70 00:03:27,360 --> 00:03:29,640 it's shorter than before so there's sound 71 00:03:29,640 --> 00:03:31,800 four point seven seconds and then no 72 00:03:31,800 --> 00:03:34,110 sound for point three seconds this is 73 00:03:34,110 --> 00:03:36,120 the simplest way of programming a buzzer 74 00:03:36,330 --> 00:03:37,920 but we're going to make the program 75 00:03:37,920 --> 00:03:40,770 a little more complicated we are going 76 00:03:40,770 --> 00:03:43,140 to program it using a 77 00:03:43,140 --> 00:03:44,160 different sequence 78 00:03:44,190 --> 00:03:45,000 with a loop 79 00:03:51,240 --> 00:03:53,280 okay so now you can see this 80 00:03:53,280 --> 00:03:57,000 code this word here means loop this 81 00:03:57,000 --> 00:03:59,010 is a program we have from before 82 00:03:59,010 --> 00:04:00,780 the same one and we are going 83 00:04:00,780 --> 00:04:02,730 to put it inside of the loop 84 00:04:03,390 --> 00:04:06,720 so there are two drop-down possibilities counting 85 00:04:06,720 --> 00:04:10,080 upward or downward so we will either 86 00:04:10,080 --> 00:04:11,280 move up or down 87 00:04:12,540 --> 00:04:13,860 so the first thing that we need 88 00:04:13,890 --> 00:04:15,210 is a variable 89 00:04:19,440 --> 00:04:19,950 this 90 00:04:21,660 --> 00:04:24,180 this purple ok the name for this 91 00:04:24,180 --> 00:04:25,860 variable is tono you can name it 92 00:04:25,864 --> 00:04:28,980 frequency or tone whatever you want so 93 00:04:28,980 --> 00:04:31,680 with this variable we are controlling the 94 00:04:31,680 --> 00:04:34,710 frequency we are going to sweep frequencies 95 00:04:34,710 --> 00:04:36,690 from ten hertz to one hundred and 96 00:04:36,690 --> 00:04:39,870 thirty hertz and each time it jumps 97 00:04:39,870 --> 00:04:41,280 by twenty units 98 00:04:41,280 --> 00:04:42,870 is moving upwards 99 00:04:44,010 --> 00:04:45,510 okay I will show you an example 100 00:04:46,260 --> 00:04:49,410 it's first frequency and then hurts 101 00:04:51,390 --> 00:04:52,860 to the second one is ten plus 102 00:04:52,860 --> 00:04:55,230 twenty so thirty thirty plus twenty is 103 00:04:55,230 --> 00:04:58,950 fifty then fifty plus twenty seventy then 104 00:04:59,010 --> 00:05:01,620 ninety one hundred ten and one hundred 105 00:05:01,620 --> 00:05:03,600 thirty is the last one so each 106 00:05:03,600 --> 00:05:06,270 time we jump we're adding twenty units 107 00:05:06,270 --> 00:05:08,250 according to the program and this is 108 00:05:08,250 --> 00:05:10,800 the meaning of twenty here and 109 00:05:10,800 --> 00:05:12,900 we're starting with ten and ending with 110 00:05:12,900 --> 00:05:13,560 one thirty 111 00:05:15,510 --> 00:05:17,730 here we have the variable we are 112 00:05:17,730 --> 00:05:20,220 going to use to store the numbers 113 00:05:20,520 --> 00:05:22,710 and tier having upwards means that the 114 00:05:22,710 --> 00:05:25,080 numbers will get higher or count up 115 00:05:25,530 --> 00:05:27,390 we could also choose to move downwards 116 00:05:27,420 --> 00:05:29,010 but in that way we will start 117 00:05:29,010 --> 00:05:31,620 with one thirty and finish at ten 118 00:05:32,700 --> 00:05:33,120 okay 119 00:05:34,350 --> 00:05:35,850 so i think now you can see 120 00:05:35,850 --> 00:05:38,340 that we have a lot of possibilities 121 00:05:38,340 --> 00:05:40,470 in this loop it's the same set 122 00:05:40,470 --> 00:05:42,660 from the previous example that is now 123 00:05:42,660 --> 00:05:44,880 inside the loop so listen to the 124 00:05:44,897 --> 00:05:45,660 simulation 125 00:05:47,520 --> 00:05:49,050 and you will be able to hear 126 00:05:49,050 --> 00:05:52,170 the frequencies get higher until it loops 127 00:05:52,320 --> 00:05:53,910 and starts all over again 128 00:05:58,050 --> 00:05:59,910 okay let's start a simulation 129 00:06:10,020 --> 00:06:11,940 you are how it's going up getting 130 00:06:12,390 --> 00:06:12,840 higher 131 00:06:14,040 --> 00:06:16,230 frequency is getting higher so this second 132 00:06:16,230 --> 00:06:17,730 program is what you are going to 133 00:06:17,730 --> 00:06:19,980 reproduce as well as answer two more 134 00:06:19,980 --> 00:06:21,210 questions below 135 00:06:23,490 --> 00:06:23,940 good luck