Light Up Neopixels when tapped-Example
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Light Up Neopixels when tapped-Example

by nemesis_c on Mon Aug 01, 2016 1:11 am

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.
(queu sad violin music)

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

Uploaded the code
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)
Added some gloves

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 120

void setup(void)

  // 2, 4, 8 or 16 G!
  //Smaller range (2G) = high precision
  //Large range=detect greater forces

  //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

void loop()

//Makes  Neopixels light up at the same time
void ColorFill(uint16_t r,uint16_t g,uint16_t b){
  for(uint16_t i=0; i<10; i++) {
    CircuitPlayground.setPixelColor(i, r, g, b);
snape.jpg (61.59 KiB) Viewed 589 times
Last edited by nemesis_c on Tue Aug 02, 2016 11:22 pm, edited 1 time in total.

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

Re: Light Up Neopixels when taped-Example

by adafruit_support_mike on Mon Aug 01, 2016 1:44 am

Nice! Thanks for posting!

Posts: 57366
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.