Led control using switch

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Led control using switch

Jump to solution
549 Views
Shrini
Contributor I

I have written the code for led control using switch. But it is not working. I have configured the pins PTC12 for switch as input direction and PTD15 for LED as output direction.  

Code: 

#define LED0_PORT PTC
#define LED0_PIN 12
// #define LED1_PORT PTC
// #define LED1_PIN 13
#define LED2_PORT PTD
#define LED2_PIN 15
// #define LED3_PORT PTD
// #define LED3_PIN 16
#include "sdk_project_config.h"
#include <stdio.h>
int main(void)
{
CLOCK_DRV_Init(&clockMan1_InitConfig0);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
int sw = PINS_DRV_ReadPins(LED0_PORT);
for(;;)
{
if(sw == 0){
PINS_DRV_WritePin(LED2_PORT, LED2_PIN, 1);
}
else{
PINS_DRV_WritePin(LED2_PORT, LED2_PIN, 0);
}
}
}

0 Kudos
Reply
1 Solution
541 Views
Senlent
NXP TechSupport
NXP TechSupport
0 Kudos
Reply
2 Replies
542 Views
Senlent
NXP TechSupport
NXP TechSupport
0 Kudos
Reply
532 Views
Shrini
Contributor I
Hi@Senlent, Thank you.
0 Kudos
Reply