Shop OBEX P1 Docs P2 Docs Learn Events
ColorPAL #28380 — Parallax Forums

ColorPAL #28380

kazuya86kazuya86 Posts: 5
edited 2014-11-11 08:00 in Accessories
I watch a display of colorPAL (http://m.youtube.com/watch?v=uYXXQpb29Qc).

I have Parallax of board of education(Rev C), ColorPAL#28380 and 4-pin RGB LED, I have connect ColorPAL and RGB LED on the board. ColorPAL was connected to PIN 15, and RGB LED was connected to pin 6, Anode is on PIN 6, 3-pin(cathode) on breedboard.

Anyone know how to write or add a code to let the RGB show the measure color when the ColorPAL detect the color it sees.

I use the code
' -----[ Program Description ]---------------------------------------------
' This program drives the Parallax ColorPAL color sensor and provides
' serial RGB data to the PC-hosted TCS230_ColorPAL_match.exe color
' matching program.

' -----[ I/O Definitions ]-------------------------------------------------
sio     PIN 15           ' Serial I/O com pin for ColorPAL.

' -----[ Constants ]-------------------------------------------------------
' Baudrate definitions. Serial I/O must be open-drain. The ColorPAL includes
' a pullup internally.
#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    baud    CON  119 + 32768
  #CASE BS2SX, BS2P
    baud    CON  327 + 32768
  #CASE BS2PX
    baud    CON  536 + 32768
#ENDSELECT
' -----[ Variables ]-------------------------------------------------------
red     VAR Word          ' Received RGB values from ColorPAL.
grn     VAR Word
blu     VAR Word
' -----[ Initialization ]--------------------------------------------------
GOSUB Reset               ' Reset the ColorPAL and enter direct command mode.
' -----[ Program Code ]----------------------------------------------------
SEROUT sio, baud, ["= (00 $ m) !"]  'Program ColorPAL to send $ then color data.
DO
  SERIN sio, baud, [WAIT("$"), HEX3 red, HEX3 grn, HEX3 blu] ' Receive RGB data back.
  DEBUG "R", DEC4 red, " G", DEC4 grn, " B", DEC4 blu, CR ' Output it.
LOOP
' -----[ Subroutines ]-----------------------------------------------------
' Reset: Sends a long break to reset ColorPAL and enter direct command mode.
Reset:
  LOW sio                   'Pull sio low to eliminate any residual charge.
  INPUT sio                 'Return pin to input.
  DO UNTIL sio : LOOP       'Wait for pin to be pulled high by ColorPAL.
  LOW sio                   'Pull pin low.
  PAUSE 1000                  'Keep low for 80ms to enter Direct mode.
  INPUT sio                 'Return pin to input.
  PAUSE 1000                  'Pause another 10ms
  RETURN
Sign In or Register to comment.