Sunteți pe pagina 1din 2

Adriel Cavalcante Silva

EEI 130302
Prof. Ms. Iran
Disciplina de Microcontroladores

LIGA LED
#include "msp430.h"
int tempo = 0;
int main( void )
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset
P1DIR=BIT6; //Define o Port 1 bit 0 como saida
while(1)
{
for(tempo=0;tempo<20000;tempo++); //um for apenas para gastar o tempo
P1OUT=1; //aciona o Led
for(tempo=0;tempo<20000;tempo++); //tempo em que led fica acionado
P1OUT=0; //apaga o Led
}
}

CONTROLE DE DOIS LEDS


#include "msp430.h"
int tempo = 0;
int main( void )
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset
P1DIR=0x41; // Registrador para acender led 1
P1OUT=0x40; // Registrador para apagar led 2
while(1)
{
for(tempo=0;tempo<3;tempo++); //um for apenas para gastar o tempo
P1DIR=0x41; //aciona o Led
for(tempo=0;tempo<3;tempo++); //tempo em que led fica acionado
P1OUT=0x40; //apaga o Led
}
}
Adriel Cavalcante Silva
EEI 130302
Prof. Ms. Iran
Disciplina de Microcontroladores

SOS
#include "msp430.h"
int tempo = 0;

int main (void) {


WDTCTL = WDTPW + WDTHOLD;
P1DIR=0x01;
// 3 pontos (letra S)
for (tempo=0; tempo<20000; tempo++) {
P1OUT=1;
__delay_cycles(15000);
P1OUT=0;
__delay_cycles(10000);
}
__delay_cycles(20000);
// 3 traços (letra O)
for (tempo=0; tempo<3; tempo++) {
P1OUT=1;
__delay_cycles(15000);
P1OUT=0;
__delay_cycles(10000);
}
__delay_cycles(20000);
// 3 pontos (letra S)
for (tempo=0; tempo<3; tempo++) {
P1OUT=1;
__delay_cycles(15000);
P1OUT=0;
__delay_cycles(10000);
}
}

S-ar putea să vă placă și