Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:47:15+00:00 2026-06-11T22:47:15+00:00

I am using AVR as the micro controller and ATMEGA8 as the processor (inside

  • 0

I am using AVR as the micro controller and ATMEGA8 as the processor (inside the micrcontroller). The board that has micro controller has 4 LEDS. I am able to burn the program and light up the LEDS. But I am unable to achieve a particular thing.

L1 L2  L3 L4

These are 4 LEDS. In the first round each LED lights up after a gap of 3 seconds.The last LED (L4) keeps lighting after the first round.As the third round starts each LED lights at a gap of 3 seconds and L3 keeps lighting when L4 is also lighting and it goes on….till L1.

L1 L2 L3 L4
         On
      On On
   On On On
On On On On

But I am unable to achieve this. Because as i set one LED ON other gets OFF. I even tried adding a small time gap as 10 milliseconds. How do I do this ? Here is what I have till now :

    #include<avr/io.h>
    #include<util/delay.h>
    DDRB = 0xFF; // input
 //PORTB = 0xFF;

    // ob00011110 --> on all --> binary

    int i=0;

    while(i<1) {
      PORTB = 0b00010000; // first led on
      _delay_ms(3000);
      PORTB = 0b00001000; // second led on
      _delay_ms(3000);
      PORTB = 0b00000100; // third on
      _delay_ms(3000);
      PORTB = 0b00000010; // fourth on
      _delay_ms(3000);
      i += 1;
    }

    PORTB = 0b00000010; // keep the 4th on and start all over again and reach til 3rd LED
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:47:16+00:00Added an answer on June 11, 2026 at 10:47 pm

    It looks like your sequence is wrong. When you turn the 2nd LED on you are turning the first off. The sequence should be:

      PORTB = 0b00010000; // first led only
      _delay_ms(3000);
      PORTB = 0b00011000; // first and second led on
      _delay_ms(3000);
      PORTB = 0b00011100; // first, second, and third on
      _delay_ms(3000);
      PORTB = 0b00011110; // first, second, third, and fourth on
      _delay_ms(3000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am working on a project which has following setup. AVR micro-controller IDE
I am using avr studio 5. My controller is AT32UC3A0512. I want to know
I have a binary file that I've disassembled using avr-objcopy. The interrupt vector table
I am using EVK1105 development board with AVR Studio 5 as development IDE for
Am trying to write a program for AVR STK600 board in which am cycling
Here in the program, am cycling through LEDs using timer interrupt & if someone
In order to ensure that some initialization code runs before main (using Arduino/avr-gcc) I
I have a couple of libraries that are created using avr-ar. Each contains a
I am using the UART of Atmega169/AVR Butterfly for transmission to another board, baudrate
Background: I am developing a largish project using at Atmel AVR atmega2560. This project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.