2291 views|0 replies

1662

Posts

0

Resources
The OP
 

MSP430 F5529 button control LED light on and off program code [Copy link]

#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; //Turn off the watchdog
P8DIR |= BIT1; //Set the P8.1 output light
P1DIR &=~ BIT2; //Set the p1.2 input button
P1REN = BIT2; //Set the pull-up resistor to make it more stable (really)
P8OUT &=~ BIT1; //Off by default, P1.2 cannot set the initial value
for(;;)
{
if(P1IN&BIT2) //If P1 is positive, it will light up, otherwise it will go out
{
P8OUT |= BIT1;
}
else
{
P8OUT &=~ BIT1;
}
}
}

This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list