#include "oulib.h" // Bion board example // Turn on LED when button is pressed // One change from our discussion in class: // When the button is pressed, the pin reads a 0 // // Circuit information: // Button connected to PORT D, pin 3 // -- When open, the pin is at +5 V // -- When closed, the pin is at 0 V // // LED connected to PORT C, pin 5 // int main (void) { DDRC = 0xFF; DDRD = 0x0; while(1) { if(!(PIND & 0x8)) // Does PIN 3 of PORT D read low right now? { // The button is pressed PORTC = PORTC | 0x20; // PORTC |= 0x20; // Equivalent to above line } else { // Button is not pressed PORTC &= ~0x20; //PORTC &= 0xDF; // Equivalent to above line } }; return (0); }