/*****************************************************
*********       Penny Checker Module       ***********
*********  ME 218A - Aut 2007 - Project    ***********
******************************************************/

#include <stdio.h>
#include <ME218_C32.h>
#include <timers12.h>
#include "PWMS12.h"
#include "IO_Definitions.h"
#include "Constants.h"
#include "ConfigureInitialize.h"
#include "ADS12.h"


void WaitForPenny(void);      
/*   Waits until a penny has been inserted. */

char CheckPenny(void);
/*   Reads the penny sensor input */

void WaitForPenny (void)
{
  char event;
  
  while (1) 
    { 
      event = CheckPenny();   
      if (event == EVENT) {
        return;
      }
      else if (event == NO_EVENT); 
      
      else printf("Penny Error\r\n");
    }
}
          
char CheckPenny (void)
{
  char input;
  
  input = PTM & COINSENSOR; //Check if your input is high
  
  if (input != 0)
  {
    return EVENT;
  }
  else
  {
    return NO_EVENT;
  }
}
