Go Down

Topic: Coding issue: Using a TCS 230 colour sensor readings to control solenoids (Read 360 times) previous topic - next topic


Hi all,

I'm very new to Arduino programming so please excuse my ignorance, I'm have problems with my coding  and I'd appreciate if someone would point me in the right directions with this issue. Basically I am reading the colour of an object and with the result I want to activate a specific solenoid. For example if the colour sensor reads RED I need the code to delay solenoid1 for 2 seconds, for BLUE I need a delay of 4 seconds from solenoid2, and for GREEN I need a delay of 6 seconds from solenoid3.

The code I've written so far is trying to control 2 solenoids for starters, so when the sensor reads RED it will immediately put the solenoid at HIGH, delay 2 second, and then input LOW. I've changed the code to put the solenoid at LOW and delay 2 seconds first once the sensor reads RED but this causes all the solenoids to come on and be controlled incorrectly. And I've tried putting a 2 second delay immediately after the sensor reads.
I'm abit concerned whether its the sensors readings that might be the problem and that I need another function  as a timer to track my readings are something like that.
I have attached my code .
I'd really be grateful if someone with experience in this area could take a quick look, thank you.

Go Up