Page 1 of 2
LED ring R click
From MikroElektonika Documentation
LED ring R click carries a ring of 32 red LEDs driven by four 8-bit 74HC595 serial-in, parallel-out shift
registers. The ring is 25 mm in diameter. The click communicates with the target MCU through the
mikroBUS™ SPI interface, with RST, CS, SCK, MISO and MOSI pins marked MR#, LAT, CLK,
DSOUT, DSIN, respectively. Other LED colors will also be available. The board is designed to use
either a 3.3V or 5V power supply only.
LED ring R click
Features and usage notes
LED ring click is one of several click boards that
employ 74HCP595 shift registers to drive LEDs.
Rotary click use the same, as well as Bargraph click,
7-Seg click and 7x10 click.
Using 8-bit shift registers to drive an array of LEDs
is simply good practice, because it leaves more
available pins on the target MCU, allowing you to
either use a cheaper, lower pin count main MCU, or
use the leftover pins for other purposes.
The end result is a smaller, more cost effective
design.
LED Ring R click
IC/Module
Led ring, 74HC595 serial in parallel out shift
registers x4
Interface
Power
supply
Website
www.mikroe.com/click/led-ring-r
(http://www.mikroe.com/click/led-ring-r)
SPI
3.3V, 5V
Schematic also available in PDF (http://cdn-
docs.mikroe.com/images/9/94/LED_ring_R_click_sch
Programming
The following code snippet demonstrates different ways to communicate with the click and initializes a
clockwork pattern with a single LED at a time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
sbit
sbit
#include
#include
LRR_LAT at
GPIOD_ODR.B13;
LRR_RST at
GPIOC_ODR.B2;
<stdint.h>
"led_ring_hw.h"
void
main()
{
uint8_t
test_bfr[4];
uint8_t
i
= 0;
uint16_t
var_time
= 500;
uint32_t
led
= 0x00000001;
// set latch and reset pins as output
GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_13);
GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_2);
// initalize SPI
SPI3_Init_Advanced( _SPI_FPCLK_DIV16, _SPI_MASTER
|
_SPI_8_BIT
|
_SPI_CLK_IDLE_LOW
|
_SPI_FIRST_CLK_EDGE_TRANSITION
|
_SPI_MSB_FIRST
|
_SPI_SS_DISABLE
|
_SPI_SSM_ENABLE
|
_SPI_SSI_1,
&_GPIO_MODULE_SPI3_PC10_11_12);
led_ring_hal_init();
led_ring_start();
test_bfr[0]
test_bfr[1]
test_bfr[2]
test_bfr[3]
=
=
=
=
0xAA;
0xAA;
0xAA;
0xAA;
led_ring_hal_write(&test_bfr,
4);
// demonstration of HAL write function
led_ring_latch();
Delay_ms(1000);
led_ring_send_32 (
0xFAFAFAFA
);
// demonstration of writing 4 bytes
Delay_ms(2000);
led_ring_send_8
led_ring_send_8
led_ring_send_8
led_ring_send_8
(
(
(
(
test_bfr[0]
test_bfr[0]
test_bfr[0]
test_bfr[0]
);
// writing one byte at a time
);
);
);
while
(1)
{
led_ring_send_32 ( led );
vDelay_ms(var_time);
led
=
led
<< 1;
if
(led
== 0)
{
led
= 1;
i++;
// dot circling faster and faster
Page 2 of 2
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 }
}
}
if
(i
== 0)
var_time
= 500;
else if
(i
== 1)
var_time
= 250;
else if
(i
== 2)
var_time
= 100;
else if
(i
== 3)
var_time
= 50;
else if
( i
== 4
)
{
var_time
= 500;
i
= 0;
}
Code examples that demonstrate the usage of LED Ring click with MikroElektronika hardware, written for mikroC for ARM, PIC, and FT90x are available on
Libstock (http://libstock.mikroe.com/projects/view/1815/led-ring-click).
Resources
- LED ring click Libstock example (http://libstock.mikroe.com/projects/view/1815/led-ring-click)
- LED ring click product page (http://www.mikroe.com/click/led-ring-r/)
- Learn.mikroe.com article about handling shift registers (http://learn.mikroe.com/leds-bit-shifting-shift-register-tutorial/)
Retrieved from "http://docs.mikroe.com/index.php?title=LED_ring_R_click&oldid=371"
◾
This page was last modified on 15 June 2016, at 14:25.
◾
Content is available under Creative Commons Attribution unless otherwise noted.
http://docs.mikroe.com/index.php?title=LED_ring_R_click&printable=yes
7/11/2016