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);
}
}
}
Solved! Go to Solution.