Alex Glow
Published

The Creativity Button

Switch on your brain's creative potential with this hacked Dash button – a timer that keeps you in the hypnagogic state.

BeginnerFull instructions provided1 hour3,005
The Creativity Button

Things used in this project

Story

Read more

Schematics

Schematic (image)

Schematic (Fritzing)

Code

Bean code

C/C++
Paste this into the Bean Loader app and upload it to your LightBlue Bean.
// PinChangeInt handles pin change interrupts
#include <PinChangeInt.h> 

int hypno = 0;

void setup() {
   pinMode(0, INPUT_PULLUP);
   pinMode(1, OUTPUT);
    
   Bean.setLed(0, 0, 0);
   digitalWrite(1, LOW);
   // run pinChanged when something changes on D0 
   // This is an external library, so you don't need the prefix "Bean"
   attachPinChangeInterrupt(0, pinChanged, CHANGE);
}

void loop() { 
  // Sleep all the time when not handling an interrupt
  if (hypno == 1) {
   Bean.setLed(255, 0, 0);
   digitalWrite(1, HIGH);
   delay(500);
   Bean.setLed(0, 0, 0);
   digitalWrite(1, LOW);
   delay(600000);
   Bean.setLed(255, 0, 0);
   digitalWrite(1, HIGH);
   delay(500);
   Bean.setLed(0, 0, 0);
   digitalWrite(1, LOW);
   hypno = 0;
   }
   
  Bean.sleep(0xFFFFFFFF);
}

// Interrupt service routine (ISR) needs to return void and accept no arguments
void pinChanged() {
   hypno = 1;
}

Credits

Alex Glow

Alex Glow

145 projects • 1571 followers
The Hackster team's resident Hardware Nerd. I love robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments