#include #include #include int main(void) { int num1,num2; unsigned short start1, stop1, start2, stop2, v1, t1, v1rem, t1rem,s,d; unsigned long vel1,tim1; unsigned char in; OPTION=ADPU; //sets ADPU bit in the OPTION register ADCTL=SCAN|0x10; //sets AD scan for continuous scan on channels PE1, PE2, PE3 while ((PORTA & PA0)==PA0) //keeps the AD conversions going until PA0 goes low { printf("%d %d %d\n",ADR2,ADR3,ADR4); } num1=0; //initializes overflow count for ball blocking the first sensor num2=0; //initializes overflow count for ball between sensors TFLG2=TOF; start1=TCNT; //start of time for ball blocking the first sensor while ((PORTA & PA0)!=PA0){ //holds this loop while PAO is low if ((TFLG2 & TOF)==TOF) { //counts timer overflows num1= num1+1; // TFLG2=TOF; // } } stop1=TCNT; //start of time for ball blocking the first sensor if (stop1