Go Down

Topic: Need the void loop to run just once... (Read 7016 times) previous topic - next topic


Where in the sketch should i place

set case1Run = false
set case2Run = false

and how?


// want the loop to end here and go back to listening for commands from the phone

It does.

Humour me and put this in as the first line in loop:
Code: [Select]
serialA =0;


in this? if (Serial.available() > 0) {serialA = Serial.read();Serial.println(serialA);}



Or even better above
Code: [Select]
if (Serial.available() > 0)
  serialA = Serial.read();
to make it easier to read
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.


like this?

void loop() {
if (Serial.available() > 0)
  serialA = 0();
  switch (serialA) {
    case 1:
      digitalWrite(unlock, HIGH);
      delay(1000);               // wait for a second
      digitalWrite(unlock, LOW);
      digitalWrite(innebelysning, HIGH);
      digitalWrite(innebelysning, LOW);


Look at the code you had, and the code in UKHeliBob's last reply. Then get a clue-by-four and give yourself a good whack. As a newbie, you should get into the habit of putting each { on a line BY ITSELF and of putting each } on a line BY ITSELF.

You should also get into the habit of using Tools + Auto Format to fix your indenting.

Finally, while you have the clue-by-four handy. go read the sticky (again, if needed) at the top of the forum, and learn to post your code properly.
The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131