1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

led brightness control for atmega8

Discussion in 'Microcontrollers' started by thirumaran, Aug 5, 2013.

  1. thirumaran

    thirumaran New Member

    Likes Received:
    0
    Trophy Points:
    1
    i need to control brightness of 8 leds connected in portb.. can u give source code for this.. thanks in advance.. plz i need it urgent...
  2. Binu

    Binu Administrator

    Likes Received:
    138
    Trophy Points:
    63
    Have you started the code?
    Are you writing the code in C/ASM/BASIC language?
  3. thirumaran

    thirumaran New Member

    Likes Received:
    0
    Trophy Points:
    1
    embed c language...
  4. thirumaran

    thirumaran New Member

    Likes Received:
    0
    Trophy Points:
    1
    #include<avr/io.h> //This is the header for AVR Microcontroller.
    #include <util/delay.h> //header file to generate time delay.
    int main(void)

    {
    OCR1AH = 0;
    DDRB =0xFF; //PortB 1 as output
    TCCR1A = (1<<COM1A1)|(1<<1); // OC1A to zero, 8-Bit PWM
    TCCR1B = 1; //Start PWM
    for (;;) {
    int i;
    for (i=0; i<255; i++) {
    OCR1AL = i; //Change lowbyte of OCR1A
    _delay_ms(15);
    }
    for (i=255; i>0; i--) {
    OCR1AL = i;
    _delay_ms(15);
    }
    }
    return 0; // never reached
    }


    i used this code for single led i need to control 8 led pls help me...
Loading...

Share This Page

Loading...