Skip to main content

Timeline for Using OR with a while loop

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
May 25, 2021 at 6:25 comment added Bill Patton I have a slide with two limits on it. One at each end of the slide. I'm doing experiments with this slide. At one time during programming I want home_limit1 to operate as a home switch for the CW direction. In a different program I want the slide to run in the opposite direction, CCW and now home_limit2 will now act as a home switch. I just wanted to know if I could or 2 digital reads together as shown above. while(digitalRead(home_limit1) || home_limit2). This way I could change the logic below the statement and make the motor run to the counterclockwise Direction and trip home_limit2.
May 24, 2021 at 9:35 answer added Majenko timeline score: 2
May 24, 2021 at 9:34 history edited Edgar Bonet CC BY-SA 4.0
Code formatting.
May 24, 2021 at 4:52 review Close votes
Jun 6, 2021 at 6:02
May 24, 2021 at 2:35 comment added hcheung In while(digitalRead(home_limit1) || home_limit2), the program will not evaluate home_limit2 as long as digitalRead(home_limit1) return 1, is that what you want? do you really means while(digitalRead(home_limit1) && home_limit2)? If this is not what you want, you will need to edit your post to explain in plain English of what you want first.
May 24, 2021 at 2:22 comment added Coder9390 Firstly, when posting code select it and press ctrl+k to formatt it properly. Try putting digitalRead in for both conditions and also specify what digitalRead value it should be
May 24, 2021 at 1:55 review First posts
May 24, 2021 at 1:58
May 24, 2021 at 1:54 history asked Bill Patton CC BY-SA 4.0