user27151: This is for a class in which we are not allowed to use the Arduino Library (Not my choice or preference). I know to use DDRB for the B pins. This is the code that I have so far:
//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (condition to turn on light) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   if (condition to turn off the light) {
     *portDataB &= 0x7F
   }
}

I would like for the light to turn on when the input of PB4 is HIGH (from a button press). I just am not sure on what to put in the condition statements or the setup functions. 
When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?
I am using the Arduino Mega ATmega2560 btw.
From the comments I have this:
//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (portPinB & 0x10) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   else {
     *portDataB &= 0x7F
   }
}


user2881: Assuming the button is connected between GND and pin 10, without any pull-ups or pull-downs.
void setup () {
    //For the led output I know that I would do this
    DDRB = 0;             // set all pins on port B to INPUT
    DDRB |= _BV(DDB7);   // set PB7 to OUTPUT
    PORTB = 0;            // set all pins on port B to LOW
    PORTB |= _BV(PORTB4); // enable the pull-up resistor on PB4
}

void loop () {
    if( PINB & _BV(PINB4) )
    {
        // if bit PINB4 is set, the button is not pressed
        PORTB &= ~_BV(PORTB7); // turn off led
    }
    else
    {
        PORTB |= _BV(PORTB7); // turn off led
    }
}


user10794: 
When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?


Clarification
I take that question to mean "When I assign the value to 0x80 to DDRB". For example:
DDRB = 0x80;

In the code above that question, you were not assigning, you were "or"ing the value.

Yes. Typically you would "or" in the value if you want to affect only one pin, eg.
DDRB |= 0x80;

The conventional way to make it an input again would be:
DDRB &= ~0x80;

That is, "and" in the negated bit pattern for that pin.
Remember, you have 3 registers (per port) where "x" is "A", "B", "C" etc.:

DDRx - data direction - a 1-bit is output, a 0-bit is input
PORTx - output value - a 1-bit is HIGH, a 0-bit is LOW
However, if the data direction is input, then a 1-bit is input-pullup, and a 0-bit is not input-pullup.
PINx - read the input from the port - a 1-bit is HIGH, a 0-bit is LOW
Note that writing a 1-bit to PINx toggles the output value of that port.


These remarks apply to the AVR chips, not the SAM ones.

27151: <p>This is for a class in which we are not allowed to use the Arduino Library (Not my choice or preference). I know to use DDRB for the B pins. This is the code that I have so far:</p>

<pre><code>//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (condition to turn on light) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   if (condition to turn off the light) {
     *portDataB &amp;= 0x7F
   }
}
</code></pre>

<p>I would like for the light to turn on when the input of PB4 is HIGH (from a button press). I just am not sure on what to put in the condition statements or the setup functions. </p>

<p>When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?</p>

<p>I am using the Arduino Mega ATmega2560 btw.</p>

<p>From the comments I have this:</p>

<pre><code>//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (portPinB &amp; 0x10) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   else {
     *portDataB &amp;= 0x7F
   }
}
</code></pre>
 2881: <p>Assuming the button is connected between GND and pin 10, without any pull-ups or pull-downs.</p>

<pre><code>void setup () {
    //For the led output I know that I would do this
    DDRB = 0;             // set all pins on port B to INPUT
    DDRB |= _BV(DDB7);   // set PB7 to OUTPUT
    PORTB = 0;            // set all pins on port B to LOW
    PORTB |= _BV(PORTB4); // enable the pull-up resistor on PB4
}

void loop () {
    if( PINB &amp; _BV(PINB4) )
    {
        // if bit PINB4 is set, the button is not pressed
        PORTB &amp;= ~_BV(PORTB7); // turn off led
    }
    else
    {
        PORTB |= _BV(PORTB7); // turn off led
    }
}
</code></pre>
 10794: <blockquote>
  <p>When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?</p>
</blockquote>

<hr>

<p><strong>Clarification</strong></p>

<p>I take that question to mean "When I <em>assign</em> the value to 0x80 to DDRB". For example:</p>

<pre><code>DDRB = 0x80;
</code></pre>

<p>In the code above that question, you were not assigning, you were "or"ing the value.</p>

<hr>

<p>Yes. Typically you would "or" in the value if you want to affect only one pin, eg.</p>

<pre><code>DDRB |= 0x80;
</code></pre>

<p>The conventional way to make it an input again would be:</p>

<pre><code>DDRB &amp;= ~0x80;
</code></pre>

<p>That is, "and" in the negated bit pattern for that pin.</p>

<p>Remember, you have 3 registers (per port) where "x" is "A", "B", "C" etc.:</p>

<ul>
<li>DDRx - data direction - a 1-bit is output, a 0-bit is input</li>
<li><p>PORTx - output value - a 1-bit is HIGH, a 0-bit is LOW</p>

<p>However, if the data direction is input, then a 1-bit is input-pullup, and a 0-bit is not input-pullup.</p></li>
<li><p>PINx - read the input from the port - a 1-bit is HIGH, a 0-bit is LOW</p>

<p>Note that writing a 1-bit to PINx toggles the output value of that port.</p></li>
</ul>

<hr>

<p>These remarks apply to the AVR chips, not the SAM ones.</p>
