Halloween 2024 - Teil 1 - Der Süßigkeitenspender - AZ-Delivery

Not at home on Halloween? That can end badly. Unless you have a candy or candy dispenser. We have a possible guard in the box in previous project presented.

All you need are a microcontroller, LEDs and buttons as well as a strong servo motor, plus some craft stuff and creativity.

Hardware

1

Microcontroller Uno

1

Prototyping Shield, Alternatively Mini Breadboard

2

RGB LEDS

1

Servo with metal gear MG90S,  MG995,  MG996R

1

Button (here arcade button with LED)

Opt.

Active Summer (Buzzer)

Jumper cable and power supply 4xAA battery

approx. 1m

Cable channel 60x40mm from the hardware store, adhesive tape


Here is the most important component that

Candy dispenser

Bonbon dispenser, cable channel 60x40 mm, servo arm extended with shrink hose

I had seen a candy dispenser with a linear motor and parts from the 3D printer on the Internet. At Linearmotor I remembered my scrap collection with old CD/DVD drives. Both the drawer, As well as the reading head are moved in this way. So dissect an old drive was exciting, but in the end it was not suitable for my structure. Alternative is a servo engine.

Unfortunately not In the range of AZ-Delivery is the illuminated button how it is used in arcade consoles. You can of course also use other buttons.

My idea: the children press the red nose of my slightly creepy clown face, the red eyes become green, after 2.5 seconds their eyes flash twice and the Servomotor Rotate around 90 ° to push out a small candy pack. You can paint, print it out, or how I glue together as a patchwork.



The whole structure is not intended for eternity, so electronics and batteries are in a cardboard box.

I use RGB LEDs with a common cathode. This has the longest leg of the RGB LED, the individual leg on one side is for the red content, the two legs on the other side are for green and blue. I use the pins of the microcontroller No. 3 for red, 4 for GND, 5 for green and 6 for blue, firstly to be able to dim the LEDs (3, 5 and 6 have PWM) and secondly with the short -term setting of the pins 4 on high wink both the wink, as well as activate the optional buzzer. I switched the two "eyes" (RGB LEDs) in parallel. You can optionally control them individually.

Uno With prototyping shield. 2 RGB LEDs, illuminated buttons (like game console)

circuit diagram

sketch

(Download):

/* Halloween 2023
Clown Face with Rgbleds as Eyes, Big Button with Led as Nose
Normal ops: Red Eyes and Button with Red Led,
When button is pressed, eye gymnast and LED in button off for 6 sec,
After 2.5 s, Green Eyes Twinkle and Buzzer Sounds Shortly Two Times
Servo wants to activated to push out sweets
by Bernd Albrecht 
for AZ-Delivery  */

#include <Servo.H>
Servo myservo;                // Create servo object to control a servo
intimately POS = 0;                  // variable to store the servo position

// Constants Won't Change. They're used here to set pin Numbers:
const intimately button = 8;      // The Number of the PushButton PIN
const intimately Redledpin =  3;     // The Number of the Red Led Pin
const intimately gndledpin =  4;     // The Number of the Common Ground Led Pin
const intimately Greenledpin =  5;   // The Number of the Green Led Pin
const intimately blood pine =  6;    // The Number of the Blue Led Pin
const intimately ledpine =  9;        // The Number of the Led PIN in button

// variables wants change:
intimately button = 0;          // Variable for reading the push button status

void set up() {
  // Initialize the Led Pin as An Output:
  pin mode(Redledpin, OUTPUT);
  pin mode(gndledpin, OUTPUT);
  digital(gndledpin, Low);    
  pin mode(Greenledpin, OUTPUT);
  pin mode(blood pine, OUTPUT);
  pin mode(ledpine, OUTPUT);  
  // Initialize the PushButton Pin as an input:
  pin mode(button, Input_pullup);
  myservo.Attach(10); // Attaches the servo on pin 10 to the servo object 
  myservo.write(130);
  delay(500);  
}  // End setup

void servoturn()   {    // Adjust Angles Acc. to your setup
    for (POS = 130; POS >= 20; POS -= 1) {
    // goes from 120 degrees to 20 degrees
    // in Steps of 1 degree
    Serial.print(POS);
    myservo.write(POS);
    delay(10);
    }
  for (POS = 20; POS <= 130; POS += 1) {
    // goes from 20 degrees to 120 degrees
    Serial.print(POS);  
    myservo.write(POS);
    delay(10);
    }
}  // End servoturn

void loop() {
  // Read the State of the PushButton Value:
  button = digital read(button);
  // check if the push button is pressed. If it is, the buttonstate is low:
  IF (button == Low) {
    // turn green led on, red led off:
    digital(Redledpin, Low);
    digital(ledpine, Low);    
    digital(Greenledpin, HIGH);
    delay(2500);
    digital(gndledpin, HIGH);     
    delay(250); 
    digital(gndledpin, Low); 
    delay(250);
    digital(gndledpin, HIGH);     
    delay(250);
    digital(gndledpin, Low);
    servoturn();      
    delay(2500);        
  } Else {
    // turn green led off red led on:
    digital(Greenledpin, Low);
    digital(ledpine, HIGH);      
    digital(Redledpin, HIGH);    
  }
}  // end loop

Have fun building and programming your Halloween surprise, here again the links to the articles of the past few years:

Für arduinoSpecials

2 commentaires

Michael Zint

Michael Zint

Hallo,
gute Idee, kommt genau richtig.
Ich hatte nur einige Probleme.
Der Sketch aus dem Downloadlink hat nicht funktioniert, ich habe mir dann den Sketch direkt von der Seite kopiert, das hat dann funktioniert aber erst als ich den Piezo aus dem Projekt rausgenommen habe warum auch immer.

Philipp

Philipp

Sehr schönes und einfaches Projekt. Danke fürs teilen und die tolle Anleitung.

Laisser un commentaire

Tous les commentaires sont modérés avant d'être publiés

Articles de blog recommandés

  1. ESP32 jetzt über den Boardverwalter installieren - AZ-Delivery
  2. Internet-Radio mit dem ESP32 - UPDATE - AZ-Delivery
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1 - AZ-Delivery
  4. ESP32 - das Multitalent - AZ-Delivery