Components and supplies
Capacitor 100 µF
9V 1A Switching Wall Power Supply
Servo Motor
Arduino Nano R3
5V Relay Module
Press Button Switch with LED
NRF24L01 Radio Transciever
12V Solenoid
4xAA battery holder
Tools and machines
Drill / Driver, Cordless
3D Printer (generic)
Apps and platforms
Fusion 360
Project description
Code
Button and Box Code
arduino
The first section is for the arduino in the bust. The second section is for the arduino in the box.
1/* Secret Bust Button 2 * Bust 3 */ 4#include <SPI.h> 5#include <nRF24L01.h> 6#include <printf.h> 7#include <RF24.h> 8#include <RF24_config.h> 9 10RF24 radio(7, 8); // CE, CSN 11const byte address[6] = "00001"; 12 13const int buttonPin = 9; 14bool buttonState; 15//bool prevButtonState = 0; 16 17void setup() { 18 Serial.begin(9600); 19 radio.begin(); 20 radio.openWritingPipe(address); 21 radio.setPALevel(RF24_PA_MIN); 22 radio.stopListening(); 23 24 pinMode(buttonPin, INPUT); 25} 26 27void loop() { 28 buttonState = digitalRead(buttonPin); 29 Serial.println(buttonState); 30 31 radio.write(&buttonState, sizeof(buttonState)); 32 } 33 34 35 36 37 /* Secret Bust Switch Project 38 * Box Code 39*/ 40 41// Include Libraries 42#include <SPI.h> 43#include <nRF24L01.h> 44#include <RF24.h> 45#include <Servo.h> 46 47// Create Objects 48RF24 radio(7, 8); // CE, CSN 49Servo servo; 50 51// Declare Variables 52const byte address[6] = "00001"; 53bool buttonState; 54const int solenoidPin = 4 ; 55const int servoPin = 3; 56bool lidOpenState = false; 57int pos; 58int prevButtonState; 59 60void setup() { 61 Serial.begin(9600); // Start Serial Monitor 62 radio.begin(); 63 radio.openReadingPipe(0, address); 64 radio.setPALevel(RF24_PA_MIN); 65 radio.startListening(); // Start Listening for radio transmission 66 pinMode(solenoidPin, OUTPUT); 67 digitalWrite(solenoidPin, HIGH); // Release (Lock) Solenoid 68 servo.attach(servoPin); 69 servo.write(5); // Home Servo to 0 Deg (Box Closed Position) 70 delay(1000); // Wait one second 71 servo.detach(); 72} 73 74void loop() { 75if (radio.available()){ 76 radio.read(&buttonState, sizeof(buttonState)); 77 prevButtonState = buttonState; 78 for (int n=0; n=5; n++){ 79 radio.read(&buttonState, sizeof(buttonState)); 80 delay(50); 81 if (prevButtonState != buttonState){ 82 n = 0; 83 } 84 Serial.print("Button State: "); Serial.println(buttonState); 85 Serial.print("Lid Open State: "); Serial.println(lidOpenState); 86 if (buttonState == true && lidOpenState == false){ // If bust switch is pressed and lid is closed... 87 openLid(); // Open lid seqence... 88 lidOpenState = true; // Lid is now open 89 } 90 if (buttonState == false && lidOpenState == true){ // If bust switch is unpressed and lid is open... 91 closeLid(); // Close lid sequence... 92 lidOpenState = false; // Lid is now closed 93 } 94} 95//delay(100); 96} 97} 98/* 99------------------------------------------------------------------------------------------------------------------------------------ 100 Open lid sequence 101------------------------------------------------------------------------------------------------------------------------------------ 102*/ 103void openLid(){ 104 Serial.println("Opening"); 105 digitalWrite(solenoidPin, LOW); // Engage(unlock) Solenoid 106 servo.attach(servoPin); 107 delay(500); 108 servo.write(180); 109 delay(1200); 110 servo.detach(); 111 digitalWrite(solenoidPin, HIGH); // Solenoid is in released (locked) position 112} 113 114/* 115------------------------------------------------------------------------------------------------------------------------------------ 116 Close lid sequence 117------------------------------------------------------------------------------------------------------------------------------------ 118*/ 119void closeLid(){ 120 Serial.println("Closing"); 121 digitalWrite(solenoidPin, LOW); // Engage (unlock) Solenoid 122 servo.attach(servoPin); 123 delay(500); 124 servo.write(5); 125 delay(1200); 126 servo.detach(); 127 digitalWrite(solenoidPin, HIGH); // Solenoid is in released (locked) position 128}
Button and Box Code
arduino
The first section is for the arduino in the bust. The second section is for the arduino in the box.
1/* Secret Bust Button 2 * Bust 3 */ 4#include <SPI.h> 5#include <nRF24L01.h> 6#include <printf.h> 7#include <RF24.h> 8#include <RF24_config.h> 9 10RF24 radio(7, 8); // CE, CSN 11const byte address[6] = "00001"; 12 13const int buttonPin = 9; 14bool buttonState; 15//bool prevButtonState = 0; 16 17void setup() { 18 Serial.begin(9600); 19 radio.begin(); 20 radio.openWritingPipe(address); 21 radio.setPALevel(RF24_PA_MIN); 22 radio.stopListening(); 23 24 pinMode(buttonPin, INPUT); 25} 26 27void loop() { 28 buttonState = digitalRead(buttonPin); 29 Serial.println(buttonState); 30 31 radio.write(&buttonState, sizeof(buttonState)); 32 } 33 34 35 36 37 /* Secret Bust Switch Project 38 * Box Code 39*/ 40 41// Include Libraries 42#include <SPI.h> 43#include <nRF24L01.h> 44#include <RF24.h> 45#include <Servo.h> 46 47// Create Objects 48RF24 radio(7, 8); // CE, CSN 49Servo servo; 50 51// Declare Variables 52const byte address[6] = "00001"; 53bool buttonState; 54const int solenoidPin = 4 ; 55const int servoPin = 3; 56bool lidOpenState = false; 57int pos; 58int prevButtonState; 59 60void setup() { 61 Serial.begin(9600); // Start Serial Monitor 62 radio.begin(); 63 radio.openReadingPipe(0, address); 64 radio.setPALevel(RF24_PA_MIN); 65 radio.startListening(); // Start Listening for radio transmission 66 pinMode(solenoidPin, OUTPUT); 67 digitalWrite(solenoidPin, HIGH); // Release (Lock) Solenoid 68 servo.attach(servoPin); 69 servo.write(5); // Home Servo to 0 Deg (Box Closed Position) 70 delay(1000); // Wait one second 71 servo.detach(); 72} 73 74void loop() { 75if (radio.available()){ 76 radio.read(&buttonState, sizeof(buttonState)); 77 prevButtonState = buttonState; 78 for (int n=0; n=5; n++){ 79 radio.read(&buttonState, sizeof(buttonState)); 80 delay(50); 81 if (prevButtonState != buttonState){ 82 n = 0; 83 } 84 Serial.print("Button State: "); Serial.println(buttonState); 85 Serial.print("Lid Open State: "); Serial.println(lidOpenState); 86 if (buttonState == true && lidOpenState == false){ // If bust switch is pressed and lid is closed... 87 openLid(); // Open lid seqence... 88 lidOpenState = true; // Lid is now open 89 } 90 if (buttonState == false && lidOpenState == true){ // If bust switch is unpressed and lid is open... 91 closeLid(); // Close lid sequence... 92 lidOpenState = false; // Lid is now closed 93 } 94} 95//delay(100); 96} 97} 98/* 99------------------------------------------------------------------------------------------------------------------------------------ 100 Open lid sequence 101------------------------------------------------------------------------------------------------------------------------------------ 102*/ 103void openLid(){ 104 Serial.println("Opening"); 105 digitalWrite(solenoidPin, LOW); // Engage(unlock) Solenoid 106 servo.attach(servoPin); 107 delay(500); 108 servo.write(180); 109 delay(1200); 110 servo.detach(); 111 digitalWrite(solenoidPin, HIGH); // Solenoid is in released (locked) position 112} 113 114/* 115------------------------------------------------------------------------------------------------------------------------------------ 116 Close lid sequence 117------------------------------------------------------------------------------------------------------------------------------------ 118*/ 119void closeLid(){ 120 Serial.println("Closing"); 121 digitalWrite(solenoidPin, LOW); // Engage (unlock) Solenoid 122 servo.attach(servoPin); 123 delay(500); 124 servo.write(5); 125 delay(1200); 126 servo.detach(); 127 digitalWrite(solenoidPin, HIGH); // Solenoid is in released (locked) position 128}
Downloadable files
Box
Box
Bust
Bust
Bust Switch Electronics
Bust Switch Electronics
Box Electronics
Box Electronics
Bust Switch Electronics
Bust Switch Electronics
Box
Box
Box Electronics
Box Electronics
Bust
Bust
Documentation
Bust_Pedestal_Top
Bust_Pedestal_Top
Bust_Pedestal
Bust_Pedestal
Gear Mechanism
Gear Mechanism
Bust_Statue
Bust_Statue
Bust_Statue
Bust_Statue
Servo Mount
Servo Mount
Gear Mechanism
Gear Mechanism
Bust_Pedestal
Bust_Pedestal
Bust_Pedestal_Top
Bust_Pedestal_Top
Comments
Only logged in users can leave comments
maguerero
0 Followers
•0 Projects
Table of contents
Intro
49
0