Go Down

Topic: Automatic beer-opener, using a servo-motor solenoid and then the servo again (Read 544 times) previous topic - next topic

Stinoenthom

Hi guys,
I am really bad at programming i just put some code from the internet together i hoped that someone could help me with my project for school.

What i am trying to accomplish is that the beer pushes down a button, the  button activates the servo to turn 180 degrees so the opener is right on top of the beer, when the servo has turned the solenoid pushes the opener up with enough power to open it up. After the solenoid pushed it up the servo turns back 180 degrees and then the cycle is done.

I really hope someone is able to help met with this.

I added the program i made (it probably is just a lot of bullshit) and a sketchup of our 'robot'.

thanks in advance,

Thom

slipstick

So a "beer-opener"? What is the beer in, a bottle, a can, a barrel, something else?

I can't see any sketchup which might have given a hint.

Steve

Stinoenthom

https://3dwarehouse.sketchup.com/model/22dc3266-f01b-4dcd-918e-414c0d802aec/Bierbot

the .skp file was to big to upload here is the link.

(it is in a bottel by the way)

TomGeorge

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

You need to post you image as jpg, png or pdf.

Not everybody has access to the app that made the skp file.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Stinoenthom

Here it iss. I changed the robot a little though but that doesn't do anything to the way it should be programmed.

TomGeorge

Hi,
OPs Code
Code: [Select]


#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position
int solenoidPin = 4;    //This is the output pin on the Arduino we are using
int pushButton = 2;
int degree
void setup() {
  // put your setup code here, to run once:
 pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 Serial.begin (9600);
 pinMode (pushButton, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 int buttonState = digitalRead (pushButton);
 Serial.println(buttonState);
 delay(1);
if (buttonState , HIGH){
 for (pos = 0; pos <= 180; pos += 1){//gaat van 0 naar 180 graden
  myservo.write (pos);
  delay (15);
  if (pos >179){
  analogWrite
  
 }}
if (pos = 180){
 digitalWrite(solenoidPin, HIGH);    //Switch Solenoid ON
  delay(1000);                      //Wait 1 Second
  digitalWrite(solenoidPin, LOW);     //Switch Solenoid OFF
  if (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position }
}}}



Try to avoid  doing   }}}
put them to separate lines and do a Auto-Format in the IDE, press   CTRL-T.
Your code formated;
Code: [Select]

#include <Servo.h>
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0;    // variable to store the servo position
int solenoidPin = 4;    //This is the output pin on the Arduino we are using
int pushButton = 2;
int degree
void setup() {
  // put your setup code here, to run once:
  pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin (9600);
  pinMode (pushButton, INPUT);
}
void loop() {
  // put your main code here, to run repeatedly:
  int buttonState = digitalRead (pushButton);
  Serial.println(buttonState);
  delay(1);
  if (buttonState , HIGH) {
    for (pos = 0; pos <= 180; pos += 1) { //gaat van 0 naar 180 graden
      myservo.write (pos);
      delay (15);
      if (pos > 179) {
        analogWrite
      }
    }
    if (pos = 180) {
      digitalWrite(solenoidPin, HIGH);    //Switch Solenoid ON
      delay(1000);                      //Wait 1 Second
      digitalWrite(solenoidPin, LOW);     //Switch Solenoid OFF
      if (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);                       // waits 15ms for the servo to reach the position }
      }
    }
  }

OPs diagram


Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

slipstick

What is this bit of code supposed to do?
Code: [Select]

      if (pos > 179) {
        analogWrite
      }


Steve

Stinoenthom

it is supposed to stop the servo from turning back 180 degrees, when i uploaded my code it. turned 180 and back i was trying to stop it from doing that insteantly but i forgot to finish the code i guess.

TomGeorge

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How are you powering your servo?
What model is the servo?
What is the solenoid and how are you controlling it?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

Stinoenthom

hi i put the sketch of my cicuit as an attachment and also specifications of the solenoid and the servo.

"'the sketch is to big how do i upload it?



wvmarle

OP's images:




Do you have a working prototype already? (maybe manually operated so at least you have the size and motion correct)
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Stinoenthom

heey guys thanks for the imput i finished it myself and it works!!

lastchancename

(Short close-up video please)

While a worthy goal, i'd be suspicious of using a solenoid to 'pop the bottle top'.
A solenoid imparts a very short impulse of mechanical energy, which is just as likely to take the neck off the bottle??
If I was building this, an arrangement of servos is fine to position the opener and bottle - but, i'd use a stronger geared-down servo/motor to apply the progressive force needed to lift the cap.
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

Go Up