{"id":8714,"date":"2018-04-06T02:00:15","date_gmt":"2018-04-06T06:00:15","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=8714"},"modified":"2018-04-25T02:04:38","modified_gmt":"2018-04-25T06:04:38","slug":"arduino-tutorials-for-testers-door-bell","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-door-bell\/","title":{"rendered":"Arduino Tutorials for Testers: build a door bell"},"content":{"rendered":"<p>This is the first installment of our tutorial series on <a href=\"https:\/\/www.arduino.cc\">Arduino<\/a>. In this tutorial, you will learn about how to build a DC Door Bell and two basic but important modules\/functions\/commands: Digital Read and Digital Write.<\/p>\n<hr \/>\n<h3>Why this post?<\/h3>\n<p>Arduino on a software QA site? Huh? Well, we think the tech world is changing enough that <a href=\"https:\/\/qxf2.com\/blog\/the-need-for-change-at-qxf2\/\">testing will have to adapt<\/a>. In the not too distant future, knowing how to work with simple circuits will be as common as testers needing to know how to code.<\/p>\n<p>But wait! Even if I buy that reason, what is so special about testers? Can&#8217;t they just follow any of the bazillion tutorials online about Arduino? Well, apparently not. Based on our experience, testers learn quickly by doing and exploring rather than following manuals or textbooks. If you look back at how you got good at testing, I am sure you picked up more by actually testing software rather than just reading textbooks.<\/p>\n<p>The material in this series of tutorials has been used to successfully train testers at Qxf2 on hardware. The results were good. So we thought we should share our work on our blog.<\/p>\n<hr \/>\n<h3>Components Required:<\/h3>\n<ol>\n<li>Arduino Board: Arduino is an open-source electronics platform based on easy-to-use hardware and software. Using Arduino, you can read input device\/sensors, process the data and control the output devices. For more details refer <a href=\"https:\/\/www.arduino.cc\/en\/Guide\/Introduction\">official site<\/a>.<\/li>\n<li>Breadboard: If you are new to Breadboard, refer the link <a href=\"https:\/\/learn.sparkfun.com\/tutorials\/how-to-use-a-breadboard\">here<\/a> to know how to use it.<\/li>\n<li>Jumper Wires: Use to build a circuit<\/li>\n<li>LED\/5VDC Buzzer: Refer the following figure 1 to identify the terminals of LED.\n<figure id=\"attachment_8928\" aria-describedby=\"caption-attachment-8928\" style=\"width: 150px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/04\/electronic-39971_1280.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8928 size-medium\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/04\/electronic-39971_1280-150x300.png\" alt=\"LED top view, side view, and symbol\" width=\"150\" height=\"300\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/04\/electronic-39971_1280-150x300.png 150w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/04\/electronic-39971_1280-512x1024.png 512w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/04\/electronic-39971_1280.png 640w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><figcaption id=\"caption-attachment-8928\" class=\"wp-caption-text\">Fig. 1 LED top view, side view, and symbol<\/figcaption><\/figure>\n<p>Take the LED in your hand and look at the LED from the top view. Observe at the outer body structure, you will see a circular body with a cut at one side of the body that looks like &#8216;-&#8216; (minus) shape as shown in above Fig. 1 at the top\/first image.\u00a0 The terminal near to minus &#8216;-&#8216; shape\/cut is a cathode (-ve) terminal. You can also identify terminals by looking at the LED from a side view as shown in above Fig. 1 at the middle of the image. Look at the internal structure of LED, the terminal with small kite shape is Anode (+ve) terminal.<\/li>\n<li>Push to ON Switch: Fig. 2 shows Push to ON Switch.\n<figure id=\"attachment_8717\" aria-describedby=\"caption-attachment-8717\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-8717\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch-300x248.png\" alt=\"Push to On Switch\" width=\"300\" height=\"248\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch-300x248.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch-768x634.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch-1024x845.png 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/push-to-on-switch.png 2000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-8717\" class=\"wp-caption-text\">Fig. 2 Push to On Switch<\/figcaption><\/figure>\n<p>This switch is also known as a BED-type switch because of its structure. If you don&#8217;t know basics of a switch, please go to the following link <a href=\"https:\/\/learn.sparkfun.com\/tutorials\/switch-basics\">here<\/a>\u00a0and to know how to identify the terminals of above switch refer the link\u00a0<a href=\"http:\/\/tymkrs.tumblr.com\/post\/19734219441\/the-four-pin-switch-hooking-it-up\">here<\/a>.<\/li>\n<li>Resistor: Here, we require a resistor of 330 ohms or above for a <a href=\"https:\/\/www.build-electronic-circuits.com\/current-limiting-resistor\/\">current limiting<\/a> purpose.<\/li>\n<\/ol>\n<p>You can get these components fairly easily at many places (including online). We bought our engineers <a href=\"https:\/\/www.amazon.in\/dp\/B01KNR581U\/ref=ox_ya_os_product\">this Arduino super-starter kit<\/a>.<\/p>\n<hr \/>\n<h3>Step 1: Connect LED to digital pin of Arduino:<\/h3>\n<p>Pull out all component mentioned above from your kit or from component list of the <a href=\"https:\/\/www.tinkercad.com\/\">simulator<\/a>.<\/p>\n<figure id=\"attachment_8721\" aria-describedby=\"caption-attachment-8721\" style=\"width: 622px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/led-connection-2.jpg\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8721 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/led-connection-2.jpg\" alt=\"Connect LED to Arduino\" width=\"622\" height=\"332\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/led-connection-2.jpg 622w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/led-connection-2-300x160.jpg 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/a><figcaption id=\"caption-attachment-8721\" class=\"wp-caption-text\">Fig. 3 Connect LED to Arduino<\/figcaption><\/figure>\n<p>Now, look at the above Fig. 3 and start building a circuit on a breadboard. Here, you need to select any digital pin of Arduino. We selected pin number 4 randomly. Use a jumper wire to connect pin number 4 of the board and any one terminal of the resistor, now connect the second terminal of the resistor to the anode of LED and connect the cathode of LED to GND pin of the board. Refer to Fig. 4 to confirm your connection.<\/p>\n<figure id=\"attachment_8722\" aria-describedby=\"caption-attachment-8722\" style=\"width: 934px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital-write.png\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8722 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital-write.png\" alt=\"LED Connection to Arduino using Breadboard\" width=\"934\" height=\"476\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital-write.png 934w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital-write-300x153.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital-write-768x391.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/a><figcaption id=\"caption-attachment-8722\" class=\"wp-caption-text\">Fig. 4 LED Connection to Arduino using Breadboard<\/figcaption><\/figure>\n<hr \/>\n<h3>Step 2: Write a code to turn LED ON and OFF:<\/h3>\n<p>Refer below flowchart to understand the flow of code.<\/p>\n<figure id=\"attachment_8723\" aria-describedby=\"caption-attachment-8723\" style=\"width: 418px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digitalWrite.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8723\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digitalWrite.png\" alt=\"Flowchart to turn ON\/OFF the LED\" width=\"418\" height=\"316\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digitalWrite.png 418w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digitalWrite-300x227.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a><figcaption id=\"caption-attachment-8723\" class=\"wp-caption-text\">Fig. 5 Flowchart to turn ON\/OFF the LED<\/figcaption><\/figure>\n<p><strong>Note:<\/strong> In below code, we are controlling two LED&#8217;s, one which connected to Arduino at pin 4 and other builtin LED which is connected to pin 13. Please read below code line by line. It is very easy to understand.<\/p>\n<h4>Arduino Code\/Sketch:<\/h4>\n<pre lang=\"arduino\">\/\/declare a variable and assign pin no.\r\nint ledPin = 4; \r\nint builtLed= 13;\r\n\r\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  pinMode(ledPin,OUTPUT);      \/\/set ledPin as a output pin\r\n  pinMode(builtLed,OUTPUT);    \/\/set builtLed as a output pin\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly:\r\n  digitalWrite(ledPin,HIGH);        \/\/Turn on external LED\r\n  digitalWrite(builtLed,LOW);       \/\/Turn off built-in LED\r\n  delay(1000);                      \/\/add delay of 1 sec\r\n  digitalWrite(ledPin,LOW);         \/\/Turn off external LED\r\n  digitalWrite(builtLed,HIGH);      \/\/Turn on built-in LED\r\n  delay(1000);                      \/\/add delay of 1 sec\r\n}\r\n<\/pre>\n<p>Above code uses a<strong> digitalWrite()\u00a0<\/strong>command\/function to turn ON\/OFF the LED. When you set a value to HIGH for particular pin using digitalWrite() function, Arduino will set pin value to logic 1 i.e. 5 V and for LOW, it will set pin value to logic 0 i.e. 0 V. So, as per the connection, Arduino turns ON LED when you set pin value of that LED to HIGH and vice-versa.<\/p>\n<p>Now, upload the code\/sketch on Arduino Board and observe the inbuilt and external connected LED Blinks alternately. To upload the sketch, you need to follow below steps:<\/p>\n<ol>\n<li>Open Arduino IDE. Write\/Copy the complete code and save it.<\/li>\n<li>Connect Arduino Board to your system (laptop\/desktop)<\/li>\n<li>Go to Tools Menu &gt; Boards and select your Arduino Board type<\/li>\n<li>Go to Tools Menu &gt; Port and select the correct port<\/li>\n<li>Now you are set to upload the code. Click on upload button on the toolbar or Go to Sketch Menu, and click on upload button.<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> Please do not disturb connection, when you move to step 3 to avoid repetition.<\/p>\n<hr \/>\n<h3>Step 3: Interface switch to Arduino<\/h3>\n<figure id=\"attachment_8724\" aria-describedby=\"caption-attachment-8724\" style=\"width: 438px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interface_switch.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8724\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interface_switch.png\" alt=\"Connect the switch to Arduino\" width=\"438\" height=\"351\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interface_switch.png 438w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interface_switch-300x240.png 300w\" sizes=\"auto, (max-width: 438px) 100vw, 438px\" \/><\/a><figcaption id=\"caption-attachment-8724\" class=\"wp-caption-text\">Fig. 6 Connect the switch to Arduino<\/figcaption><\/figure>\n<p>Refer the\u00a0above Fig. 6 and try to build the circuit on a breadboard. To identify &#8216;NO'(normally open) pins refer link <a href=\"http:\/\/tymkrs.tumblr.com\/post\/19734219441\/the-four-pin-switch-hooking-it-up\">here<\/a>. In above connection, we used the resistor to avoid the short circuit between Vcc (5V pin) and GND when we press the switch.<\/p>\n<p>Check out below Fig.7 to confirm your connections are OK or not.<\/p>\n<figure id=\"attachment_8725\" aria-describedby=\"caption-attachment-8725\" style=\"width: 919px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/switch_interfacing.png\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8725\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/switch_interfacing.png\" alt=\"Connect Switch to Arduino using Bread Board\" width=\"919\" height=\"469\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/switch_interfacing.png 919w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/switch_interfacing-300x153.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/switch_interfacing-768x392.png 768w\" sizes=\"auto, (max-width: 919px) 100vw, 919px\" \/><\/a><figcaption id=\"caption-attachment-8725\" class=\"wp-caption-text\">Fig. 7 Connect Switch to Arduino using Breadboard<\/figcaption><\/figure>\n<hr \/>\n<h3>Step 4:\u00a0Write code to read data on digital pin<\/h3>\n<p>Refer below flowchart to understand the flow of code.<\/p>\n<figure id=\"attachment_8726\" aria-describedby=\"caption-attachment-8726\" style=\"width: 426px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital_read.png\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8726\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital_read.png\" alt=\"Flowchart to read pin value\" width=\"426\" height=\"407\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital_read.png 426w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/digital_read-300x287.png 300w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/a><figcaption id=\"caption-attachment-8726\" class=\"wp-caption-text\">Fig. 8 Flowchart to read pin value<\/figcaption><\/figure>\n<h4>Arduino Code\/Sketch:<\/h4>\n<pre lang=\"Arduino\">int switchbuttonPin = 7;    \/\/declare a variable and assign pin no.\r\nint switchValue = 0;        \/\/declare a variable to hold switch value\r\n\r\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  pinMode(switchbuttonPin,INPUT); \/\/ Set switch button pin as input pin\r\n  Serial.begin(9600);             \/\/ Initialize serial monitor \r\n}\r\n\r\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly:\r\n  switchValue = digitalRead(switchbuttonPin); \/\/ read switch value and hold it in variable\r\n  Serial.print(\"Switch Value = \");      \/\/ print message on serial monitor and keep cursor on same line\r\n  Serial.println(switchValue);          \/\/ print switch value on serial monitor and move cursor to next line\r\n}\r\n<\/pre>\n<p>Above code\/sketch read the value at pin 7 which is connected to switch. Command\/function\u00a0<strong>digitalRead()\u00a0<\/strong>will help to read the value of any digital pin. As per the switch connection, you will get value &#8216;0&#8217; at pin 7 of Arduino when we press (and hold) the switch and value &#8216;1&#8217; in release position because when we press the switch, GND will directly get connected to pin 7 and in normal\/release state, pin 7 will get connected to VCC via resistor. You can see these values on serial monitor as we are printing it. Upload the above code\/sketch on Arduino and open the serial monitor. To open the serial monitor, you need to click on serial monitor icon available at the upper right corner of IDE or go to tools menu and click on &#8216;Serial Monitor&#8217; option.<\/p>\n<hr \/>\n<h3>Step 5: Build Door Bell Circuit<\/h3>\n<figure id=\"attachment_8728\" aria-describedby=\"caption-attachment-8728\" style=\"width: 794px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/DC-Door-Bell-1.jpg\" data-rel=\"lightbox-image-8\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8728 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/DC-Door-Bell-1.jpg\" alt=\"Circuit Diagram of DC Door Bell\" width=\"794\" height=\"358\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/DC-Door-Bell-1.jpg 794w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/DC-Door-Bell-1-300x135.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/DC-Door-Bell-1-768x346.jpg 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/a><figcaption id=\"caption-attachment-8728\" class=\"wp-caption-text\">Fig. 9 Circuit Diagram of DC Door Bell<\/figcaption><\/figure>\n<p>Above connection diagram is a combination of step 1 and step 3 of the tutorial, if you don&#8217;t disturb any connection during step 3, your connection will look like above Fig. 9. You can also look at part b of above Fig. 9, it is the equivalent circuit of Door Bell without any controller. You can build that and check it on a breadboard.<\/p>\n<p>Check out below Fig. 10 for Door Bell Circuit using Breadboard.<\/p>\n<figure id=\"attachment_8729\" aria-describedby=\"caption-attachment-8729\" style=\"width: 669px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/door_bell.png\" data-rel=\"lightbox-image-9\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8729\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/door_bell.png\" alt=\"DC Door Bell Connections using Breadboard\" width=\"669\" height=\"334\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/door_bell.png 669w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/door_bell-300x150.png 300w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/a><figcaption id=\"caption-attachment-8729\" class=\"wp-caption-text\">Fig. 10 DC Door Bell Connections using Breadboard<\/figcaption><\/figure>\n<p><strong>Note:<\/strong>\u00a0After uploading below sketch, if you are able to turn LED ON and OFF by pressing the switch, then you need to replace LED with 5V DC buzzer. Connect +ve terminal of buzzer at the place of Anode and -ve terminal at the place of Cathode.<\/p>\n<hr \/>\n<h3>Step 6: Code for Door Bell<\/h3>\n<p>Refer below flowchart to understand the flow of code.<\/p>\n<figure id=\"attachment_8730\" aria-describedby=\"caption-attachment-8730\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/Door_Bell_.png\" data-rel=\"lightbox-image-10\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8730\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/Door_Bell_.png\" alt=\"Flowchart of DC Door Bell\" width=\"550\" height=\"437\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/Door_Bell_.png 550w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/Door_Bell_-300x238.png 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-8730\" class=\"wp-caption-text\">Fig. 11 Flowchart of DC Door Bell<\/figcaption><\/figure>\n<h4>Arduino Code\/Sketch:<\/h4>\n<pre lang=\"Arduino\">int BellPin = 4;            \/\/declare a variable and assign pin no.\r\nint SwitchbuttonPin = 7;    \/\/declare a variable and assign pin no.\r\nint SwitchValue = 0;        \/\/declare a variable to hold switch value\r\n\r\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  pinMode(BellPin,OUTPUT);        \/\/set Bell Pin as a output pin\r\n  pinMode(SwitchbuttonPin,INPUT); \/\/ Set switch button pin as input pin\r\n  Serial.begin(9600);             \/\/ Initialize serial monitor \r\n}\r\n\r\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly\r\n  SwitchValue = digitalRead(SwitchbuttonPin); \/\/ read switch value and hold it in variable\r\n  Serial.print(\"Switch Value = \");      \/\/ print message on serial monitor and keep cursor on same line\r\n  Serial.println(SwitchValue);          \/\/ print switch value on serial monitor and move cursor to next line  \r\n  if (SwitchValue == 0) {\r\n    digitalWrite(BellPin,HIGH); \/\/Ring the bell\r\n  }\r\n  else{\r\n    digitalWrite(BellPin,LOW); \/\/Keep Bell in off state\r\n  }\r\n  delay(500); \/\/ add some delay\r\n}\r\n\r\n<\/pre>\n<p>Above code will read the status of the switch using digitalRead command\/function and based on the status of the switch it will turn the LED ON\/OFF using digitalWrite command\/function. Once, the circuit is working fine as expected replace the LED with Buzzer.<\/p>\n<hr \/>\n<p>Hope you enjoyed the tutorial. In this tutorial, you learned about how to read and write a digital value on Arduino pins. In our <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-light-dimmer\/\">next tutorial<\/a>, you will learn about two more important modules\/functions that will help you to control the brightness of a light. If you follow along, at the end of this <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorial-series-for-testers\/\">series<\/a>, you will distinguish how hardware devices\/instruments\/products are designed, you can guess how they are programmed, you will get ideas about how to test it and you can build and help others in building products.<\/p>\n<p><strong>Learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2 Services<\/a>.<\/strong><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>This is the first installment of our tutorial series on Arduino. In this tutorial, you will learn about how to build a DC Door Bell and two basic but important modules\/functions\/commands: Digital Read and Digital Write. Why this post? Arduino on a software QA site? Huh? Well, we think the tech world is changing enough that testing will have to [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159,117],"tags":[119],"class_list":["post-8714","post","type-post","status-publish","format-standard","hentry","category-arduino","category-hardware-testing","tag-arduino"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=8714"}],"version-history":[{"count":41,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8714\/revisions"}],"predecessor-version":[{"id":14831,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8714\/revisions\/14831"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=8714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=8714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=8714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}