EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / how to make running led using atmega16

how to make running led using atmega16

|

Microcontroller › AVR › how to make running led using atmega16

  • This topic has 5 replies, 3 voices, and was last updated 11 years, 5 months ago by dagakshay.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • February 13, 2011 at 4:33 am #652
    M.Fakhruzzaman.Al.Faisal
    Participant

    I have a question to all member in this forum, I want to make the runing led with the atmega16 but I can’t make the programs ??? anyone can help me ? please tell me

    February 14, 2011 at 5:26 am #5525
    dagakshay
    Participant

    how many LEDS to want to interface…

     

    algo for simple running 8 LEDs:

     

    while(1)

    {

    PORTB=(1<<0);

    _delay_ms(100); 

     

     

    PORTB=(1<<1);

    _delay_ms(100);

     

    PORTB=(1<<2);

    _delay_ms(100);

     

    PORTB=(1<<3);

    _delay_ms(100);

     

    PORTB=(1<<4);

    _delay_ms(100);

     

    PORTB=(1<<5);

    _delay_ms(100);

     

    PORTB=(1<<6);

    _delay_ms(100);

     

    PORTB=(1<<7);

    _delay_ms(100);

    }

    February 14, 2011 at 3:25 pm #5529
    M.Fakhruzzaman.Al.Faisal
    Participant

    I am confused because you have entered above algo is on port B all, if it can be one input (1 pin) is for 8 LED PORTB? or means of PORTB0 to PORTB 7?? please explain, thanks

    February 15, 2011 at 7:02 am #5534
    dagakshay
    Participant

    i dint get you…

    are you asking for PORTB=(1<<n);

     

    PORTm is use to send output on port m in avr…

     

    suppose i want to make PB3 means 3rd pin of  port B as high and rest all as low i can write it as

    PORTB=0b00001000; // b stands for binary…

    PORTB=0x80; // here x stand for hexadecimal…

    or

    PORTB=(1<<PB3);

    PORTB=(1<<3);

     

     

    if you want to put multiple pin as output (in a port) you can use:

    PORTm=(1<<n)|(1<<n’)|(1<<n”);

     

    but remember in above statement on n n’ n” pin will be high and rest all will be low…

     

    and if you want to change only a single pin with out affecting the rest of port values use bit wise operation…. 

    February 18, 2011 at 9:26 am #5551
    Amit Joshi
    Participant

     i think it is also can be done by

     

    // for left shift

    for(i=0;i<6;i++)

    {

    PORTx = (PORTx<<1);  

    _delay_ms(1000);

    }

     

     // for right shift

    for(i=0;i<6;i++)

    {

    PORTx = (PORTx<<1); 

    _delay_ms(1000);

    }

     

     // for cicular shift

    while(1)

    {

    PORTx = (PORTx<<1)|(PORTx>>7); 

    _delay_ms(1000);

    }

    February 21, 2011 at 4:47 am #5557
    dagakshay
    Participant

    for right shift

    PORTx=(PORTx>>1); 

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 16, 2022
  • Need help for diy ups project August 16, 2022
  • Is there a discord for this forum? August 16, 2022
  • cadence transient and pss simulation August 16, 2022
  • Digital Display Information August 16, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools