{"id":819,"date":"2017-11-12T21:24:41","date_gmt":"2017-11-12T21:24:41","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=819"},"modified":"2019-03-26T22:24:35","modified_gmt":"2019-03-26T22:24:35","slug":"learning-arduino-for-beginners-ep8-while-loop-pull-up-resistors","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=819","title":{"rendered":"Learning ARDUINO for Beginners EP#8 while loop and pull up resistors"},"content":{"rendered":"<h1>In this tutorial we will make a Arduino piano to demonstrate how the while loop works..<\/h1>\n<p><iframe loading=\"lazy\" title=\"Learning ARDUINO for Beginners EP#8 while loop &amp; pull up resistors\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/NheQtzZLXCM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h1><strong><a href=\"https:\/\/www.facebook.com\/zarduino\/\">Check us out on Facebook!<\/a><\/strong><\/h1>\n<h2><\/h2>\n<h2>ARDUINO Code:<\/h2>\n<p>#define button1 2 \/\/ button pins<br \/>\n#define button2 3<br \/>\n#define button3 4<br \/>\n#define button4 5<br \/>\n#define button5 6<br \/>\n#define button6 7<br \/>\n#define button7 8<br \/>\n#define button8 9<br \/>\n#define button9 10<br \/>\n\/\/ save pin 11 for speaker<br \/>\n#define button10 12<br \/>\nint v1=HIGH; \/\/ button state value<\/p>\n<p>void setup() {<br \/>\npinMode(button1,INPUT_PULLUP);<br \/>\npinMode(button2,INPUT_PULLUP);<br \/>\npinMode(button3,INPUT_PULLUP);<br \/>\npinMode(button4,INPUT_PULLUP);<br \/>\npinMode(button5,INPUT_PULLUP);<br \/>\npinMode(button6,INPUT_PULLUP);<br \/>\npinMode(button7,INPUT_PULLUP);<br \/>\npinMode(button8,INPUT_PULLUP);<br \/>\npinMode(button9,INPUT_PULLUP);<br \/>\npinMode(button10,INPUT_PULLUP);<\/p>\n<p>}<\/p>\n<p>void loop() {<\/p>\n<p>v1=digitalRead(button1);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,1000);<br \/>\nv1=digitalRead(button1);<br \/>\n}<\/p>\n<p>v1=digitalRead(button2);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,900);<br \/>\nv1=digitalRead(button2);<br \/>\n}<\/p>\n<p>v1=digitalRead(button3);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,800);<br \/>\nv1=digitalRead(button3);<br \/>\n}<\/p>\n<p>v1=digitalRead(button4);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,700);<br \/>\nv1=digitalRead(button4);<br \/>\n}<\/p>\n<p>v1=digitalRead(button5);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,600);<br \/>\nv1=digitalRead(button5);<br \/>\n}<\/p>\n<p>v1=digitalRead(button6);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,500);<br \/>\nv1=digitalRead(button6);<br \/>\n}<\/p>\n<p>v1=digitalRead(button7);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,400);<br \/>\nv1=digitalRead(button7);<br \/>\n}<\/p>\n<p>v1=digitalRead(button8);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,300);<br \/>\nv1=digitalRead(button8);<br \/>\n}<\/p>\n<p>v1=digitalRead(button9);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,200);<br \/>\nv1=digitalRead(button9);<br \/>\n}<\/p>\n<p>v1=digitalRead(button10);<br \/>\nwhile(v1==LOW)<br \/>\n{<br \/>\ntone(11,100);<br \/>\nv1=digitalRead(button10);<br \/>\n}<\/p>\n<p>noTone(11); \/\/stop the tone from playing<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will make a Arduino piano to demonstrate how the while loop works.. Check us out on Facebook! ARDUINO Code: #define button1 2 \/\/ button pins #define button2 3 #define button3 4 #define button4 5 #define button5 &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=819\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":809,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-819","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=819"}],"version-history":[{"count":1,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/819\/revisions"}],"predecessor-version":[{"id":1274,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/819\/revisions\/1274"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/809"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}