15,501,036 members
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 7:21am
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.

## Solution 2

You could start reading a tutorial on `AVR` registers. See, for instance AVR I/O Register Configuration - Tutorials[^].

## Solution 3

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.

## Solution 1

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[^]

Top Experts
Last 24hrsThis month
 OriginalGriff 182 CPallini 165 Richard MacCutchan 50 Richard Deeming 40 Dave Kreskowiak 20
 OriginalGriff 3,812 Richard MacCutchan 2,019 Richard Deeming 1,523 Graeme_Grant 1,391 CPallini 1,313

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