[AVR] A littile help here with ATmega16

Status
Not open for further replies.

codename25

Member level 3
Joined
Jan 15, 2015
Messages
65
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
555
Hi,
I'm a newbie in microcontroller. I loaded Muc with simple led blink code, where the led glows for 500ms. One led is connected to pin 1 and other at pin2 of port c. The led is connected with 10k resister. But the led at pin1 glows brightly and led at pin2 glows barely. Is this problem with the code or hardware. Please help me with this. Thanks.
 

\[\sqrt[n]{ }\]
10k is higher!!! Use 10mA current for LED!!!

Use ohms law!!! R = V / I

Hi,
Thanks for the reply. As you said, I changed the resister value to 470E resisitor. But the problem still exist. I'm attaching the image of the two leds. You can see the variation. Is there any other way?

 

Post code too!!! Compiler used, etc...

I'm including the code and the compiler used is AVR STUDIO 4.1.

Code:
#define F_CPU 2000000UL
#include<avr/io.h>
#include<util/delay.h>
intmain(void){
    DDRB |=_BV(DDB0);
while(1){
        PORTB ^=_BV(PB0);
PORTB ^=_BV(PB1);
_delay_ms(500);}}
 

Code:
#define F_CPU 2000000UL
#include<avr/io.h>
#include<util/delay.h>
intmain(void){
    DDRB |=_BV(DDB0);
    DDRB |=_BV(DDB1);
while(1){
        PORTB ^=_BV(PB0);
PORTB ^=_BV(PB1);
_delay_ms(500);}}
 
Code:
#define F_CPU 2000000UL
#include<avr/io.h>
#include<util/delay.h>
intmain(void){
    DDRB |=_BV(DDB0);
    DDRB |=_BV(DDB1);
while(1){
        PORTB ^=_BV(PB0);
PORTB ^=_BV(PB1);
_delay_ms(500);}}

It worked.Thanks alot for your kind help. Thank you.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…