finished logic

probably next step is to then apply this to an arduino in a prototype.  but, test next