Code Representation

Headers, libraries, and definitions

int main()
{

Display welcome message and prompt for touch

While (touch screen not pressed) { }  //Wait for touch-screen to begin program 

Wait 500 ms to prevent touch from being read twice

While (touch screen not pressed)  //Run until user presses screen to end program

{

Function: Read data

Function: Analyze

Function: Display

}

Display Thank you and Good-bye message

} //Close main 

 

Read

{

Start Timer

While (Number of switches <= 47 && Time less than 1 second)

{

       Data_array(counter)= input variable IR.Value()

               If ( counter >= 1)

{

If (Value has changed from previous)

{

Increase switches

}

}

        Sleep(1);

Increment counter

} //end While loop

 Stop timer

}

 

Analyze

{

Time Elapsed = Stop time – start time

Number of Cycles = Number of Switches / 2

Frequency = Number of Cycles / Time elapsed

}

 

Display

{

LCD.Clear()

Use if statements and LCD.WriteLine(frequency) to display appropriate frequency to screen

If no IR is emitted, display “0 Hz”

}