Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Simple Sequential : Led + Breadboard

$
0
0

Hello, Guys!

 

 So, as some already know I 'm  a noob with embedded system and I really I'm  liking of the series MSP430 by TI.

 

I am trying make this code work, but so far  I did not succeed, What  I want is a simple led sequential on the breadboard, the breadboard will be 9 Leds, being 6 on Port 1, e just 3 in the Port 2 for now.

That code work but not syncronized,  I'd want which when end the first "array" of the leds, starts the seconds "arrays" of the leds (port 2, 3 leds), I would like to use someone like struct in C but I don't have know enough yet, the code:

 

 #include <msp430G2553.h>


  void Delay(void);
  void sequencial(void);
  char led1[7] = {BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6};
  char led2[3] = {BIT0, BIT1, BIT2};
  volatile int i = 0;
  volatile int f = 0;
 
  int main(void) {
    
  WDTCTL = WDTPW | WDTHOLD;
  P1DIR = 0xff;
  P2DIR = 0xff;
 
 
        for (;;) {
          sequencial();
              }
  }
    
    void Delay(void) {
        unsigned int dly = 30000;
        while(--dly); {
            
        }
        }
      void sequencial(void){
        i++;
          Delay();
        P1OUT = led1[i];
       if(i==7) i=0;
           
         P1OUT |= 0x00;
            f++;
              Delay();
             P2OUT = led2[f];
              if(f==3) f=0;
              
             P2OUT |= 0x00;
      }
   

 

The outpouts are working separately not synchronized, How do I make this? Thanks!


Viewing all articles
Browse latest Browse all 2077

Trending Articles