/*
Filename: practical_1.6
Author: George Howard
Date: 21/02/2024
Description: This is a program that illuminates a specific LED based on the input of switch 0;
*/
#include <avr/io.h>
#include <util/delay.h>
#define MASK01 0x01 // 0000 0001
int main(void) {
while (1) {
unsigned char switches = 0x00;
unsigned char ledsOut = 0x00;
switches = PINC;
unsigned char masked = switches & MASK01;
// Assigning Ports
DDRC = 0x00;
DDRA = 0xFF;
PORTC = 0xFF;
// Switch statement to decide output
switch(masked) {
case 0x00:
ledsOut = 0x80;
break;
case MASK01:
ledsOut = (0x80 >> 3);
break;
default:
ledsOut = 0x00;
break;
}
// Assigning output to ports
PORTA = ledsOut;
}
}