The UART is used to send and receive data to and from the robot via a Bluetooth module. Below is the UART setup subroutine. Calling the subroutine sets the UART for 9600 baud. The subroutine also enables the receive interrupt and also enables the UART.
Next is the transmit subroutine. Pretty straight forward, call the sub with the data and the subroutine sends the data and waits for it to send.
Last is the receive subroutine. The receive subroutine is part of an interrupt handler. The subroutine has ten registers to receive data. Each time the UART receives data, the data in the registers are shifted up by one register. As data is being received, the receive subroutine mirrors back the data to confirm that the data has been received. Another routine checks the registers for the magic word “send”. Once the word “send” has been received, the PIC will transmit the potentiometer and switch data to the robot.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.