Skip to content

Commit 47bce01

Browse files
committed
Document how to use the LEDs on the KCH HAT
I've opted to name this document after the LEDs it controls, rather than the board where those LEDs are hosted, to follow the naming pattern of the "motors", "servos" (etc.) docs which do the same for the other boards. This is based on the current state of the API integration in https://github.com/srobo/sr-robot3/pull/60, so may not be quite how this is intended to function. Hopefully there's a useful starting point here though. Fixes #358
1 parent 8739a41 commit 47bce01

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 provide 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.green = (0, 1, 1)
49+
~~~~~

0 commit comments

Comments
 (0)