Software
Overview
We designed the software to be modularized and easy to integrate. The motors, IR beacon sensor, ultrasonic sensors, and motors each had global enumerated variable states that would constantly update and could be used in function calls at any time. Our functionality can be broken down into four stages:
- Escape safe space
- Find fact checker
- Go to launch site and launch 9 balls
- Return home for reloading
system states
The bot cycled through a programmed set of states to escape the safe space, hit the fact checker, and launch balls. More intricate strategy was planned, but not implemented due to time constraints.
ultrasonic sensor (ping) states
The ultrasonic sensors were continuously pinged to check distances. The pings alternated between each sensor every 45 milliseconds to avoid interference. The pings would update a global enumerated variable pingState, oscillating between the three states below. This ping state was used in logical checks to align the bot with the wall or determine distance away from the wall at any given time.
beacon sensor states
The beacon sensor states were continually updated through interrupts on pins 2 and 3. The beacon state was checked for alignment before launching balls and going home. The system was capable of distinguishing between the social media controlled/uncontrolled signals and the homing beacon signal.
Reference
The source Arduino code can be found here.