Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******
- * Marquessa MacKenzie
- * December 11/2020
- * Atelier 1: Discovery
- *
- * Original Code:
- Code for the Textile Game Controller Jam by Social Body Lab, Dames Making Game, & Game Play Lab.
- May 30, 2020 - June 6, 2020.
- This is code follows along the "How to Make an Capacitive Sensor Using E-Textile Materials" here: https://youtu.be/kTfoMyjtgws
- The code contains 1 capacitive sensor which lights up when touched.
- Circuit Playground Library:
- https://learn.adafruit.com/circuit-playground-lesson-number-0
- *
- *Added speaker putput from here: https://learn.adafruit.com/circuit-playground-music/using-the-circuit-playground-speaker
- *********/
- /**Must include the Adafruit_CircuitPlayground.h**/
- #include <Adafruit_CircuitPlayground.h>
- #define CAP_THRESHOLD 800 //increase this number if unintentional keypresses occur and
- /**Setting up the ability to read capactive touch on the Circuit Playgroun**/
- /**If using capactive touch, you must include this line in your code!**/
- boolean capButton(uint8_t pad) {
- if (CircuitPlayground.readCap(pad) > CAP_THRESHOLD) {
- return true;
- } else {
- return false;
- }
- }
- void setup() {
- Serial.println(CircuitPlayground.readCap(6));
- Serial.begin(9600); // Starting the serial monitor
- CircuitPlayground.begin(); // Initiating the Circuit Playground
- }
- void loop() {
- Serial.println(CircuitPlayground.readCap(6));
- if (capButton(6)) {
- CircuitPlayground.playTone(1760,100); // output a 1760 Hz sound for a tenth of a second
- }
- if (capButton(1)) {
- CircuitPlayground.playTone(440,100); // output a 440 Hz sound for a tenth of a second
- }
- if (capButton(0)) {
- CircuitPlayground.playTone(800,100); // output a 800 Hz sound for a tenth of a second
- }
- // if (capButton(0)) { // if the 0 pin is activated through capactive touch
- // Serial.println("Pin 6 is activated!");
- // for (int i = 0 ; i < 10; i++) { // loop through all of the lights and turn them on
- // CircuitPlayground.setPixelColor(i, 255, 0, 200); // pink colour
- // }
- // } else { // turn off all of the LEDs
- // CircuitPlayground.clearPixels();
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement