Skip to content

Commit d37a0fe

Browse files
committed
Merge branch 'kch-leds'
2 parents d351f08 + dbbde6c commit d37a0fe

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

_data/sidebar_tree.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ tree:
4747
tree:
4848
- url: /programming/sr/cheat_sheet
4949
title: API Quick Reference
50+
- url: /programming/sr/leds/
51+
title: LEDs
5052
- url: /programming/sr/motors/
5153
title: Motors
5254
- url: /programming/sr/power/

programming/sr/leds/index.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
layout: page
3+
title: LEDs
4+
---
5+
6+
LEDs
7+
====
8+
9+
The KCH HAT provides diagnostic information about the state of your robot
10+
through a collection of preconfigured and user-controllable LEDs. It is part of
11+
the [Brain Board](/docs/kit/brain_board) assembly, however control of its LEDs
12+
is provided through a distinct API.
13+
14+
The LEDs on the KCH can be accessed via the `kch` object:
15+
16+
~~~~~ python
17+
R.kch.something...
18+
~~~~~
19+
20+
[LEDs](#leds) {#leds}
21+
---------------------
22+
23+
The KCH HAT has three RGB LEDs: A, B and C. The LEDs default to off, however
24+
once set they will hold their value even if your code exits. This is potentially
25+
useful to understand the current state of your code as it runs or the final
26+
state of the code afterwards.
27+
28+
Each channel of each LED acts independently, so you can either set them separately:
29+
30+
~~~~~ python
31+
# Turn on the red channel of LED A
32+
R.kch.a.red = 1
33+
34+
# Turn on the green channel of LED B
35+
R.kch.b.green = 1
36+
37+
# Turn off the red channel of LED A
38+
R.kch.a.red = 0
39+
~~~~~
40+
41+
Alternatively you can set the red, green and blue channels for a given LED all together:
42+
43+
~~~~~ python
44+
# Set LED C to a yellow colour
45+
R.kch.c.rgb = (1, 1, 0)
46+
47+
# Set LED B to a light blue colour
48+
R.kch.b.rgb = (0, 1, 1)
49+
~~~~~
50+
51+
You can also access all the LEDs together:
52+
53+
~~~~~ python
54+
# Turn on the blue channel of all the LEDs
55+
for led in R.kch.leds.values():
56+
led.blue = 1
57+
58+
# Set all LEDs to a purple colour
59+
for led in R.kch.leds.values():
60+
led.rgb = (1, 0, 1)
61+
~~~~~

0 commit comments

Comments
 (0)