EEVblog Electronics Community Forum
A Free & Open Forum For Electronics Enthusiasts & Professionals
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
This topic
This board
Entire forum
Google
Bing
Home
Help
Search
About us
Links
Login
Register
EEVblog Electronics Community Forum
»
Electronics
»
Microcontrollers
»
Project of Atmega
« previous
next »
Print
Search
Pages: [
1
]
Go Down
Author
Topic: Project of Atmega (Read 959 times)
0 Members and 1 Guest are viewing this topic.
yalect
Regular Contributor
Posts: 133
Project of Atmega
«
on:
December 26, 2017, 06:37:07 pm »
Hi,
I want to ask you about this C program that make the Led connected to the output of Atmega fliflop but the problem is when I simulated this program on Protuse I observed that the Led still on not flashs
2) which program or software is better to simulate Atmega?
thank you
**********************************************************************************************************
int main(void)
{
DDRC |= (1<<PINC0); //Nakes first pin of PORTC as Output
// OR DDRC = 0x01;
DDRD &= ~(1<<PIND0);//Makes firs pin of PORTD as Input
// OR DDRD = 0x00; //Makes all pins of PORTD input
while(1) //infinite loop
{
if(PIND & (1<<PIND0) == 1) //If switch is pressed
{
PORTC |= (1<<PINC0); //Turns ON LED
Delay_ms(3000); //3 second delay
PORTC &= ~(1<<PINC0); //Turns OFF LED
}
}
}
Logged
hugatry
Contributor
Posts: 17
Country:
Re: Project of Atmega
«
Reply #1 on:
December 26, 2017, 07:11:06 pm »
The code actually works (almost) as you intended it to work; While PD0 is high, PC0 repeatedly toggles between high and low.
Problem is, the low-state won't last long. PC0 goes back to high so fast that you won't even notice the low-state.
Logged
https://www.youtube.com/user/hugatry
Print
Search
Pages: [
1
]
Go Up
« previous
next »
Share me
Smf
EEVblog Electronics Community Forum
»
Electronics
»
Microcontrollers
»
Project of Atmega
There was an error while thanking
Thanking...
EEVblog Main Site
EEVblog on Youtube
EEVblog on Twitter
EEVblog on Facebook
EEVblog on Odysee