Home TI launchpad MSP-EXP430G2 RGB led example

MSP-EXP430G2 RGB led example

In this example we connect an RGB led to our MSP-EXP430G2 launchpad and flash the red, green and blue colours

Schematic

I actually had an RGB breakout attached the the MSP-EXP430G2 launchpad but this is the same circuit

launchpad and rgb led

launchpad and rgb led

Code

Again this is written in Energia

[codesyntax lang=”cpp”]

void setup() 
{                
  // initialize the digital pin as an output.
  pinMode(P2_0, OUTPUT);
  pinMode(P2_1, OUTPUT); 
  pinMode(P2_2, OUTPUT); 
}

// the loop routine runs over and over again forever:
void loop() 
{
  //RED
  digitalWrite(P2_0, LOW);
  digitalWrite(P2_1, HIGH);
  digitalWrite(P2_2, HIGH);
  delay(1000);               // wait for a second
  //GREEN
  digitalWrite(P2_0, HIGH);
  digitalWrite(P2_1, LOW);
  digitalWrite(P2_2, HIGH);
  delay(1000);               // wait for a second
  //BLUE
  digitalWrite(P2_0, HIGH);
  digitalWrite(P2_1, HIGH);
  digitalWrite(P2_2, LOW);
  delay(1000);  
}

[/codesyntax]

Links

You may also like