{"id":1391,"date":"2021-10-21T13:22:28","date_gmt":"2021-10-21T13:22:28","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=1391"},"modified":"2021-10-21T13:22:46","modified_gmt":"2021-10-21T13:22:46","slug":"solved-break-statement-not-within-loop-or-switch","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/break-statement-not-within-loop-or-switch\/29637.html","title":{"rendered":"Solved Break Statement Not Within Loop Or Switch"},"content":{"rendered":"<p>I am using the Arduino Uno and am trying to control a stepper motor. I&#8217;m getting the error(&#8220;break statement not within loop or switch ) when I try and compile the following code: I want to break out of the loop if the first &#8220;if statement is true&#8221; Any suggestions??<\/p>\n<p>void loop()<br \/>\n{<\/p>\n<p>\/\/Stepper motor will turn 90 degrees counterclockwise, VALVE WILL OPEN<\/p>\n<p>if (ValveStatus==1) {<br \/>\nbreak; }<br \/>\nelse if ((duration\/74\/2)&lt;5) {<\/p>\n<p>Serial.println (&#8220;OPEN VALVE&#8221;);<br \/>\nmyStepper.step( -stepsPerRevolution);<br \/>\ndelay(500);<br \/>\nValveStatus++;<br \/>\n}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":4},"question-category":[55],"question_tags":[],"class_list":["post-1391","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/1391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=1391"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=1391"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}