Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
int main(void)
{
	DDRD=0B00000000;
	DDRB |=(1<<1);    
	DDRB &= ~(1<<0);  
	PORTB |=(1<<0);   
    while (1) {
		if((PINB&(1<<0))==0){
			while((PINB&(1<<0))==0);
			for(char i=0; i<8; i++){
				if((PIND&(1<<i))!=0)
					PORTB|=(1<<1);
				else
					PORTB &=~(1<<1);
			}
		}
    }
    _delay_ms(1);  
}



What I have tried:

I actually don't know what it does, need help please
Posted
Updated 23-Apr-21 6:21am
Comments
Richard MacCutchan 23-Apr-21 9:49am    
Try asking the person who wrote it.
Rick York 23-Apr-21 10:54am    
You are learning micro what?
Rick York 23-Apr-21 11:59am    
All of those shifts of 0 and 1 are ridiculous. Is it really so difficult to write 1 and 2? The shifts certainly don't add to readability.
KarstenK 23-Apr-21 14:30pm    
maybe that is some codestyle for that programming.

You could start reading a tutorial on AVR registers. See, for instance AVR I/O Register Configuration - Tutorials[^].
 
Share this answer
 
This is a bunch of bit shifts, basically just changing numbers, but what does this actually mean to the hardware attached to the board? Only the person who wrote that code and put the hardware together will know.
 
Share this answer
 
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900