Assignment 1 LED | EMBEDDED AND ROBOTICS

Assignment 1 LED


ASSIGNMENT 1 -CONTROLLING LEDs

questions:


  1. GLOW A SINGLE LED
  2. GLOW 8 LED OF A PORT
  3. BLINKING A SINGLE LED
  4. BLINKING  8 LED OF A PORT
  5. ALTERNATE GLOWING LED s 
  6. GLOWING LED IN INCREASING PATTERN
  7. GLOWING LED IN DECREASING PATTERN
  8. GLOWING LED IN CONVERGING PATTERN
  9. GLOWING LED IN DIVERGING PATTERN
  10. BOTH CONVERGING AND DIVERGING PATTERN
  11. INCREASING AND DECREASING PATTERN
  12. WITH A SWITCH GLOW 1 LED
  13. WITH A SWITCH GLOW ALL 8 LEDS
  14. WITH 4 DIFFERENT SWITCH GLOW 4 DIFFERENT PATTERN
  15. WITH 1 SWITCH GLOW 4 DIFFERENT PATTERN 
_____________________________________________________________________
proteus microcontroller circuit with led pattern


_______________________________________________________________________________

answers:

GLOW A SINGLE LED

DDRA.0=1;
while (1)
      {
       PORTA.0=1;

      };
}

_______________________________________________________________________________

GLOW 8 LED OF A PORT

DDRA.0=255;
while (1)
      {
       PORTA=255;

      };
}
_______________________________________________________________________________
BLINKING A SINGLE LED

DDRA.0=1;                // declaring pin as output
while (1)
      {
       PORTA.0=1;         // giving output to pin as 5 volt
       delay_ms(100);    // dont forget to include header file #include<delay.h>
       PORTA.0=0;   
       delay_ms(100);
      };
}
_______________________________________________________________________________
BLINKING  8 LED OF A PORT

DDRA=255;                // declaring port as output
while (1)
      {
       PORTA=255;         // giving output to pin as 5 volt
       delay_ms(100);    // dont forget to include header file #include<delay.h>
       PORTA=0;   
       delay_ms(100);
      };
}


_______________________________________________________________________________

 ALTERNATE GLOWING LED s 

DDRA=255;                // declaring port as output
while (1)
      {
       PORTA=0b01010101;         // giving value in binary format
       delay_ms(100);               // dont forget to include header file #include<delay.h>
       PORTA=0b10101010;   
       delay_ms(100);
      };
}
_______________________________________________________________________________
 GLOWING LED IN INCREASING PATTERN


// do not forget to initialize x as an integer (int x)  above main() on top of program
We have to make pattern in binary form like this
00000001
00000011
00000111
00001111
00011111
00111111
01111111
11111111
All places having 1 denotes led glow ie +5V while 0 stands for o volt


while (1)
      {
        for(x=1;x<256;x=((x*2)+1))          
         {
         PORTA=x;
         delay_ms(100);
         }
      };
}


_______________________________________________________________________________

Decreasing pattern : DO IT YOURSELF



_______________________________________________________________________________

 GLOWING LED IN CONVERGING PATTERN

// do not forget to initialize x,y as an integer (int x,y;)  above main() on top of program
We have to make pattern in binary form like this
10000001
01000010
00100100
00011000

DDRA=255;               // declaring port as output
while (1)
      {   y=1;                                  // DECLARE int y,x; ON THE TOP OF PROGRAM
        for(x=128;x>=16;x=x/2)           // do not forget to intialise x as an integer (int x) above main() on top of program
         {
         PORTA=x+y;
         y=y*2;
         delay_ms(100);
         }
      };
}
_______________________________________________________________________________

 GLOWING LED IN DIVERGING PATTERN

// do not forget to initialize x,y as an integer (int x,y;)  above main() on top of program
We have to make pattern in binary form like this

00011000
00100100
01000010
10000001

DDRA=255;               // declaring port as output
while (1)
      {   y=8;                                  // DECLARE int y,x; ON THE TOP OF PROGRAM
        for(x=16;x<=128;x=x*2)           // do not forget to intialise x as an integer (int x) above main() on top of program
         {
         PORTA=x+y;
         y=y/2;
         delay_ms(100);
         }
      };
}

Converging and diverging pattern: do it yourself
_______________________________________________________________________________

 WITH A SWITCH GLOW 1 LED

DDRA.0=1;          //PIN A AS OUTPUT    
DDRB.0=0;         // PIN B AS INPUT
while (1)
      {  
      if(PINB.0==1)        // IF PIN B GETS INPUT 5 V FROM SWITCH PIN A IS GIVEN 5 V
      {
      PORTA.0=1;
      }
     };  
 }


 OTHER QUESTION DO YOURSELF..
_______________________________________________________________________________

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Is it real that you are pursuing down the LED TV Service Center in Hyderabad Electronicservicecenter.in is one of the fundamental multi check advantage center in twin urban areas. We have been advancing strong and quality affiliations wherever all through the city with our inside and out readied and fit bosses.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...

Popular Posts