RGB LED cube 5x5x5
1.0
Martin Stejskal, Schmidt Dominik
Main Page
Related Pages
Modules
Files
File List
Globals
All
Files
Functions
Variables
Macros
Groups
Pages
SW
AVR
led_cube_lib
pwm_rgb.c
Go to the documentation of this file.
1
10
#include "
pwm_rgb.h
"
11
12
13
void
init_pwm_rgb
(
void
)
14
{
15
/* Only set pins to output and set them to 1. No matter if support is enabled
16
* or disabled. Always set as output...
17
*/
18
19
// Red color
20
io_set_dir_out
( PWM_R_PORT, PWM_R_pin );
21
io_set_1
( PWM_R_PORT, PWM_R_pin );
22
23
// Green color
24
io_set_dir_out
( PWM_G_PORT, PWM_G_pin );
25
io_set_1
( PWM_G_PORT, PWM_G_pin );
26
27
// Blue color
28
io_set_dir_out
( PWM_B_PORT, PWM_B_pin );
29
io_set_1
( PWM_B_PORT, PWM_B_pin );
30
31
// OK, add configure some stuff, if required...
32
#if pwm_support == enabled
33
34
// Set outputs to non-inverting 8bit fast PWM
35
TCCR3A = (1<<COM3A1)|(0<<COM3A0)|\
36
(1<<COM3B1)|(0<<COM3B0)|\
37
(1<<COM3C1)|(0<<COM3C0)|\
38
(0<<WGM31) |(1<<WGM30);
39
40
// 8bit fast PWM, prescaller 1
41
TCCR3B = (0<<WGM33) |(0<<WGM32)|\
42
(0<<CS32) |(0<<CS31) |(1<<CS30);
43
44
// And set default values to OCR3x registers (on)
45
OCR3A = 255;
// PWM value for red color -> 100%
46
OCR3B = 255;
// PWM value for green color -> 100%
47
OCR3C = 255;
// PWM value for blue color -> 100%
48
#endif
49
}
Generated on Thu Jun 6 2013 16:25:54 for RGB LED cube 5x5x5 by
1.8.4