This code was created by putting together fragments of code one private which is my main project and the other had was a code from the forum.
Explanation
bool myFlag = false; //create + name flag
This code creates and lets you name your flag.
if (myFlag == false) //if myFlag is true turn
This code states that if the flag is true then turn of the pin or whatever
myFlag = true; // set the flag to true thus turning servo1 off
This states that the flag is turned so (in this case) turn off the servo
myFlag = false; // set the flag to false thus turning servo 1 on
This states that there is no flag so (in this case) the servo can turn on again
THIS EXPLANATION MAY NOT BE 100% RIGHT SINCE I MYSELF AM REASONABLY NEW TO FLAGS.
THE CODE MAY NOT WORK ON OTHER MODULES SINCE IT DIDN'T ALWAYS WORK FOR ME WITH OTHER MODULES
As you may have noticed I don't currently have a circuit schematic programe; it would be great if someone could recommend me one. Thanks
EXPANDED TECHNICAL DETAILS
Kinetic Indicator Logic
This project uses physical "Flags" or semaphores as a charming and mechanical alternative to digital screen alerts.
- Angular Position Mapping: The Arduino manages a SG90 micro servo attached to a physical flag arm. The firmware maps digital events (e.g., an incoming email or a sensor trigger) to specific servo degrees (0° for DOWN, 90° for UP).
- Smooth Swing Animation: To prevent the flag from snapping too quickly and damaging the mechanical joint, the code uses a loop to incrementally update the servo position, creating a rhythmic and deliberate "Raising" movement.
Practical Use Cases
- Visual Alert System: Ideal for quiet environments like libraries or home offices where a mechanical indicator is more peaceful than a buzzer or screen notification.