source: trunk/Arduino/libraries/Adafruit_Circuit_Playground/examples/demo/demo.ino @ 28

Last change on this file since 28 was 3, checked in by markus, 7 years ago

Setup project structure

File size: 2.6 KB
Line 
1// Demo program for testing library and board - flip the switch to turn on/off buzzer
2
3#include <Adafruit_CircuitPlayground.h>
4
5// we light one pixel at a time, this is our counter
6uint8_t pixeln = 0;
7
8void setup() {
9  //while (!Serial);
10  Serial.begin(9600);
11  Serial.println("Circuit Playground test!");
12
13  CircuitPlayground.begin();
14}
15
16
17void loop() {
18  // test Red #13 LED
19  CircuitPlayground.redLED(HIGH);
20  delay(100);
21  CircuitPlayground.redLED(LOW);
22  delay(100);
23
24  /************* TEST CAPTOUCH */
25  Serial.print("Capsense #3: "); Serial.println(CircuitPlayground.readCap(3));
26  Serial.print("Capsense #2: "); Serial.println(CircuitPlayground.readCap(2));
27  if (! CircuitPlayground.isExpress()) {  // CPX does not have this captouch pin
28    Serial.print("Capsense #0: "); Serial.println(CircuitPlayground.readCap(0));
29  }
30  Serial.print("Capsense #1: "); Serial.println(CircuitPlayground.readCap(1));
31  Serial.print("Capsense #12: "); Serial.println(CircuitPlayground.readCap(12));
32  Serial.print("Capsense #6: "); Serial.println(CircuitPlayground.readCap(6));
33  Serial.print("Capsense #9: "); Serial.println(CircuitPlayground.readCap(9));
34  Serial.print("Capsense #10: "); Serial.println(CircuitPlayground.readCap(10));
35 
36  /************* TEST SLIDE SWITCH */
37  if (CircuitPlayground.slideSwitch()) {
38    Serial.println("Slide to the left");
39  } else {
40    Serial.println("Slide to the right");
41    CircuitPlayground.playTone(500 + pixeln * 500, 100);
42  }
43
44  /************* TEST 10 NEOPIXELS */
45  CircuitPlayground.setPixelColor(pixeln++, CircuitPlayground.colorWheel(25 * pixeln));
46  if (pixeln == 11) {
47    pixeln = 0;
48    CircuitPlayground.clearPixels();
49  }
50
51  /************* TEST BOTH BUTTONS */
52  if (CircuitPlayground.leftButton()) {
53    Serial.println("Left button pressed!");
54  }
55  if (CircuitPlayground.rightButton()) {
56    Serial.println("Right button pressed!");
57  }
58
59  /************* TEST LIGHT SENSOR */
60  Serial.print("Light sensor: ");
61  Serial.println(CircuitPlayground.lightSensor());
62
63  /************* TEST SOUND SENSOR */
64  Serial.print("Sound sensor: ");
65  Serial.println(CircuitPlayground.mic.soundPressureLevel(10));
66
67  /************* TEST ACCEL */
68  // Display the results (acceleration is measured in m/s*s)
69  Serial.print("X: "); Serial.print(CircuitPlayground.motionX());
70  Serial.print(" \tY: "); Serial.print(CircuitPlayground.motionY());
71  Serial.print(" \tZ: "); Serial.print(CircuitPlayground.motionZ());
72  Serial.println(" m/s^2");
73
74  /************* TEST THERMISTOR */
75  Serial.print("Temperature ");
76  Serial.print(CircuitPlayground.temperature());
77  Serial.println(" *C");
78}
Note: See TracBrowser for help on using the repository browser.