whac a mole coding

hey all im getting //case label ‘0’ not withing switch statement//
can anyone please help?

*Whac An LED
*/
void setup(){
Serial.begin(115200);
pinMode(11, OUTPUT);
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
pinMode(3, OUTPUT);
pinMode(12, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
}

void loop (){
double i= 1;
int S0, S1, S2, S3,sum;
while(1< pow(10,300)){
int k;
k = random(0,4);
delay(500);

randomSeed( analogRead(0) + analogRead(1) + analogRead(2) + analogRead(3) + analogRead(4) + analogRead(5) );
S0= !analogRead(12);
S1= !analogRead(8);
S2= !analogRead(7);
S3= !analogRead(4);
switch(k);{
case 0:
digitalWrite(11, HIGH);
while( S0 == HIGH){
S0= !digitalRead(12);
digitalWrite(11,HIGH);}
if(S0 == LOW){
digitalWrite(11, LOW);}
break;
case 1:
digitalWrite(9, HIGH);
while(S1 == HIGH){
S1= !digitalRead(8);
digitalWrite(9, HIGH);}
if(S1 == LOW){
digitalWrite(9, LOW);}
break;
case 2:
digitalWrite(6, HIGH);
while(S2 == HIGH){
S2= !digitalRead(7);
digitalWrite(6, HIGH);}
if(S2 == LOW){
digitalWrite(6, LOW);}
break;
case 3:
digitalWrite(3, HIGH);
while(S3 == HIGH){
S3= !digitalRead(4);
digitalWrite(3, HIGH);}
if(S3 == LOW){
digitalWrite(3, LOW);}
break;
}
1++
}
}

It is in the code I think, probably after the letter i, not sure. All the great information supplied like a description of what it does, a schematic (not a frizzy thing). and what it is to do.

If You post the code according to advice given in "How to use this Forum" etc. , using code tags, up to the left in this window maybe the reason for the error could be easily found. All helpers do not use Pc equipped with IDE.

    switch(k);{

is that semikolon correct?

The arduino is connected with the edushield and it lights up 4 pins and the program is souppose to allow yoi to play whac a mole with the four push buttons

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can as you now see, be quite garbled and is always more difficult to read due to the font.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

Some formatting clean-up may also help. The IDE has the "autoformat" function that does a great job in making code more readable. Press CTRL-T in the IDE.

As you can see the result of posting code without code tags is an unreadable mess, full of smilies and other issues.

That said, I think @Railroader found the problem already. Well, maybe not THE problem, but quite definitely a problem.

This line:

         1++

also doesn't make sense, and again surprises me of what nonsense the compiler happily accepts (assuming the code actually compiles for you).

//Its fixes everyone thanks. The error was switch(k);{
//It has to be
switch (k){

Small stuff tilts large objects….

Hi,
Please read the post at the start of any forum , entitled “How to use this Forum”.
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

PLEASE post your complete code.

Thanks… Tom… :slight_smile:

TomGeorge:
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

PLEASE post your complete code.

I explained all that.

I think he's just happy that he figured it out and doesn't care whether it is legible or not. :roll_eyes:

Paul__B:
I explained all that.

I think he's just happy that he figured it out and doesn't care whether it is legible or not. :roll_eyes:

Yes, but if you look at other threads, lots of noobs still need this even after being asked politely. :slight_smile: