Arduino UNO Lego Mini-golf Course (+ Wooden Version)
by Panpannic in Circuits > Arduino
230 Views, 1 Favorites, 0 Comments
Arduino UNO Lego Mini-golf Course (+ Wooden Version)
For my first Arduino project I made a Lego mini golf course.
Pressing and holding a button controls a servo motor and LED lights that show you how hard you're gonna swing.
(There are also instructions to make a wooden version)
Downloads
Supplies
Electronic Components
1x Arduino uno
1x experiment breadboard
3x Arduino 5 mm LEDS (green, yellow and red)
1x Arduino push button (12x12x7.3 mm)
10x Arduino Jumper wires
1x TowerPro Microservo 9g (servomotor)
1x USB cable
4x Arduino resistors 10K Omhs
1x Arduino resistor 220 Ohm
Materials for Arduino Enclosure
2x LEGO 16x6 plates (3027)
1x LEGO 8x4 plate Dark green (3035)
24x LEGO 2x4 bricks in grey and lime (3001)
4x LEGO 3x2 bricks grey (3002)
7x LEGO 2x1 bricks (3004)
>15x LEGO plates Lime
golfclub:
1x LEGO 2x3 plate Dark purple (3021)
1x LEGO 1x6 plate Medium lavender (3666)
1x LEGO 1x2 brick Yellow (3004)
decoration:
1x fake LEGO 1x4x6 ladder
1x LEGO bar 6L with stopring (63965)
2x LEGO Plant leaves 6x5 (2417)
1x LEGO 1x1 Plant brick round with 3 bamboo leaves (30176)
1x LEGO crate 3x4x1 2/3 with handholds (30150)
1x LEGO 1x1 with stud on side (87087) (For vines on the wall)
minifigure:
1x LEGO minifigure head female smirk silver lips (3626bpb0674)
1x LEGO torso red wrap top (76382 / 88585)
1x LEGO tan pants
1x fake LEGO black bob
Materials Golfcourse:
1x LEGO 10x20 base plate flat
>32x LEGO1x4 lime flat tiles (2431)
1x LEGO 2x2 with groove and 1 stud in the middle, yellow (87580)
5x LEGO 8x1 plate Lime (3460)
2x LEGO 4x1 tile Yellow (35371)
2x LEGO 8x1 tile Yellow (4162)
3x LEGO 4x1 Fence with lattice Yellow (3633)
2x LEGO 1x2 brick Yellow (3004)
6x LEGO 1x1 round open stud Yellow (3062)
goal:
6x LEGO 1x1 lime slope (54200)
4x LEGO 2x2 with groove (3068)
1x LEGO fence 1x4x2 Yellow (3185)
2x LEGO slope curve 3x1 Lime (50950)
2x LEGO 1x6 plate Lime (3666)
1x LEGO 4x4 plate yellow (3031)
1x LEGO 2x10 plate Light grey (3828)
2x LEGO 2x4 Dark grey (3020)
4x LEGO 1x1 cone with top groove Yellow (59900)
2x LEGO 1x2 grill Dark stone grey with bottom groove (2412)
decorations:
1x LEGO flower stem (3741)
1x LEGO plant (6255)
1x LEGO 1x4 white flag pole (3957)
1x LEGO 4x1 roze streamer flag (4459)
1x LEGO 2x2 tile round with open stud (18674)
1x MEGA BLOKS smurfs carnival arc piece 1x5x2 (LEGO also has arcs of 1x6x2, 15254)
minifigure:
1x LEGO head male angry eyebrows and scowl (4259916)
1x LEGO hoed tan minifigure headgear hat (98279)
1x LEGO torso shirt with sunset (973c32h01pr1517)
1x LEGO tan pants
1x LEGO 1x1x4 flag pole (3596)
1x LEGO 1x1 plate with open O clip (4550017)
Tools
Soldering iron
Solder
Woodglue
Gluegun with hot glue
Lots of coffee
Wood Tools
A Backsaw
A figure saw
A screw- and drill machine
Sanding paper (on the rougher side)
A slim wood file
Wood
8.3 m² of poplar planks. (about 4 planks of wood works with a 2 mm thickness works)
4x 2x2x8 wooden bars
about 60 popsicle sticks
Decoration
Acrylic paint (blue, magenta, green and salmon)
1x Plastic straw
1x Clay ball
Soft styrofoam
Ribbed cardboard
6 felt pads
The Game
The game is very simple. On the golf course, place a ball on the open stud tile. On the top of the Arduino housing, press and hold the blue button. based on how long you hold this button down, the golf club will rotate backwards in steps and the LEDs will turn on one by one. When you release the button, the golf club will shoot forward and hit the ball hard. if you hold the button down for too long, the leds go out and the golf club gently moves to the starting position so you can start again.
I decided that the Servo would start at 90 degrees with no LEDs on, then move to 120 degrees with the red LED, 150 with the yellow LED added and finally to 180 degrees with the green LED on.
Lay-out
The Code
// These variables store the flash pattern
// and the current state of the LED
//#define BUTTON_PIN 4
int ledPin1 = 11; // the number of the LED pin (LED Green)
int ledState1 = LOW; // ledState used to set the LED
int ledPin2 = 12; // the number of the LED pin (LED Yellow)
int ledState2 = LOW; // ledState used to set the LED
int ledPin3 = 13; // the number of the LED pin (LED red)
int ledState3 = LOW; // ledState used to set the LED
int ButtonPower = 0;
// Include the Servo library
#include
// Declare the Servo pin
int servoPin = 3;
// Create a servo object
Servo Servo1;
void setup()
{
// set the digital pin as output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(4, INPUT);
Serial.begin(9600);
//Make the Servo angle 90 degrees by default
Servo1.attach(servoPin);
Servo1.write(90);
}
void loop()
{
int buttonState = digitalRead(4);
//Serial.println(buttonState);
// check to see if it's time to change the state of the LED
//The longer I press the button, the higher the int 'buttonpower' is.
if (buttonState== HIGH) {
ButtonPower = ButtonPower + 1;
delay(30);
}
if (buttonState== LOW){
ButtonPower =0;
}
if (ButtonPower == 90){
ButtonPower =0;
}
//The button power counts up to 90 degrees and resets to 0 as long as the button is pressed
Serial.println(ButtonPower );
//if the button isnt pressed, nothing happens
if(ButtonPower == 0){
Servo1.write(90);
ledState3 = LOW;
ledState2 = LOW;
ledState1 = LOW;
digitalWrite(ledPin3, ledState3);
digitalWrite(ledPin2, ledState2);
digitalWrite(ledPin1, ledState1);
}
if (ButtonPower >0 && ButtonPower <15) {
// State 1
Servo1.write(120);
ledState3 = HIGH;
digitalWrite(ledPin3, ledState3);
}
if (ButtonPower >15 && ButtonPower < 50) {
Servo1.write(150);
ledState2 = HIGH;
digitalWrite(ledPin2, ledState2);
}
if (ButtonPower >50 && ButtonPower <75) {
Servo1.write(180);
ledState1 = HIGH;
digitalWrite(ledPin1, ledState1);
}
if (ButtonPower >= 75 && ButtonPower <= 90) {
// when buttonpower is higher than 75 but lower than 90, it starts to slowly move to 90 degrees again
Servo1.write (180-(ButtonPower-75)*6);
}
}
Soldering
After taking plenty of pictures of my breadboard and writing down where everything was supposed to go, I went ahead and started soldering. Since I used the YWRobot breadboard for it, I didn't need to connect anything at the bottom, and was able to copy the exact layout I made earlier.
One thing to note was that the pins of the button were to short and stubby to properly fit in the breadboard, so I soldered some cut of wire from the resistors to the pins which worked just fine.
Building the Arduino Housing
The first step is to place the 2 LEGO 16x6 plates (3027) next to eachother, and attach them using the 2x4, 3x2 and 2x1 bricks in various shades of grey. Place your Arduino Uno in the middle of these plates and secure is with the bricks, leaving space for the wires, USB connector and power port.
Place a couple of 8x1 bricks above the Arduino to place the breadboard on.
keep building upwards with lime bricks and keep a 4x2 hole for the servo motor.
Finally, conceal most of the breadboard with flat lime LEGO plates, leaving only the button and LEDS exposed.
For decorating you could use LEGO 1x1's with a stud on side (87087) to place LEGO 6x5 Plant leaves on, and put plants, the ladder and crate on the build.
Building the Golf Course
To make the Golf course, use 1 LEGO 10x20 base plate flat for the base.
Place around 32 LEGO1x4 lime flat tiles (2431), or other sizes of flat lime studs on the course.
On the side , place 4 LEGO 8x1 plate Lime (3460) with be placed with 2 LEGO 4x1 tile Yellow (35371) and 2 LEGO 8x1 tile Yellow (4162) on top to make an outline.
Place another LEGO 8x1 plate Lime (3460) in the back to place a minifigure on.
Make sure to add 1 LEGO 2x2 with groove and 1 stud in the middle, yellow (87580), so you can place a ball on it without rolling away.
Moving on to the goal, make it 10 studs wide and connect it to the course with 2 LEGO 1x6 plates Lime (3666).
Place a yellow tile where the goal will be.
Place a 2 LEGO 2x2 plates on the sides with a 2x2 smooth tile on top, and connect it to the middle goal using 4 LEGO 1x1 lime slopes (54200).
To add obstacles, use either LEGO 1x2 plates with a single, or 2 studs.
Wooden Housing Design
Here are some instructions if you want to make a wooden housing instead of working with LEGO.
first I make a design, which uses 2 9x9 cm boards for the front and back, and 3 9x12 boards for the sides and top. to fasten everything together, use 4 small slats in the corners.This housing is larger than the LEGO version, but the Arduino fits perfectly.
Sawing the Wood
I started with sawing, for which I used a back saw and a workbench. I made the sides first (9 cm x 12 cm, and 9 cm x 9 cm) but I recommend also making the roof (9 cm x 12 cm), the bottom (roughly 14.5 cm x 12.5 cm) and the golf course (9 cm x 18 cm).
Then I sanded down the planks,
and cut 4 2x2x8 wooden bars for the support.
Screwing the Base Together
Now that all the pieces are cut it's time to put it together.
First drill 4 holes in the 12x9 planks, leaving about 2 cm space from the top and bottom. then use the drill to screw these boards to the 2x2x8 bars.
Now drill the front and back to the bars, but make sure these screws have more or less than 2cm clearance from the top and bottom or they will hit the other screws. Also, the front and back must be loosely screwed so that they can be loosened to make holes in them later.
after this the bottom is screwed on, which can be done from the top.
Felt pads can be placed on the screws to prevent scratching.
Making It Arduino-proof
now it's time to mark where your arduino cable will go, and unscrew the back of your base.
With a jigsaw you can cut the hole and screw the back back onto your base. You repeat the same process for the front, where you servo sticks out of.
Then its time to screw your arduino to the baseplate. You do this by marking the holes onto your plate with a pen, drilling tiny holes and then screwing the screws in using tweezers.
Now you will create the support for your breadboard. You do this by taking a smaller beam and mounting it between the two rear beams. Then you can screw your breadboard to this bar.
For the top of the housing I first made a cardboard prototype. After cutting holes in it and making some iterations I was able to draw the position on the wood.
First you drill holes where you want them, and then put your fretsaw through the hole and close the fretsaw.
After putting everything back together your base is finished!
Decoration + Golf Course
the next step is to cover the sides of your base with popsicle sticks vertically, which you glue on with a gluegun. You can also place some of the popsicle sticks horizontally to cover up any gaps.
Glue the 9x18 cm board onto your base for the golf course and place some felt pads under it as well.
To make the golf club, you glue a couple of popsicle sticks together. I also used some cut up popsicle sticks to make a little U shape in which you can place the ball to sit still. Just make sure to sand it from the top so it doesnt block the golfclub when swinging.
Use some more popsicles to make a goal and the borders for your golf course.
The last step is decorating to your own preference. I went with a beach theme, for which I used a plastic straw for a shower, popsicles for a surfboard, styrofoam for an inflatable donut, sanding paper for a straw roof, and painted with a dry brush to get a worn of beach house vibe.
And you're done!