Get ready to kick yourself MrJKF, ... maybe.
Leds can detect as well as emit light. And one result of that is that colored bulb leds (red, green, blue, etc, can be used to detect colored light.
It works well enough that one man invented a liquid analyzer that uses them to measure light absorbed when passing through the liquid. Different liquids made different profiles and the device has many such stored.
Also be prepared for fun with colors. What looks yellow to humans may be red and green mixed or it may be yellow. Regardless of color detector, you may need to establish profiles for your skittles!
Learn the do many things at once lesson. It will make life easier. Properly done, you will need less code and debugging will be easier.
Many things at once --- Input is a Thing. Every input should have its own piece of code inside of loop(). The input sections should update variables regularly and other code reads them. The input code doesn't run because some other code needs data, it just runs all the time (every iteration of loop()) or at regular intervals dependably.
Contact button/switch code, for example, needs to watch not just for pin state change but the noise generated for 2 or more ms that can appear to be dozens of button presses. And doing that right takes up almost no cpu time. The code watches pin state for changes and it turns that into button state for process and/or output code to read, abstracting data into meaning which is easier for the rest of the sketch to use.
It should run a step every time that loop() goes around which should take less than 1 millisecond. 1 ms = 16000 cpu cycles on a 16MHz Arduino can do a lot when nothing waits which is how you make many things run "at the same time", they all get a turn to take just 1 step then loop() for the next, etc.
Processing is a Thing. That's the Think Code. State machines usually live there. Input changes usually drive this code and it often drives the Output Code.
Output is a Thing. From serial printing to motor running, it's Output and you can make it smart so it doesn't burn up a relay or overflow serial monitor with text or handle different hardware and/or buses.
Many Things at Once and they all run as separate pieces. An Output Thing can be replaced with a different but similar Output Thing without disturbing the rest of the code either at all or more than minimally. Same with Input Things. Your Code Things can be more easily reused if you don't give in to the temptation to merge/specialize Input/Process/Output.
Hope any of that helps. Hope you have a few days to spend messing with other people's code examples.
It's a great fast-track to cutting your own coding teeth.