Pages: [1]   Go Down
Author Topic: Light sensing cammand  (Read 77 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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()
{


Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got frustrated and deleted the rest.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24298
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 89
Posts: 3452
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Jump to: