As a newbie in Arduino projects and also in programming I want to ask for your help regarding to a current project that I’m working on. Situation is as follow:
I’m planing to build a laser counter system for tires where If they pass through a certain path they will be counted. My system contains Arduino Leonardo, 5 Laser pointers, 5 LDRs and a PLC. Lasers send a ligh beam directly to LDRs. At the moment when object passess through then I have no light emitted to LDR so I gather a resistance change for that fraction of time.So I want to set my configuration with LDRs such that I can activate an digital output corresponding to a certain input to PLC. But now my problem is that I can’t take all LDRs state at once and therefore I can’t trigger all digital outputs to arduino. At the moment I have modified a simple program from some pre-tested source codes available on internet but still I can only see the reaction for only on LDR in time I cannot make it to monitor 5 AI and activate 5 DO to send input signals to PLC.
this is my code that I modified and trying to monitor outputs (not complete).
// LDR pin connections
// name = analogpin;
int LDR = 0;
int LDR1 = 2;
int LDR2 = 3;
int LDR3 = 4;
int LDR4 = 5;
// initialize the serial port
// and declare inputs and outputs
int sensorValue = analogRead(LDR);
int sensorValue2 = analogRead(LDR1);
int sensorValue3 = analogRead(LDR2);
int sensorValue4 = analogRead(LDR3);
int sensorValue5 = analogRead(LDR4);
I would appreciate a lot if somebody could help me to develop this code or some suggestions regarding to coding part (what kind of libraries would be suitable for me at this case).