'{$STAMP BS2} '{$PBASIC 2.5} ' StampPlot Example for the TAOS TCS230 Color Sensor ' Adapted by Martin Hebel - SelmaWare Solutions ' www.stampPlot.com ' The StampPlot macro used to run this code in not ' very important. All the code to plot the data is sent ' from the BASIC Stamp. The StampPlot macro configuration ' simply has some other beneficial features. 'Define port pins EN CON 1 A0 CON 2 S0 CON 3 S1 CON 4 S2 CON 5 S3 CON 6 nLED CON 7 OUT CON 8 'Define count periods for each color. 'Adjust these for a reading just under 255 ' for a white sheet of paper. 'Define variables for color results. RED VAR Word GREEN VAR Word BLUE VAR Word 'Program starts here. PAUSE 1000 ' Wait for StampPlot connection to stabilize DEBUG CR,"!AWTH 3",CR DEBUG "!TMAX 80",CR DO: FOR red = 0 TO 255 STEP 80 ' Step through colors FOR green = 0 TO 255 STEP 80 FOR blue = 0 TO 255 STEP 80 GOSUB PlotIt ' Plot Data PAUSE 1000 NEXT NEXT NEXT LOOP 'Color: Read all three color components. PlotIt: DEBUG "!ACHN 0,", DEC Red,",(Red)",CR ' plot amount of red on channel 0 in red DEBUG "!ACHN 1,", DEC Green,",(Green)",CR ' plot amount of green on channel 0 in green DEBUG "!ACHN 2,", DEC Blue,",(Blue)",CR ' plot amount of blue on channel 0 in blue ' Draw a filled rectange at top of plot based on time in composite color of hex RGB DEBUG "!FREC L9,90a,T9,100a,", HEX2 BlUE, HEX2 GREEN, HEX2 RED, CR ' Update bar and color value boxes DEBUG "!O UPDATE",CR ' If Log Data check is checked, write hex and decimal colors to file DEBUG "!IFTH (ChkLog),=,1,!LOGD ",HEX2 BlUE, HEX2 GREEN, HEX2 RED, ",", DEC Red, ",", DEC Green, ",", DEC Blue,CR RETURN