On the spectacoal side there were various inputs:
1 potentiometer
1 button
2 switches
dump
anchor
Joystick X
JOystick Y
XBee Data Out to PIC32 Data In
And a few outputs:
Connection LED
Recharge LED
Servo Motor (gas)
PIC32 Data out to XBee Data In
This analog input allowed us to quickly and easily choose which boat to pair with. With the ability to turn 300 degrees and there being 6 boats, boat 1 was between 0-50deg, boat 2 between 50-100, Boat 3 between 100-150, boat 4 between 150-200, boat 5 between 200-250, and boat 6 between 250-300. An analog compatible input pin was used (AN1).
This debounced pull-up switch circuit served as a digital input to trigger reading the potentiometer value and determine which boat to pair with. The switch is idle high and pulls low when pressed. Pin 12 was used as the input.
The 10kΩ resistor keeps the input pin at a reliable HIGH level when the switch is not pressed, while minimizing current draw from the 3.3 V supply.
The 1kΩ resistor protects the microcontroller during fast transitions or if the pin is accidentally configured as an output.
The 0.1uF capacitor filters out switch bounce, forming an RC low-pass filter with an approximate time constant of 1 ms. This means that brief, noisy voltage changes caused by the switch will be smoothed out, helping the microcontroller read clean high or low signals.
The recharging switch was a limit switch. Charging mode is entered if the limit switch is pressed through the recharging action. While the limit switch is pressed down, refueling messages will be continually sent to the BARNACOAL.
The dumping and anchoring switches were simple SPDT switches. The initial state of the switch is read at the beginning of the code and a change triggers the dumping/anchoring mechanism to deploy and then retract.
The 10kΩ resistor keeps the input pin at a reliable HIGH level when the switch is not pressed, while minimizing current draw from the 3.3 V supply.
The joystick was powered by 3.3V to match the 3.3V logic of the PIC32. The VRx and VRy outputs were treated as analog inputs and read as 10-bit values (0–1023). These values were then converted to 8-bit (0–255), with 127 representing the centered (neutral) position. This conversion was necessary because the values were sent over XBee to the BARNACOAL, which required 8-bit data.
The Xbee was extremely easy to set up electrically. There were only four connections to the XBee: 3.3V, ground, Data In, and Data Out.
This LED current limiting circuit uses a 240Ω resistor. This circuit limits the current through the LED to a safe level when driven by the PIC32 output pin.
With the PIC32 output voltage at 3.3V and a forward voltage of about 2.0V for the red LEDS and a desired current of about 5mA, this gave us a (3.3V-2.0V)/5mA ~ 240Ω.
The servo motor was the only component that required a +5 V supply. It was connected with three wires: +5 V power, ground, and a PWM control signal from the PIC32. Pin 14 (RB5) was selected for the PWM signal because it is 5 V tolerant, ensuring safe operation. The servo was then controlled using the provided PWM library.
A 5V power bank was used to power the power distribution board (PDB) from the ME 218B projects. This PDB then distributed the 5V and 3.3V connections and powered all of the spectacoal outputs and inputs. Only the servo motor required 5V and the rest used 3.3V.
Below are all the inputs that were used on the PIC32. In total, there were 12 inputs/outputs used for gameplay. Two additional pins were used for TeraTerm and an additional three for programming and resetting. Even then, there were 5 pins left for other uses.