int RBG1[] {12, 11, 10};
const int BUZZ = 3;
const int sensor = 4;
const int sit = 2;
int sensorRead = 0;
void setup() {
pinMode(RBG1[12, 11 ,10], OUTPUT);
pinMode(BUZZ, OUTPUT);
pinMode(sensor, INPUT);
pinMode(sit, INPUT);
pinMode(8, OUTPUT);
}
void loop() {
int READ1 = digitalRead(sensor); delay(25); int READ2 = digitalRead(sensor);
int PUSH1 = digitalRead(sit); delay(25); int PUSH2 = digitalRead(sit);
digitalWrite(8, HIGH);
while ((READ1 == READ2) && (READ1 == HIGH)) {
bob();
scroll();
Boom();
}
while ((READ1 == READ2) && (READ1 == LOW)) {
Scilence
}
or
while ((PUSH1 == PUSH2) && (PUSH1 == HIGH)) {
scroll();
Boom();
}
while ((PUSH1 == PUSH2) && (PUSH1 == LOW)) {
Scilence();
}
}
int i = 0;
int scroll();
for (int i = 0; i< 3; i++) {
digitalWrite(RBG1[i], HIGH);
delay(500);
}
for (int o = 0; 0< 3; o++) {
digitalWrite(RBG[o], LOW);
delay(500);
}
}
int Boom() {
for (int y = 0; y< 8; y++){
digitalWrite(BUZZ, HIGH);//Sharon got this!
delay(random(200));
digitalWrite(BUZZ, LOW);
delay(random(200));
}
}
int bob() {
if (digitalRead(sit) == HIGH) {
int e = 0;
e +60000;
delay(e);
scroll();
Boom();
}
}
void Scilence() {
digitalWrite(BUZZ, LOW);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
}
tilt switch connects to pin 4
push button connects to pin 2
Buzzer connects to pin 3
pin 8 is just used to turn on an LED
Thanks for using code tags !
Can you attach a schematic, and possibly explain what’s supposed to happen.
If you reformat the code properly, you may see a few odd things that might help you solve your problem.
Not only does this not do anything (as the subject line suggests), but I doubt it will compile. 'or' is a boolean operation keyword. It is not a flow control keyword like 'if' or 'while'.
- this doesn't compile
- I don't know what it is supposed to do much less what it does
- What kind of sensor is sensor?
- What is sit?
- How are sensor and sit wired?
- What do you think this does?
e +60000;
- If you ever enter any of your while loops you will never get out
so, shooting for annoying, so, well done.
not sure if you understood the subject line, but to address your points, it would violate the last bit of the specification.
That won’t do what you hope it will.
Your while loops never exit because you never change or check the entry conditions inside the loops.
And what is that “or” doing. Again not what you think.
Zero is always less than three
We covered this in another topic.
Completely and utterly inappropriate for this purpose.
And indeed, for most such projects.
OP: Here are the two * references you need to study.
Are we being trolled?
sit is a pushbutton
sensor is a tilt switch
Four questions and two answers is not a good ratio.
what is an entry condition?
An entry condition is the bit in the brackets of the while instruction. If this evaluates to be true then the code in the braces following the while is executed. When this code is finished the entry conditions are evaluated again. The code in the braces must do something that could change those variables if the code is ever going to escape from this loop.
Your code does nothing in this direction so once entered any of your while loops they can never end and your code is stuck there forever.
thank you
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.