You are on page 1of 6

#include <msp430g2452.

h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
if (CALDC1_1MMZ == 0xFF || CALDC0_1MMZ == 0XFF)
{
while (1);
}
BCSCTL1 = CALBC1_1MMZ;
DCOCTL = CALDC0_1MMZ;
P1DIR = 0x40;
P1OUT = 0;
while(1)
{
P1OUT = 0x40;
_delay_cycles(50000);
P1OUT = 0;
_delay_cycles(50000);
}
}
________________________________________________
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0xff;
P1OUT &= ~0x01;
while(1)
{
P1OUT ^= 0x01;
__delay_cycles(1000000);
}
}
______________________________________________________
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0xf7;
P1OUT &= ~0xff;
P1REN |= 0x08;

P1OUT |= 0x08;
while(1)
{
if (P1IN & 0x08)
{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}
}
}
_________________________________________________________
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out
WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0xf7;//diz quem eh entrada e saida
P2DIR = 0xf8;//diz quem eh entrade e saida
P1OUT &= ~0xff;//todas as saidas do pino 1
P2OUT &= ~0xff;//todas as saidas do pino 2
P1REN |= 0x08;// resistores pin1.3
P1OUT |= 0x08;// pullup pin1.3
P2REN |= 0x01;// resistores pin2.0
P2OUT |= 0x01;// pullup pin2.0
P2REN |= 0x02;// resistores pin2.1
P2OUT |= 0x02;// pullup pin2.1
P2REN |= 0x04;// resistores pin2.2
P2OUT |= 0x04;// pullup pin2.2
while(1) //loop infinito
{
if (P1IN & 0x08)
{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}
if (P2IN & 0x01)
{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}

reset
no pino
no pino
recebem
recebem

1
2
0
0

if (P2IN & 0x02)


{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}
if (P2IN & 0x04)
{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}
}
}
__________________________________________________________________
3 botoes - 3 leds
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out
WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0xf7;//diz quem eh entrada e saida
P2DIR = 0xf8;//diz quem eh entrade e saida
P1OUT &= ~0xff;//todas as saidas do pino 1
P2OUT &= ~0xff;//todas as saidas do pino 2
P1REN |= 0x08;// resistores pin1.3
P1OUT |= 0x08;// pullup pin1.3
P2REN |= 0x01;// resistores pin2.0
P2OUT |= 0x01;// pullup pin2.0
P2REN |= 0x02;// resistores pin2.1
P2OUT |= 0x02;// pullup pin2.1
P2REN |= 0x04;// resistores pin2.2
P2OUT |= 0x04;// pullup pin2.2
while(1) //loop infinito
{
if (P1IN & 0x08)
{
P1OUT &= ~0x01;
}
else
{
P1OUT |= 0x01;
}

reset
no pino
no pino
recebem
recebem

1
2
0
0

if (P2IN & 0x01)


{
P2OUT &= ~0x08;
}
else
{
P2OUT |= 0x08;
}
if (P2IN & 0x02)
{
P2OUT &= ~0x10;
}
else
{
P2OUT |= 0x10;
}
if (P2IN & 0x04)
{
P2OUT &= ~0x20;
}
else
{
P2OUT |= 0x20;
}
}
}
________________________________________________________________________________
___
#include "io430.h"
int main()
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR =0xf7;
P1REN = 0x8;
P1OUT =0x8;
P2DIR = 0xff;//diz quem eh entrade e saida no pino 2
// P2REN |= 0x7;// resistores pin2.0
// P2OUT |= 0x7;// pullup pin2.0
// P2OUT &= ~0x38;
while (1){
if(P1IN == 0x0){
P2OUT = 0x38;
__delay_cycles(200000);
P2OUT = 0x0;
__delay_cycles(200000);
}
else
{
P2OUT = 0x38;
__delay_cycles(20000);
P2OUT = 0x0;

__delay_cycles(20000);
}
}
return 0;
}
________________________________________________________________________________
_________________
//3 botes 3 leds (jeito Marcelo)
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P2DIR = 0xf8;//diz quem eh entrade e saida no pino 2
P2OUT &= ~0xff;//todas as saidas do pino 2 recebem 0
P2REN |= 0x07;// resistores pin2.0 a 2.2
P2OUT |= 0x07;// pullup pin2.0 a 2.2

while(1) //loop infinito


{
// escrevendo "jeito" 1
if (!(P2IN & 0x01))
{
P2OUT |= 0x08; // P2OUT = P2OUT | 0x08
delay ();
P2OUT &= 0xf7;
delay();
}
else
{
P2OUT &= 0xf7;
}
// escrevendo "jeito" 2
if (!(P2IN & 0x02))
{
P2OUT |= 0x10;
delay();
P2OUT &= 0xef;
delay();
}
else
{
P2OUT &= 0xef;
}
if (!(P2IN & 0x04))
{

P2OUT |= 0x20;
delay();
P2OUT &= 0xdf;
delay();
}
else
{
P2OUT &= 0xdf;
}
}
}
int delay(void)
{
unsigned int dly = 3000000;
while(--dly);
{
}
return 0;
}

You might also like