Introduction: COLORKEY
it wont be easy for them to find your secrets. Keep your secrets safe with colorkey just push three colors and the box would be open
Step 1: Where the Idea Come From?
rememeber when you where a child and you got all those magic secrets hidden from others. COLORKEY give children the easiest and funniest way to keep your secrets hidden.
Step 2: How Does COLORKEY Work?
In order to make the object functional, I used Wiring to achieve the object programming.
Each color is a pulse switch that is connected to wiring. When 3 of the 6 switches are activated; automatically wiring activates an electric lock.
Here is the code for COLORKEY:
int switchrojo = 0;
int switchverde = 1;
int switchmorado = 2;
int switchazul = 3;
int switchamarillo = 4;
int switchnaranja = 5;
int cerradura = 8;
int presionadorojo=0;
int presionadoverde=0;
int presionadomorado=0;
int presionadoazul=0;
int presionadoamarillo=0;
int presionadonaranja=0;
int times_pressed = 0;
long start_time = 0;
void setup()
{
pinMode(switchrojo, INPUT);
pinMode(switchverde, INPUT);
pinMode(switchmorado, INPUT);
pinMode(switchazul, INPUT);
pinMode(switchamarillo, INPUT);
pinMode(switchnaranja, INPUT);
pinMode(cerradura, OUTPUT);
Serial.begin(9600);
pinMode(48, OUTPUT);
digitalWrite (48, HIGH);
}
void loop() {
if(digitalRead(switchrojo) == LOW) {
while(digitalRead(switchrojo) == LOW);
presionadorojo = 1;
times_pressed++;
}
if(digitalRead(switchverde) == LOW) {
while(digitalRead(switchverde) == LOW);
presionadoverde = 1;
times_pressed++;
}
if(digitalRead(switchazul) == LOW) {
while(digitalRead(switchazul) == LOW);
presionadoazul = 1;
times_pressed++;
}
if(digitalRead(switchmorado) == LOW) {
while(digitalRead(switchmorado) == LOW);
presionadomorado = 1;
times_pressed++;
}
if(digitalRead(switchamarillo) == LOW) {
while(digitalRead(switchamarillo) == LOW);
presionadoamarillo = 1;
times_pressed++;
}
if(digitalRead(switchnaranja) == LOW) {
while(digitalRead(switchnaranja) == LOW);
presionadonaranja = 1;
}
if(millis() - start_time > 5000) {
times_pressed = 0;
presionadorojo = 0;
presionadoverde = 0;
presionadoazul = 0;
presionadomorado = 0;
presionadoamarillo = 0;
presionadonaranja = 0;
start_time = millis();
}
if(times_pressed >= 3) {
if((presionadorojo == 0) &&
(presionadoverde == 1) &&
(presionadomorado == 0) &&
(presionadoazul == 1) &&
(presionadoamarillo == 0) &&
(presionadonaranja == 1))
{
digitalWrite (cerradura, HIGH);
delay (5000);
digitalWrite (cerradura, LOW);
times_pressed = 0;
presionadorojo = 0;
presionadoverde = 0;
presionadoazul = 0;
presionadomorado = 0;
presionadoamarillo = 0;
presionadonaranja = 0;
start_time = millis();
}
}
Serial.print(presionadorojo, DEC);
Serial.print(" ");
Serial.print(presionadoverde, DEC);
Serial.print(" ");
Serial.print(presionadoazul, DEC);
Serial.print(" ");
Serial.print(presionadomorado, DEC);
Serial.print(" ");
Serial.print(presionadoamarillo, DEC);
Serial.print(" ");
Serial.println(presionadonaranja, DEC);
Serial.print(times_pressed, DEC);
Serial.print(" ");
delay(100);
}
Each color is a pulse switch that is connected to wiring. When 3 of the 6 switches are activated; automatically wiring activates an electric lock.
Here is the code for COLORKEY:
int switchrojo = 0;
int switchverde = 1;
int switchmorado = 2;
int switchazul = 3;
int switchamarillo = 4;
int switchnaranja = 5;
int cerradura = 8;
int presionadorojo=0;
int presionadoverde=0;
int presionadomorado=0;
int presionadoazul=0;
int presionadoamarillo=0;
int presionadonaranja=0;
int times_pressed = 0;
long start_time = 0;
void setup()
{
pinMode(switchrojo, INPUT);
pinMode(switchverde, INPUT);
pinMode(switchmorado, INPUT);
pinMode(switchazul, INPUT);
pinMode(switchamarillo, INPUT);
pinMode(switchnaranja, INPUT);
pinMode(cerradura, OUTPUT);
Serial.begin(9600);
pinMode(48, OUTPUT);
digitalWrite (48, HIGH);
}
void loop() {
if(digitalRead(switchrojo) == LOW) {
while(digitalRead(switchrojo) == LOW);
presionadorojo = 1;
times_pressed++;
}
if(digitalRead(switchverde) == LOW) {
while(digitalRead(switchverde) == LOW);
presionadoverde = 1;
times_pressed++;
}
if(digitalRead(switchazul) == LOW) {
while(digitalRead(switchazul) == LOW);
presionadoazul = 1;
times_pressed++;
}
if(digitalRead(switchmorado) == LOW) {
while(digitalRead(switchmorado) == LOW);
presionadomorado = 1;
times_pressed++;
}
if(digitalRead(switchamarillo) == LOW) {
while(digitalRead(switchamarillo) == LOW);
presionadoamarillo = 1;
times_pressed++;
}
if(digitalRead(switchnaranja) == LOW) {
while(digitalRead(switchnaranja) == LOW);
presionadonaranja = 1;
}
if(millis() - start_time > 5000) {
times_pressed = 0;
presionadorojo = 0;
presionadoverde = 0;
presionadoazul = 0;
presionadomorado = 0;
presionadoamarillo = 0;
presionadonaranja = 0;
start_time = millis();
}
if(times_pressed >= 3) {
if((presionadorojo == 0) &&
(presionadoverde == 1) &&
(presionadomorado == 0) &&
(presionadoazul == 1) &&
(presionadoamarillo == 0) &&
(presionadonaranja == 1))
{
digitalWrite (cerradura, HIGH);
delay (5000);
digitalWrite (cerradura, LOW);
times_pressed = 0;
presionadorojo = 0;
presionadoverde = 0;
presionadoazul = 0;
presionadomorado = 0;
presionadoamarillo = 0;
presionadonaranja = 0;
start_time = millis();
}
}
Serial.print(presionadorojo, DEC);
Serial.print(" ");
Serial.print(presionadoverde, DEC);
Serial.print(" ");
Serial.print(presionadoazul, DEC);
Serial.print(" ");
Serial.print(presionadomorado, DEC);
Serial.print(" ");
Serial.print(presionadoamarillo, DEC);
Serial.print(" ");
Serial.println(presionadonaranja, DEC);
Serial.print(times_pressed, DEC);
Serial.print(" ");
delay(100);
}
Step 3: Wiring Board Connections
Step 4: Object Construction
In order to test COLORKEY I made a prototype in cartonboard, just to see if it really worked! The final object is made of wood.
Step 5: Easy to Use!
Just push your color key (3 colors) and the box will be open