Led control using switch

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Led control using switch

ソリューションへジャンプ
434件の閲覧回数
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 件の賞賛
1 解決策
426件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport
0 件の賞賛
2 返答(返信)
427件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport
0 件の賞賛
417件の閲覧回数
Shrini
Contributor I
Hi@Senlent, Thank you.
0 件の賞賛