Automatic beer-opener, using a servo-motor solenoid and then the servo again

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

bierbot.ino (1.29 KB)

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

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

(it is in a bottel by the way)

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... :slight_smile:

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

Hi,
OPs Code

#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;

#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.... :slight_smile:

What is this bit of code supposed to do?

      if (pos > 179) {
        analogWrite
      }

Steve

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.

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.. :slight_smile:

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?

here it is

this time for real

OP's images:


Do you have a working prototype already? (maybe manually operated so at least you have the size and motion correct)

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

(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.

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.

I think the bottles are twist top, so the solenoid only has to hold the "spanner" around the top as the bottle is turned.
Tom.. :slight_smile:

I think OP is from The Netherlands, and other than the rare imported US beer bottles I have yet to see twist tops there (I recall having a really hard time opening such bottles - until I realised you have to twist them!)