Mai Xuân Duy
Trứng gà
code viết thế này có đúng không
#include <msp430.h>
/*
* main.c
*/
unsigned int i
unsigned char code Led[]=(0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08)
void nhay(void)
{
P1OUT = 0x81;
__delay_cycles(1000);
P1OUT = 0x42;
__delay_cycles(1000);
P1OUT = 0x24;
__delay_cycles(1000);
P1OUT = 0x18;
__delay_cycles(1000);
}
int main(void) {
WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
P1SEL = 0 ;
P1SEL2 = 0 ;
P2SEL = 0 ;
P2SEL = 0 ;
P1DIR = 0xFF;
nhay()
i=1;
while(1)
{
if (P2IN & BIT1)==0
P1OUT=Led i++;
if (i>8)
i=1
}
return 0;
}
#include <msp430.h>
/*
* main.c
*/
unsigned int i
unsigned char code Led[]=(0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08)
void nhay(void)
{
P1OUT = 0x81;
__delay_cycles(1000);
P1OUT = 0x42;
__delay_cycles(1000);
P1OUT = 0x24;
__delay_cycles(1000);
P1OUT = 0x18;
__delay_cycles(1000);
}
int main(void) {
WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
P1SEL = 0 ;
P1SEL2 = 0 ;
P2SEL = 0 ;
P2SEL = 0 ;
P1DIR = 0xFF;
nhay()
i=1;
while(1)
{
if (P2IN & BIT1)==0
P1OUT=Led i++;
if (i>8)
i=1
}
return 0;
}