Last active
August 29, 2015 14:22
-
-
Save CleoQc/b8358752ac218930924e to your computer and use it in GitHub Desktop.
Clyde - 3 Bears - raw Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
3 Gummy Bears - Halloween Hack 2014 | |
written by Nicole Parrot | |
Heavily based on code by DojoDave and Tom Igoe, as found on the Arduino website. | |
http://arduino.cc/en/Tutorial/Button | |
The circuit: | |
* uses Clyde's Ambient light, RGB connected to pins 5, 6 and 9 | |
* 3 x gummy bears respectively attached to pin 10, 12 and 13 from +5V | |
* 3 x 330 ohms resistors respectively attached to pin 10, 12 and 13 from ground | |
This code uses the Clyde library | |
This code is in the public domain. | |
*/ | |
#include <Wire.h> | |
#include <EEPROM.h> | |
#include <Clyde.h> | |
#include <SerialCommand.h> | |
#include <SoftwareSerial.h> | |
#include <MPR121.h> | |
const int rBUTTON = 10; // this is where we will read the red Gummy Bear | |
const int gBUTTON = 12; // this is the pin where we will read the green Gummy Bear | |
const int bBUTTON = 13; // this is the pin where we will read the blue Gummy Bear | |
// the ambient light will be off by default | |
int rval = 0; | |
int gval = 0; | |
int bval = 0; | |
void setup() { | |
Wire.begin(); | |
Clyde.begin(); | |
// set the three Gummy Bears as input devices | |
pinMode(rBUTTON, INPUT); | |
pinMode(gBUTTON, INPUT); | |
pinMode(bBUTTON, INPUT); | |
} | |
void loop() { | |
/* | |
Read status of all three gummy bears. | |
If they're squished, they will register as HIGH. Otherwise they will be low. | |
each gummy bear is independent of each other | |
*/ | |
rval = digitalRead(rBUTTON)*255; | |
gval = digitalRead(gBUTTON)*255; | |
bval = digitalRead(bBUTTON)*255; | |
Clyde.setAmbient(RGB(rval,gval,bval)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment