/*
CS 33301
Project 1-1
Kent State University
Derron Ward
*/
#define BIT3_MASK 0x08 // 0000 1000 --> Pin 3
#define BIT5_MASK 0x20 // 0010 0000 --> Pin 5
#define DATAB_MASK 0x25
#define DDRB_MASK 0x24
#define PINB_MASK 0x23
#define DATAD_MASK 0x2B
#define DDRD_MASK 0x2A
#define PIND_MASK 0x29
unsigned char *dataB;
unsigned char *portDDRB;
unsigned char *portPinB;
unsigned char *dataD;
unsigned char *portDDRD;
unsigned char *portPinD;
void setup() {
// Port B Setup
portDDRB = (unsigned char *) DDRB_MASK;
*portDDRB &= ~BIT3_MASK; // Configure pin 3 as input
dataB = (unsigned char *) DATAB_MASK;
portPinB = (unsigned char *) PINB_MASK;
// Port D Setup
portDDRD = (unsigned char *) DDRD_MASK;
*portDDRD |= BIT5_MASK; // Configure pin 5 as output
dataD = (unsigned char *) DATAD_MASK;
portPinD = (unsigned char *) PIND_MASK;
*dataD &= ~BIT5_MASK; // LED starts in the off state
}
void loop() {
// Poll the switch
if (((*portPinB) & BIT3_MASK) == BIT3_MASK) {
*dataD |= BIT5_MASK; // Put LED in on state
delay(2000);
*dataD &= ~BIT5_MASK; // Put LED in off state
delay(2000);
}
}