Adafruit is open and shipping! Let's build back better, together!

Light Up Neopixels when tapped-Example

Noticing that there are not very many Circuit Playground tutorials I decided to share a simple one!

But First story time:

My little sister is a BIG Harry Potter Fan.
So, of course she had to go to the midnight release of the newest book: Harry Potter and The Cursed Child.
My mother then volunteered me as tribute to chaperone.
yay..

And then there was light:
Mailman came to my rescue to deliver Circuit Playground
Which meant I had to make a project with it
So the reluctant chaperone was now an eager Potter Fan
I decided to dress up as Snape (since we have similar hairstyles)
Slytherin my way to mashing up a simple program to :
Light up the 10 Neopixels green-to match the Slytherin colors
Every time I tapped on Circuit Playground

Stuck a magnet On the Back side of Circuit Playground
Put on a black blanket (which of course in my head was a majestic cape)

And showed all the kids how Circuit Playground Worked
I'll attach the code below hopefully someone finds it useful!
As well as a picture of the minimalist Snape Costume

If you do remix the code post it back on here ! So we can have more examples :)

Code: Select all | TOGGLE FULL SIZE
`//Each time you tap Circuit Playground the neopixels will all light up green//Modify, share, learn#include <Adafruit_CircuitPlayground.h>#include <Wire.h>#include <SPI.h>//Adjust CLICKFORCE  the ending 2 digits bellow 1XX to adjust sensitivity//for 16G: 5-10 ,8G: 10-20, 4G: 20-40 2G: 40-80#define CLICKFORCE 120void setup(void) {    CircuitPlayground.begin();  // 2, 4, 8 or 16 G!   //Smaller range (2G) = high precision   //Large range=detect greater forces  CircuitPlayground.setAccelRange(LIS3DH_RANGE_2_G);   //Detecting for a 1 time tap  CircuitPlayground.setAccelTap(1, CLICKFORCE);  //If a tap is detected go do what the doSomething function says  attachInterrupt(digitalPinToInterrupt(7), doSomething, FALLING);}void doSomething(void) {        //(Red,Green,Blue) a particular color can be from 0-255   ColorFill(0, 100, 0);//color green    delay(1000);}void loop(){  while(!doSomething);  {    CircuitPlayground.clearPixels();    } }//Makes  Neopixels light up at the same timevoid ColorFill(uint16_t r,uint16_t g,uint16_t b){  for(uint16_t i=0; i<10; i++) {    CircuitPlayground.setPixelColor(i, r, g, b);  }}`
Attachments
snape.jpg (61.59 KiB) Viewed 729 times
Last edited by nemesis_c on Tue Aug 02, 2016 11:22 pm, edited 1 time in total.

nemesis_c

Posts: 53
Joined: Wed Jan 06, 2016 5:10 pm

Re: Light Up Neopixels when taped-Example

Nice! Thanks for posting!