SOFTWARE DEVELOPMENT
even our classes are classy. take a peek at our github.
Our code runs on our Arduino and integrates all the other systems. It checks for input from the buttons, activates the sensor, interprets the results, and activates the valve/motor system to pump ink. It also outputs the sensor reading data to the serial port so our MATLAB program can display the color that is being read.
Color Sensor Calibration
To calibrate the sensor, we take readings of the black and white portions of our color calibration sheet, a printout of Figure 1. We then store those values on the EEPROM using our writeEE function. EEPROM memory persists after the Arduino is unplugged, so we can calibrate once and reuse those values as long as we want.
Color Sensor Readings
We take readings by setting the color sensor on the object of interest, and then pressing the programmed “take a reading” button. We achieve a fast response by continuously looping and checking for the button state, with time debouncing in order to avoid delay issues.
After taking a reading, we apply the calibrations taken earlier to the reading with the following formula:
(BlackReading - CurrentReading)/(BlackReading - WhiteReading)
We then output the result to MATLAB via serial and display the scanned color for the user’s verification.
Valve and Motor Actuation
The list of solenoids is stored in a 4-value int array in the order Cyan Magenta Yellow Water, where the water is used to flush out the system. Once we decide which color is most prevalent in the object being scanned, we can pick the corresponding solenoid out of that array. Next, we run the pump_ink function with the solenoid to pump as an input. That function opens the correct valve, runs the pump using PWM, and then closes the valve.