Skip to content

Instantly share code, notes, and snippets.

@CleoQc
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CleoQc/b8358752ac218930924e to your computer and use it in GitHub Desktop.
Save CleoQc/b8358752ac218930924e to your computer and use it in GitHub Desktop.
Clyde - 3 Bears - raw Arduino
/*
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