File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 47
47
tree :
48
48
- url : /programming/sr/cheat_sheet
49
49
title : API Quick Reference
50
+ - url : /programming/sr/leds/
51
+ title : LEDs
50
52
- url : /programming/sr/motors/
51
53
title : Motors
52
54
- url : /programming/sr/power/
Original file line number Diff line number Diff line change
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
+ ~~~~~
You can’t perform that action at this time.
0 commit comments