Basically I am trying to "blink an eye." The servo is connect to an eyelid and I want it to blink all the open or closed. I have a randomized code that moves the servo to random locations. How would I go about coding this to move it randomly from closed to open without stopping in the middle?
bool open = random(2); // open is 0 or 1 ie false or true
// Three ways to do it with varying levels of verboseness
// 1:
if (open) {
eye.write(120);
}
else {
eye.write(30);
}
// 2:
eye.write(open? 120 : 30);
// 3:
eye.write(90*open + 30);
is a test for open, and if it's true return 120, else return 30.
But I can't find the syntax anywhere in the Arduino Reference so I'm intrigued as to where you found out about it. Is it lurking in the reference somewhere that I didn't see?
is a test for open, and if it's true return 120, else return 30.
But I can't find the syntax anywhere in the Arduino Reference so I'm intrigued as to where you found out about it. Is it lurking in the reference somewhere that I didn't see?
You can also try www.cplusplus.com for C++ code reference. The Arduino reference focuses on functions in the Arduino library, rather than C/C++ itself.