I want to combine useless box and shy box using only one arduino.
this is the circuit of useless box and shy box I found online, If it can be put together, how the circuit should be made? do you have to use a selector switch? what about the code?
I want to combine useless box and shy box using only one arduino.
this is the circuit of useless box and shy box I found online, If it can be put together, how the circuit should be made? do you have to use a selector switch? what about the code?
Welcome to the forum
What should the combined box do ?
What programming experience do you have, in particular using the Arduino ?
By the way, a PP3 battery is not suitable for powering your project if that is what you are thinking of using because it cannot supply enough current for more than a few minutes
I want to make a box with two modes, one is useless box mode and the second is shy box mode. So when it's in shy box mode, only one servo (the one which open the box) is working. But if it's in useless box mode, the censor is not used and both of the servo works (one to open the lid and the other one to press the switch). if you look at this youtube link DIY Useless Box with Arduino - YouTube
arduino: SHY BOX - YouTube , I want two of it to be combined and use only one arduino. I've tried to make both and now I want to try to combine them but I can't think of the circuits, and I've tried to make it but fail many times
I made a similar project. I called it a "silly" box. You can find full code and documentation here:
There is a very detailed wiring diagram and construction document. Code is very well commented. Given that I don't have time to offer support.
Thank you! I'll definitely try to make it. But may I ask if it's possible to combine useless box and shy box as I explained?
There wouldn’t be a reason not to, maybe a switch to select which one runs.
FYI
okay thank you
I already make the code for this project but I there's something wrong.. Can someone help me?
This is the code I've already make :
#include <Servo.h>
Servo handServo;
Servo boxServo;
int switchStatus=0, action=1, vot, randNumber=0;
const int ledPin = 13;
const int frontSwitchPin = 2;
const int handServoPin = 5;
const int boxServoPin = 6;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin,HIGH);
handServo.attach(handServoPin);
boxServo.attach(boxServoPin);
handServo.write(180);
boxServo.write(70);
//randomSeed(analogRead(0));
}
void loop()
{
switchStatus = digitalRead(frontSwitchPin);
//action = random(1,16);
if (switchStatus == LOW){
if (action == 1)
{
Serial.println("Action 1");
for (int i = 70; i <= 110; i++)
{
boxServo.write(i);
delay(20);
}
for (int i = 180; i >= 35; i--)
{
handServo.write(i);
delay(20);
}
delay(1000);
handServo.write(26);
delay(200);
for (int i = 26; i <=180; i++)
{
handServo.write(i);
delay(20);
}
for (int i = 110; i >= 70; i--)
{
boxServo.write(i);
delay(20);
}
action++;
}
else if (action == 2)
{
Serial.println("Action 2");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(550);
handServo.write(26);
delay(550);
handServo.write(180);
delay(550);
boxServo.write(70);
delay(1500);
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(3000);
boxServo.write(70);
action++;
}
else if (action == 3)
{
Serial.println("Action 3");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(1000);
boxServo.write(70);
delay(2000);
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
handServo.write(26);
delay(550);
handServo.write(180);
delay(500);
boxServo.write(70);
action++;
}
else if (action == 4)
{
Serial.println("Action 4");
for (int i = 70; i <= 110; i++)
{
boxServo.write(i);
delay(20);
}
for (int i = 180; i >= 35; i--)
{
handServo.write(i);
delay(20);
}
delay(2000);
handServo.write(26);
delay(200);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 5)
{
Serial.println("Action 5");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(2000);
handServo.write(65);
delay(550);
handServo.write(40);
delay(200);
handServo.write(65);
delay(200);
handServo.write(40);
delay(200);
handServo.write(65);
delay(200);
handServo.write(40);
delay(200);
handServo.write(65);
delay(200);
handServo.write(40);
delay(200);
handServo.write(65);
delay(200);
handServo.write(40);
delay(200);
handServo.write(65);
delay(2000);
handServo.write(26);
delay(400);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 6)
{
Serial.println("Action 6");
for (int i = 70; i <110; i++)
{
boxServo.write(i);
delay(20);
}
delay(1000);
for (int i = 0; i < 12; i++)
{
for (int j = 70; j <= 110; j++){
boxServo.write(j);
delay(6);
}
delay(200);
}
for (int i = 180; i >= 35; i--)
{
handServo.write(i);
delay(30);
}
handServo.write(26);
delay(400);
handServo.write(180);
delay(400);
boxServo.write(70);
delay(1500);
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(3000);
boxServo.write(80);
action++;
}
else if (action == 7)
{
Serial.println("Action 7");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(400);
handServo.write(26);
delay(1000);
for (int i = 0; i < 6; i++)
{
for (int j = 70; j <= 110; j++){
boxServo.write(j);
delay(6);
}
delay(200);
}
delay(500);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 8)
{
Serial.println("Action 8");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
handServo.write(26);
delay(2000);
for (int i = 0; i < 7; i++)
{
handServo.write(75);
delay(100);
handServo.write(40);
delay(100);
}
delay(500);
handServo.write(180);
delay(1000);
boxServo.write(70);
action++;
}
else if (action == 9)
{
Serial.println("Action 9");
for (int i = 70; i <= 105; i++){
boxServo.write(i);
delay(6);
}
delay(2000);
boxServo.write(110);
for (int i = 180; i >=35; i--)
{
handServo.write(i);
delay(40);
}
delay(500);
handServo.write(26);
delay(200);
for (int i = 26; i <=180; i++)
{
handServo.write(i);
delay(40);
}
boxServo.write(70);
delay(2000);
boxServo.write(100);
delay(3000);
boxServo.write(70);
action++;
}
else if (action == 10)
{
Serial.println("Action 10");
for (int i = 70; i <= 105; i++)
{
boxServo.write(i);
delay(100);
}
delay(1000);
for (int i = 0; i < 10; i++)
{
for (int j = 70; j <= 100; j++){
boxServo.write(j);
delay(6);
}
delay(100);
}
boxServo.write(110);
delay(100);
handServo.write(26);
delay(650);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 11)
{
Serial.println("Action 11");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
handServo.write(26);
delay(2000);
for (int i = 0; i < 3; i++)
{
handServo.write(65);
delay(200);
handServo.write(40);
delay(200);
}
delay(1500);
handServo.write(180);
delay(400);
boxServo.write(70);
delay(1500);
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
handServo.write(26);
delay(3000);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 12)
{
Serial.println("Action 12");
for (int i = 70; i <= 110; i++)
{
boxServo.write(i);
delay(50);
}
delay(1000);
for (int i = 180; i >= 26; i--)
{
handServo.write(i);
delay(50);
}
delay(2000);
handServo.write(26);
delay(200);
handServo.write(180);
delay(400);
boxServo.write(70);
action++;
}
else if (action == 13)
{
Serial.println("Action 13");
for (int i = 70; i <= 110; i++){
boxServo.write(i);
delay(6);
}
delay(2000);
for (int i = 180; i >= 60; i--)
{
handServo.write(i);
delay(40);
}
for (int i = 0; i < 3; i++)
{
handServo.write(60);
delay(200);
handServo.write(40);
delay(800);
}
handServo.write(26);
delay(2000);
handServo.write(180);
delay(500);
boxServo.write(70);
action++;
}
else if (action == 14)
{
Serial.println("Action 14");
for (int i = 70; i <= 105; i++){
boxServo.write(i);
delay(6);
}
delay(4000);
boxServo.write(110);
handServo.write(26);
delay(650);
handServo.write(180);
delay(500);
boxServo.write(100);
delay(4000);
boxServo.write(70);
action++;
}
else if (action == 15)
{
Serial.println("Action 15");
for (int i = 70; i <= 105; i++){
boxServo.write(i);
delay(6);
}
delay(1000);
for (int i = 0; i < 3; i++)
{
for (int j = 70; j <= 105; j++){
boxServo.write(j);
delay(50);
}
for (int j = 105; j >= 70; j--)
{
boxServo.write(j);
delay(50);
}
}
for (int j = 70; j <= 110; j++){
boxServo.write(j);
delay(50);
}
for (int i = 180; i >= 35; i--)
{
handServo.write(i);
delay(40);
}
delay(1000);
handServo.write(26);
delay(400);
handServo.write(180);
delay(400);
boxServo.write(70);
action = 1;
}
}
}
and this is the circuit :
Can you please give us a clue as to what is wrong with how the box works using the sketch that you posted ?
The most obvious problem that I see is that the servos are powered from the Arduino and not an external source
I forgot to add it to the image but I use 9v battery connect to power port.
the problem is the servo keeps moving by itself even though I already change the switch
Then you have 2 possible problems
Can someone help me with the code here?
It would be easier to help you with the code if you posted it here and described the problems
Did you note my previous comments about power to the project and in particular to the servos ?
If you had looked at my design I referred you to then you would know that a 9V battery is not capable of providing the necessary current for the Arduino and the servos. What will likely happen is that as soon as the servos start to move the Arduino will reset due to the voltage drop of initiating the servo movement. You MUST fix this issue first before trying to debug your code.
Interesting but completely useless party trick.
You need to provide power for the servos. A 5 V supply such as a "phone charger" connected directly to the servos for development Allow 1 Amp per servo. You can connect the 5 V positive to the "5V" pin of the Leonardo except for when you have it plugged into the PC USB. It should be obvious that the ground of the power supply and Arduino should always be connected.
Is that a three position switch?
Otherwise why connect both sides to Arduino pins?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.