Fish Light


The software was written using Atmel Studio 6, which features GCC compiler. The device was given four keys: M , C, U and D, for providing of the input to the program. The program assumes three modes of operation:

  • Automatic Mode
  • Manual Mode
  • Battery Mode

In the automatic mode, the color changes according to the predefined scale that was just explained. In addition to that, the manual mode allows the user to manually tune the color. Finally, since the microcontroller always needs some power in order to maintain counting of the time, the battery mode is used to ensure that the device does not restart in case of suddenly unplugging it from the mains. Although it will switch the lights off, it will still maintain counting the time.

Key Function Availability
M mode switch auto/manual
C selects the RGB and lamp manual
U increases the value of selected channel manual
D decreases the value of selected channel manual

Implementation on Atmega88

The first and most important source of information regarding the microcontoller is the datasheet [4]. I have chosen ATmega88 for the application. It is a basic project, which does not use all of the available peripherals. Most importantly, however, it possesses enough PWM channels that are required for the system to work. the following table summarises the I/O pin features that are used.

I/O Pin Feature Task
PCINT0 PB0(14) pin-controlled interrupt U
PCINT3 PB3(17) pin-controlled interrupt D
PCINT4 PB4(18) pin-controlled interrupt C
PCINT5 PB5(19) pin-controlled interrupt M
OC1A PB1(15) TC1 - PWM output A channel: R
OC0A PD6(12) TC0 - PWM output A channel: G
OC0B PD6(11) TC0 - PWM output B channel: B
OC1B PB2(16) TC1 - PWM output B channel: Lamp
TOSC1 PB6(9) TC2 - input 1 external oscillator
TOSC2 PB7(10) TC2 - input 2 external oscillator

PD0(2) Battery power indicator
/RESET PC6(1) reset pin reset

To summarise, the microcontroller uses all three timer counters. Two of them are used to generate four PWM signals and one is used to support the external crystal oscillator.