OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 // | 4 // |
5 // The 'hello world' of embedded: Blinking an LED. Uses the on-board | 5 // The 'hello world' of embedded: Blinking an LED. Uses the on-board |
6 // Raspberry Pi 2 activity LED. | 6 // Raspberry Pi 2 activity LED. |
7 | 7 |
8 import 'package:gpio/gpio.dart'; | 8 import 'package:gpio/gpio.dart'; |
9 import 'package:raspberry_pi/raspberry_pi.dart'; | |
9 import 'package:os/os.dart'; | 10 import 'package:os/os.dart'; |
10 | 11 |
11 main() { | 12 main() { |
12 // Constant for the Raspberry Pi 2 onboard green LED. | 13 // Constant for the Raspberry Pi 2 onboard green LED. |
13 const int led = 47; | 14 const int led = 47; |
mit
2015/10/05 07:26:13
Should remove this constant
Søren Gjesse
2015/10/05 07:43:39
Done.
| |
14 | 15 |
15 // Initialize gpio and configure the pin. | 16 // Initialize Raspberry Pi and configure the activity LED to be GPIO |
16 PiMemoryMappedGPIO gpio = new PiMemoryMappedGPIO(); | 17 // controlled. |
17 gpio.setMode(led, Mode.output); | 18 RaspberryPi pi = new RaspberryPi(); |
19 pi.leds.activityLED.setMode(OnboardLEDMode.gpio); | |
18 | 20 |
19 // Turn LED on and off in a continuous loop. | 21 // Turn LED on and off in a continuous loop. |
20 while (true) { | 22 while (true) { |
21 gpio.setPin(led, true); | 23 pi.leds.activityLED.on(); |
22 sleep(500); | 24 sleep(500); |
23 gpio.setPin(led, false); | 25 pi.leds.activityLED.off(); |
24 sleep(500); | 26 sleep(500); |
25 } | 27 } |
26 } | 28 } |
OLD | NEW |