Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: samples/raspberry-pi2/basic/buzzer.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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 // A small buzzer example illustrating both input and output GPIO pins. 5 // A small buzzer example illustrating both input and output GPIO pins.
6 // 6 //
7 // For breadboard layout and connections to the Pi, see: 7 // For breadboard layout and connections to the Pi, see:
8 // https://storage.googleapis.com/fletch-archive/images/buzzer-schematic.png 8 // https://storage.googleapis.com/dartino-archive/images/buzzer-schematic.png
9 9
10 import 'package:gpio/gpio.dart'; 10 import 'package:gpio/gpio.dart';
11 import 'package:raspberry_pi/raspberry_pi.dart'; 11 import 'package:raspberry_pi/raspberry_pi.dart';
12 12
13 main() { 13 main() {
14 // GPIO pin constants. 14 // GPIO pin constants.
15 const int button = 16; 15 const int button = 16;
16 const int speaker = 21; 16 const int speaker = 21;
17 17
18 // Initialize Raspberry Pi and configure the pins. 18 // Initialize Raspberry Pi and configure the pins.
19 RaspberryPi pi = new RaspberryPi(); 19 RaspberryPi pi = new RaspberryPi();
20 PiMemoryMappedGPIO gpio = pi.memoryMappedGPIO; 20 PiMemoryMappedGPIO gpio = pi.memoryMappedGPIO;
21 gpio.setMode(button, Mode.input); 21 gpio.setMode(button, Mode.input);
22 gpio.setMode(speaker, Mode.output); 22 gpio.setMode(speaker, Mode.output);
23 23
24 // Map state of button to speaker in a continuous loop. 24 // Map state of button to speaker in a continuous loop.
25 while (true) { 25 while (true) {
26 bool buttonState = gpio.getPin(button); 26 bool buttonState = gpio.getPin(button);
27 gpio.setPin(speaker, buttonState); 27 gpio.setPin(speaker, buttonState);
28 } 28 }
29 } 29 }
OLDNEW
« no previous file with comments | « samples/github/lib/src/tests/github_api_test.dart ('k') | samples/raspberry-pi2/basic/door-bell.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698