/* Soil Sensor Firmware * Light Measurement & LED Status Indication * Sensiplicity Systems * * Copyright 2015 * * Department of Botany and Plant Pathology * Center for Genome Research and Biocomputing * Oregon State University * Corvallis, OR 97331 * * This program is not free software; you can not redistribute it and/or * modify it at all. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include "light.h" #include #include static volatile enum led_state_t LedState, RequestedState; /* Set the led to a visible state. */ void set_led(enum led_state_t state){ /* Turn the anode on. */ PORTD |= _BV(PD4); /* Turn LED off, then selectively turn on the required bits. */ PORTD |= _BV(PD3); PORTE |= _BV(PE0); switch (state){ case(LED_OFF): break; case(LED_GREEN): PORTE &= ~_BV(PE0); break; case(LED_RED): PORTD &= ~_BV(PD3); break; } } /* Setup pins for the LED. */ void init_led(void){ DDRD |= _BV(PD4); DDRD |= _BV(PD3); DDRE |= _BV(PE0); }