Pre-lab:
There are two parts to the pre-lab: one is code writing, the other is to determine the number of grid points and the time to measure at each grid point. Here is the pseudo code for the microcontroller. Write the code and print it out as your pre-lab. Have the code ready to use in the lab:
1. Set up DIO3 as input
2. Set up serial connection with computer
3. Time to count = (some number of milliseconds, more than 1 less than 32,000)
Main loop:
1. Print "Press space bar to start counting"
2. While (no bytes from computer), wait 10ms
3. Clear buffer by reading string
4. Print "counting" with line feed
5. To = number of milliseconds (see below)
6. Set Counter = 0
7. While (Number of milliseconds - To) Time_to_count
8. If pulse on DIO3 within 10,000s, then Counter
9. Print out Counter value and line feed
Some Arduino code which will be useful:
1. Number of milliseconds since program started pulseIn(pin, value, timeout) - the length of pulse read in, here value = HIGH, timeout = 10,000.
2. millis() - returns 0 if no bytes sent from computer
3. If no pulse, this returns 0
4. Serial.available() - reads string from serial input, clears buffer so that Serial.available() is 0 again
5. Serial.readString() - your count
And the smaller the grid size, the better your data! Keep in mind you only have 3 hours to complete the lab. You should probably aim for 1.5 hours of data taking. Suppose you use linear spacings and count for 30s. This will take you 7x5 points x 18 minutes, not counting time to move the sample. Complete this calculation in your lab book.