The final step was to program the microcontroller in which we decided to use a very straight forward if and else statement to check the state of PD0 for our input high from the proximity brain. We then used a For the if-else statement a delay_ms was used to control the delay of the outputs of our different ports, and timing for the entire run. We added a buzzer to attract onlookers to our display that was in the else statement with a delay. We could not get programmers notepad that we used in all the labs to work at home so we opted to work with a program called codevisionavr that had all the #include functions already in the program for use. For our program we had the motor turn the pill’s then level 1 ejected, the motor ran and then level 2 ejected and then there was a delay before the trap door would release the pills into the Dixie cup. We then had the else statement include a delay and then activated the buzzer that was used to attract onlookers and also show how a timer function could allow for reminders to take pills, see appendix c figure 2 for program.
To review the completed pill dispensers flow chart to show the logic part of the system is in figure 10.