The code behind the project is fairly simple.
To establish communication between the Arduino and the color sensor, we sent register address and the byte value we want to write the magnetometer and loads the destination register with the value that was sent. To receive raw values, we send a register value address to a function and it will return the byte values for the magnetometer register’s content. Once the raw RGB values are read from their respective registers, they were converted into integers.
To determine the color being sensed, we compared the RGB values and found the color with the highest color value, then made that color the sensed color.
Once the color has been sensed, the Arduino sends out a character to the A3BU through UART.
The A3BU then takes the received character and adjusts the motor speed accordingly using Pulse Width Modulation.