Jump to content
43oh

Variation on Flashing LED - Problem


Recommended Posts

This vcode below gice the following error

 

 

 

Blink1_EB.ino: In function 'void loop()':
Blink1_EB.ino:32:8: error: 'val' cannot appear in a constant-expression
Blink1_EB.ino:32:2: error: case label '<expression error>' not within a switch statement
Blink1_EB.ino:32:13: error: expected ':' before '{' token
Blink1_EB.ino:34:4: error: case label '1' not within a switch statement
Blink1_EB.ino:41:4: error: break statement not within loop or switch
Blink1_EB.ino:43:2: error: case label '0' not within a switch statement
Blink1_EB.ino:50:2: error: break statement not within loop or switch
 

 

 

 

/*
  This is not working yet  - EB 4.02.2014
 
  Blink
  The basic Energia example.
 
  Turns on an RED and Green LED when the switch is High and  off if SW2 is LOW, repeatedly.
  Pin 2 has an LED connected on MSP430 boards, has a name 'RED_LED' in the code.
  Pin 14 has an LED connected on MSP430 boards, has a name 'GREEN_LED' in the code.

  Hardware Required:
  * MSP-EXP430G2 LaunchPad
 
  This example code is in the public domain.
*/
 int val=0;
 
// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(RED_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT); 
  pinMode(P1_3, INPUT);
 
}

// the loop routine runs over and over again forever:
void loop() {
 
   val = digitalRead(P1_3);
 
 case (val) {
 
   case 1 :
  
  digitalWrite(RED_LED, HIGH);   // turn the LED on (HIGH is the voltage level)
 // digitalWrite(GREEN_LED, LOW);
  digitalWrite(GREEN_LED, HIGH);
  delay(100);               // wait for a second
  
   break;
 
 case 0 :
 
  digitalWrite(RED_LED, LOW);    // turn the LED off by making the voltage LOW
 // digitalWrite(GREEN_LED, HIGH);
  digitalWrite(GREEN_LED, LOW);
  delay(100);               // wait for a second
 
 break;
 }
}

 

 

I would appreciate advice on what is causing the problem 

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...