This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP-EXP432P401R
Good day,
Am new to this, but am working on MSP432, and am trying to toggle the Blue LED by pressing Switch 1 and 2 at the same time.
So I need help with this issue please
Thanks
Can you share what you already have and just what the problem is? We are hesitant with questions like this because we do not want to do your homework for you.
The thing is that you need to realize the function of toggling a GPIO and reading the input of a GPIO first.
am working on Write a program that will use switches S1 and S2 to control the color of the tri-color RGB LED on the TI MSP432 LaunchPad board.
The switches will change the color of the RGB LED;
S1 - RED
S2 - Green
S1 + S2 together - Blue
for S1; Red
/*
* This program to simulate a traffic light using switches,
*/
#include "msp.h"
int main(void) {
P1->SEL1 &= ~2; /* configure P1.1 as simple I/O */
P1->SEL0 &= ~2;
P1->DIR &= ~2; /* P1.1 set as input */
P1->REN |= 2; /* P1.1pull resistor enabled */
P1->OUT |= 2; /* Pull up/down is selected by P1->OUT */
P2->SEL1 &= ~1; /* configure P2.0 as simple I/O */
P2->SEL0 &= ~1;
P2->DIR |= 1; /* P2.0 set as input */
while (1) {
if (P1->IN &2) /* use switch 1 to control red LED */
P2->OUT &= ~1; /* turn off P2.0 red LED when SW is pressed */
else
P2->OUT |= 1; /* turn on P2.0 red LED when SW is pressed */
}
}
for S2: Green
/*
* This program to simulate a traffic light using switches,
*/
#include "msp.h"
int main(void) {
P1->SEL1 &= ~BIT4; /* configure P1.1 as simple I/O */
P1->SEL0 &= ~BIT4;
P1->DIR &= ~BIT4; /* P1.1 set as input */
P1->REN |= BIT4; /* P1.1pull resistor enabled */
P1->OUT |= BIT4; /* Pull up/down is selected by P1->OUT */
P2->SEL1 &= ~2; /* configure P2.0 as simple I/O */
P2->SEL0 &= ~2;
P2->DIR |= 2; /* P2.0 set as input */
while (1) {
if (P1->IN &BIT4) /* use switch 1 to control red LED */
P2->OUT &= ~2; /* turn off P2.0 red LED when SW is pressed */
else
P2->OUT |= 2; /* turn on P2.0 red LED when SW is pressed */
}
}
but I can`t figure out how to make S1 & S2 together to toggle the Blue LED
**Attention** This is a public forum