by Wendell Cotton
The barcode function is used to determine which spray pattern to use for which crop. This function was based on the code submitted for Lab 4. It is broken up into three different parts. The first part is the header file for the entire function. The header contains all of the function prototypes that will be used for the other functions that make up the entire Barcode Function. The second part is the Barcode˙tables.c function. This function contains all of the tables used to determine the values for the various digits in the barcode. It also contains all the functions used to determine if the barcode is finished transmitting or not. The third and final function is the function that actually does all of the executions for the program.
| DIGIT | LEFT-HAND ENCODING | RIGHT-HAND ENCODING |
| 0 | 0001101 | 1110010 |
| 1 | 0011001 | 1100110 |
| 2 | 0010011 | 1101100 |
| 3 | 0111101 | 1000010 |
| 4 | 0100011 | 1011100 |
| 5 | 0110001 | 1001110 |
| 6 | 0101111 | 1010000 |
| 7 | 0111011 | 1000100 |
| 8 | 0110111 | 1001000 |
| 9 | 0001011 | 1110100 |
When the program is executed the user will first see the instructions for the program. The user will then be prompted to enter a value from the table below for the barcode. After they enter the value the user must then use bit 7 of either Dip Switch 1 or Dip Switch 2 to determine what type of crop to use, beans or corn. Once the user has selected what crop to use they will see the complete barcode. If the user is satisfied, they must terminate the program by setting bit 7 of both Dip Switch 1 and Dip Switch 2 to low.
The barcode function is designed to take a specific value in through the Dip switches, convert that number to a decimal number 0-9, calculates a check digit, and uses that check digit to determine which spray pattern is to be used by the sprayer. It accomplishes this through various modules in the program. The program will not calculate a check digit until bit 7 of either Dip Switch 1 or Dip Switch 2 is set to high and will terminate and send the last calculated value of the check digit to the program that is used to determine the spray pattern.