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

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

Related posts

MSP430FR4133 LaunchPad and SHT31 sensor example using Energia

MSP430FR4133 LaunchPad and VEML6070 sensor example using Energia

MSP430FR4133 LaunchPad and ADS1115 ADC example using Energia