Skip to content

Instantly share code, notes, and snippets.

@greylurk
Created October 14, 2015 11:30
Show Gist options
  • Save greylurk/815355508760d743a6c3 to your computer and use it in GitHub Desktop.
Save greylurk/815355508760d743a6c3 to your computer and use it in GitHub Desktop.
// Check the install instructions for https://github.com/GreyGnome/EnableInterrupt
#include <EnableInterrupt.h>
// Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
#define MOMENTARY_SWITCH 10
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
const int vape = 6;
const int masterButton = 5;
const int audioOut = 3;
#define COMMON_ANODE
volatile uint16_t vapeEnabled=0;
void interruptFunction() {
vapeEnabled != vapeEnabled
}
void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(vape, OUTPUT);
pinMode(audioOut, OUTPUT);
pinMode(masterButton, INPUT);
pinMode(MOMENTARY_SWITCH, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
enableInterrupt(MOMENTARY_SWITCH, interruptFunction, FALLING);
}
void loop() {
if (digitalRead(masterButton) == HIGH) {
digitalWrite(audioOut, LOW);
if( vapeEnabled ) {
digitalWrite(vape, HIGH);
}
setColor(255, 0, 0); // red
delay(125);
setColor(0, 255, 0); // green
delay(125);
setColor(0, 0, 255); // blue
delay(125);
setColor(255, 255, 0); // yellow
delay(125);
setColor(0, 255, 255); // aqua
delay(125);
setColor(80, 0, 80); // purple
delay(125);
}
else {
digitalWrite(audioOut, HIGH);
digitalWrite(vape, LOW);
setColor(0, 0, 0);
}
}
void setColor(int red, int green, int blue) {
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
digitalWrite(redPin, red);
digitalWrite(greenPin, green);
digitalWrite(bluePin, blue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment