Go Down

Topic: Light sensing cammand (Read 264 times) previous topic - next topic

youhi10

Hello,
I am trying to wright a program to turn on and off some relays in a specific order.
Here is what it should do.

If photo eye 1,2 and 3 are lets say <400 for 1 min together,
then turn pins 13,12,11,10,9,8 High for 30 sec
then turn pins 13,12,11,10 low and delay for 45 sec and then turn 9,8 low
and wait for photo eye 1,2,3 to be <400 again

seems simple but I cant get it to check the state of all 3 and cant get it to change the state of the relays together.

This is what I have so far. (its probably way off and not completed)
Any help would be great.


Quote


int photoeye1 = A0;
int Photoeye2 = A1;
int photoeye3 = A2;

int replay1 = 13;
int replay2 = 12;
int replay3 = 11;
int replay4 = 10;
int replay5 = 9;
int replay6 = 8;


void setup()
{

  pinMode(replay1, OUTPUT);
  pinMode(replay2, OUTPUT);
  pinMode(replay3, OUTPUT);
  pinMode(replay4, OUTPUT);
  pinMode(replay5, OUTPUT);
  pinMode(replay6, OUTPUT);
  
  
  
  Serial.begin(9600);
}

void loop()
{



PaulS

Quote
seems simple

It should be.

Quote
but I cant get it to check the state of all 3

You aren't checking any, let alone all three.

Code is posted using code tags (the # icon), not quote tags.

Quote
its probably way off and not completed

I don't know about way off, but definitely not completed.

youhi10

i got frustrated and deleted the rest.

AWOL

Quote
i got frustrated
OK, so close your eyes, take a deep breath, tense your muscles and relax.
Then post the code.
In code tags.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UKHeliBob

Write something simple first to improve your level of confidence.
Read one sensor value into a variable and output the value using Serial.println().
Now add a second sensor and variable and output it.  There are neater ways of doing this using an array, but for now just repeat the code.
Now add a third sensor and variable and output it, again repeating the code.

So, you have now got 3 readings in 3 variables.
Check if they are all below 400 and, if so, print a message to say so.

Now you can move on,  such as testing the inputs for a minute to ensure that they remain low, but hopefully you will have more confidence than you did.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up