Multiple TCS230 sensors and RTC DS1307

  1. Hello all, one short question, it is possible to connect 4 TCS230 color sensors to the same pins? I mean the input pins (S0 S1 S2 and S3). I want to detect just the green color. Of course de output pin should be different.

  2. The millis function is not pretty accurate. I try to detect the green color, but I want to continous check for 2 second if the condition is fulfill . Can you please help me with the code for RTC?

Thank you in advance!

I've not used this part but according to the information I've read you can control all 4 in parallel (S inputs).

There are many tutorials on the DS1307... here is one DS1307

1 Like
  1. Yes you can. One Arduino output can fan out to the 4 input pins. In theory you can also use one input pin. As I recall as the outputs of the TCS230 are high impedance unless the chip is enabled (/OE). These two articles have been a popular on my blog site and The second has some additional info that you may want to know as well.
  2. If you are checking for 2 seconds the millis() function will probably be accurate enough - it will be at most a few millisecond inaccurate. RTC minimum resolution is usually 1 second, so you can end up with an average error of 0.5 seconds.
1 Like

Thank you guys!

Unfortunately the led won't keep the 2000 ms :-), sometimes the led turn off faster than 2 sec and sometimes keep still on, more than 3 second.
Where is the problem? for the moment just one color sensor is used and 2 laser receiver

#define sensor_laser_1 2 // pin 2 for laser sensor
#define sensor_laser_2 3 // pin 3 for laser sensor
#define S0 4 // frecventa scalare
#define S1 5 //frecventa scalare
#define S2 6 // HIGH pentru verde
#define S3 7 // HIGH pentru verde
#define sensorOut1 8 // out color module
#define sensorOut2 9 // citire culoare pe pinul 9
#define sensorOut3 10 // citire culoare pe pinul 10
#define act_pneu 11 // LED

int led_state = LOW;            // definire piston stare initiala
unsigned long starTime = 0;        // start arduino
unsigned long previousMillis = 0;  // ultimul timp salvat
const long interval = 2000;        // setare interval asteptare dupa 2 sec

void setup() 
  pinMode(sensor_laser_1, INPUT);//define detect input pin
  pinMode(sensor_laser_2, INPUT);//define detect input pin
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut1, INPUT);
  pinMode(sensorOut2, INPUT);
  pinMode(sensorOut3, INPUT);
  pinMode(act_pneu, OUTPUT);//define ACTION output pin
void loop() 
  int laser1 = digitalRead(sensor_laser_1); // citire senzor laser intrare
  int laser2 = digitalRead(sensor_laser_2); // citiare senzor laser iesire
  int culoare1 = 0;
  int culoare2 = 0;
  int culoare3 = 0;
  unsigned long currentMillis = millis();

// Senzor culoare
   culoare1 = pulseIn(sensorOut1, LOW); 
   culoare2 = pulseIn(sensorOut2, LOW);
   culoare3 = pulseIn(sensorOut3, LOW);
  if( laser1 == LOW || laser2 == LOW || culoare1 < 175)
    led_state= HIGH; // cilindru pe ON
     if  ( currentMillis - previousMillis >interval)
           previousMillis = currentMillis;
           led_state = LOW;

This is the reason why I want to use a RTC module

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.