Kod: Zaznacz cały
#include <msp430xG46x.h>
void main (void){
unsigned char blink_status=1;
volatile unsigned int i;
WDTCTL = WDTPW | WDTHOLD; //Stop Watchdog Timer
P2DIR |= 0x04; //Configure P2.2 as Output (LED1)
P1DIR &= ~0x01; //Configure P1.0 as Input (S1)
while(1){ //Infinite loop
if (blink_status == 1) {
P2OUT ^= 0x04; //Toggle Port P2.2
i=15000; //Delay
do (i--);
while (i !=0);
}
if (!(P1IN & 0x01)) { //Detect button pressed
i=1500; //Delay, button debounce
do (i--);
while (i !=0);
while (!(P1IN & 0x01)); //Wait for the release of the button
i=1500; //Delay, button debounce
do (i--);
while (i !=0);
if (blink_status ==1){ //If LED is blinking, stop it
P2OUT&= ~ 0x04; // Turn Led off
blink_status=0;
}else
blink_status=1;
}
}
}Powyższy program mruga dioda co nacisnieciu przycisku sw1 przestaje mrugac po ponownym naciśnięciu ponownie mruga
Musze dopisac do tego programu takie coś , że jesli nacisne sw2 jest opoznienie czasowe mrugania 0,1s jesli ponwonie nacisne 0,5s
Jesli ktoś wie jak to zrobić prosze sie zglosić do mnie nie mam na celu żeby ktoś zrobił to dla tylko chcem uzyskac kilka rad jak to zrobić