Talkative Lego Card Dealer




Introduction: Talkative Lego Card Dealer


Most people play card games for entertainment value but they also provide several benefits to our emotional and mental health. It is one of the most popular indoor activities.

Most of the card games like Rummy and Poker needs a dealer. So here we are introducing our talkative lego card dealer. You can deal with the cards by simply speaking to it and it also provides the voice responses, just as those of the human dealers.

This is an awesome educational toy that can be built in the home with Alexa speaker and Lego Kit.

Step 1: Video

Let's watch the working, before getting into the making. Here the fun begins!

Step 2: Things We Need

Step 3: Building the Bricks

We are building the card dealer with the Lego Mindstorms ev3 31313 kit. For the sake of simplicity in building, the card dealer is made by assembling several blocks with several steps. We are making each block separately, and at last, we will combine it together. The interesting fact is that it needs only One Lego Mindstorms ev3 kit for building the whole.

You can check the catalog of Lego Mindstorms ev3 31313 here for getting knowledge about the bricks available in this kit. Then here comes the separate block making.

Step 4: Depot Making

This is the block where we store the cards, and also distributed from here.

Here I am using the Bridge Cards for making out the play. Bridge cards are one of two standard sizes of a playing card – the other being Poker cards. Bridge cards measure 3.5 inches tall and 2.25 inches wide (88.9mm x 56mm).This is slightly narrower than Poker cards which measure 3.5 inches by 2.5 inches (88.9mm x63.5mm).

You can adjust the depot size according to the card type, whether it is poker or bridge cards by simply adding up or removing this brick(4142135).

The medium motor is attached to the Depot for distributing cards. Then the first block is over. Then we can go to the second one.

Step 5: Rotating Platform

The Depot that made above is attached to the Rotating platform so the cards can easily be distributed for the players by the rotating platform through the concerning angles. This is also attached to the Large Motor for rotations. The image above shows the connectors in which Depot is connecting to.

There is also an axle in the rotating platform for the connection with the Large Motor as shown above.

So the second block is over. Let's get into the next one.

Step 6: RotorBlock

Here in this block, we are attaching the Medium Motor with the Intelligent Ev3 brick. This section forms the brain of the card dealer.

When the platform rotates, we need to balance the Large Motor side, otherwise, it will lead to improper rotations. So we are using the rubber wheels purposefully. This section doesn't move(Stationary part). Then we can head over to the next section.

Step 7: Medium MotorSection

The EV3 Medium Servo Motor is great for lower-load, higher speed applications and when faster response times and a smaller profile are needed, that's why I choose the medium motor here, also we all know that it is less weighing than the large motor. So it reduces the whole weight of the rotating platform to a great extent which will probably lead to the smooth movement of the platform.

This motor is used for distributing the cards for the players. It is connected with the depot.

The Wedge-Belt-Wheel and the tire is the key part of this section, because it is pushing out the card from the depot. We used three here, for faster movements. I think, in the instruction for making this block. You can't find the rubber tire with the wheel(because the part 602841 is missing in lego designer studio). So don't forget to attach the tire with the wheel.

Step 8: Slottedweight Block

This block is connected with the depot. These are used for the giving weight for the cards, placed in the depot. So the underneath card will be easily swiped out from the depot. When a card is swiped out the weight will automatically come down by the gravity.

The hinging mechanism is paving the way for weight slots to move up and down. (Refer picture above)

Step 9: Assembly

Here we are assembling the whole blocks that we have built before. It is actually pretty simple.

First, we can connect the Slotted Weight Block with the Depot. Now it constitutes the Depot.

Then we can connect the Depot with the Rotating Platform. As you can see the Depot isn't aligned straight with the platform(front section is raised to certain angles).There is some logic behind it. By this configuration, it will distribute only one card at a time. Suppose when we are aligning it straight, it will lead to improper distribution of cards. Then this platform is attached with the Rotator Block(Large Motor Section).

The brick building is over. Here I provided images of assembly because it is very easy to visualize the situations than the normal instructions. Then we can head over to the wiring of ev3 brick to motors.

Note: Build instructions for the each block are attached in the GitHub repo as PDF

Step 10: Wiring

Here actual hardware comprises one medium and large motor and also one ev3 brick. The motors should be connected to any of the ports(A, B, C, D) of the ev3 brick for proper working. Connections are made using the cables which are coming in the kit. As you can see in the kit, the same type of cable is available in three different lengths. We are using

1 X 50 cm cable for medium motor 1 X 25 cm cable for large motor As you can see the medium motor needs lengthy cables to make out at least a 360-degree rotation. That's why I am using the 50 cm cable for that, otherwise, it halts the movement of the platform. For the Large motor, the 25 cm cable is enough.

The connections are
Port A ----> Medium Motor

Port B -----> Large Motor

The wiring has just finished. Let's get into the software part.

Step 11: SettingUp

Setting up the device is very easy.

  • Install ev3dev for programming your EV3 Brick
  • Install Visual Studio Code for editing code
  • Install Alexa Gadgets Python Software on your EV3 Brick

When you downloaded the ev3 software, you need to flash it to an SD card. I prefer Class 10 SD cards. For the flashing, we use Etcher or Rufus. For booting up you need to put the SD card into the brick. For putting up SD card bare hands are enough but when you are removing I will prefer Tweezers.

So for the ev3 brick, it needs 6 x AA battery having each one 1.5V. I prefer rechargeable batteries having high energy storage capacity(high mah). Higher the mAh rating of a battery, the longer the battery will last. mAH is a unit of electric charge. For this project, I am using Panasonic Eneloop rechargeable battery having capacity up to 2550 mah.

Then boot up the ev3 brick by a long press on the center button.

If you have no idea about the basics of ev3 brick just go here. Then you must connect the ev3 brick to the internet by sharing your computer internet connectivity. For connecting to the computer there are different methods, here I am using the USB cable which is coming with the kit itself. I think it is an easy method. Have a look here for connecting to the Internet via USB. These are the other ways of networking.

It will recommend extensions that make it easy to connect to and program your EV3 Brick. As you can see when you download the file and open with the visual studio code editor it will automatically recommend the extensions. So install the ev3dev-browser extension shown up. If you have Python installed on your computer, you can install that extension too. (Don't install it if you don't have Python already installed.) Python is the language used here for the programming.

Step 12: Registering EV3 Brick As Alexa Gadget

In order for your EV3 Brick to work with Alexa and your Echo device as an Alexa Gadget, you will need to register your gadget in the Alexa Developer Console. Registering your gadget ties your unique gadget to your account, and is required in order for your creation to work properly with Alexa. An Alexa Gadget is an Alexa connected accessory that interacts with compatible Amazon Echo devices over Bluetooth.

Amazon ID and Alexa Gadget Secret should be noted up, because it uniquely identifies our gadget. The above figure shows how a gadget interacts with an Echo device, and where the Alexa Gadgets interfaces fit in.

When you've successfully registered your Alexa Gadget. Let's prepare the ev3 brick

Step 13: Preparing Ev3 Brick

Your EV3 Brick will be connecting to your Echo device using Bluetooth, which you'll need to enable on your Brick in order for the sample code to work correctly. Once Bluetooth is enabled, you’re ready to work with some code!

At this point, you can switch over to the Visual Code Workspace you created during the setup instructions. The Explorer panel should display the mission folders that are on your computer.

Step 14: Registration and Settings

Within the carddealer folder, you will see an INI file and a Python file. Open up the carddealer.ini file, which includes the following configuration details:



alexaGadgetSecret = YOUR_GADGET_SECRET


Alexa.Gadget.StateListener = 1.0 - wakeword

The INI (or initialization) file defines parameters for how your EV3 Brick should work as a gadget.
Gadget Settings: Specifies the Amazon ID and Alexa Gadget Secret that you received when you created your gadget in the Amazon Developer Console. It authenticates your EV3 Brick and allows it to connect to your Echo device and Alexa.

Step 15: How to Set Up Echo Dot?

Before setup, download or update the Alexa app in your mobile device's app store.

  • Open the Alexa app
  • Go to the settings menu
  • Select Add Device.
  • Select Amazon Echo, and then Echo Dot
  • Plugin your device
  • Follow the instructions to set up your device

Step 16: Pairing Echo With Brick

In order to work with the Alexa, the EV3 Brick needs to establish a Bluetooth connection with the Echo device.

The Echo device and the gadget discover each other over Classic Bluetooth as follows:

  • The user puts the gadget into pairing mode. This procedure depends on the gadget. For example, a button gadget might use a long press. If your gadget has a touchscreen, a user could enable pairing through an option on the screen.
  • The user puts the Echo device into pairing mode. For Echo devices without a screen, a user can put an Echo device into pairing mode by using the Amazon Alexa app. In the Alexa app, the user goes to Settings, selects the Echo device, and then selects Pair Alexa Gadget under Connected Devices. If the Echo device has a screen, the user follows on-screen instructions to initiate pairing. (screenshots are given for reference)
  • Just click on the "pair a new device", please be patient it will take some time. Here I am using the echo dot 3rd generation.

Step 17: Create Your Alexa Skill

Let’s walk through the steps of creating your Skill:

1. Sign in to
2. In the top header, hover over Alexa, and click on Alexa Skills Kit.

3. In the upper-right of the screen, click on Create Skill.

4.Enter a Skill Name, maybe “CARDDEALERS”. The name you give your Skill will also be the way you open the Skill. For example, “Alexa, open carddealers”.

5.Select your default language. Make sure the language select matches the language used on your Echo device.

6.Select Custom for the “Choose a model to add to your skill” option.

7.Select Alexa-Hosted for the “Choose a method to host your skill's backend resources” option.

8.Click Create skill in the upper-right.

9.Once you click Create skill, you will see a modal while your skill is being prepared to be customized.

Then we need to Enable the Custom Interface Controller in the console. That’s it! With Custom Interface Controller toggled on, you can write code that sends custom directives to your EV3 Brick and program how you want it to react.

Step 18: Define the Skill Interaction Model

The Skill Interaction Model defines how you can speak to your skill, and what kind of commands it can expect to respond to. The interaction model includes intents, slots, sample utterances that you define, and program against in your skill’s code

1. In the Alexa Developer Console, under Interaction Model, click on JSON Editor.

2. In the carddealer folder, you will see a folder called skill-nodejs. Within that folder, there is a model.json file. Copy the interaction model JSON from that file, and paste it into the editor, or drag and drop the JSON file onto the drop zone to upload it.

After pasting the JSON into the Alexa skill JSON Editor, click Save Model, and then Build Model presented at the top of the console interface. It may take some time for the model to build, so be patient

Step 19: Implementing the Skill Logic

There’s a lot to learn about creating skills, but for the purpose of this mission, we’ll guide you through using the Alexa-Hosted skill option you selected earlier, and share additional resources at the end. With an Alexa-Hosted skill, you can start writing code for your skill directly in the Alexa Developer Console.

1. Click on Code in the top navigation bar of the Alexa Developer Console.

2. In VS Code, open the index.js file in the carddealer/skill-nodejs/lambda folder.

3. Copy the code in the index.js file into the index.js file in the Alexa Developer Console Code Editor.

4. Copy the contents of the package.json and util.js files to the respective files in the Alexa Skill Code Editor.

5. Create a new file by clicking the New File icon in the upper-left of the Code Editor, and fill in the path and file name as /lambda/common.js

6. With the common.js file created, make sure the file is open, and then copy the code in the common.js file from the carddealer/skill-nodejs/ folder in VS Code to the common.js file in the Alexa Skill Code Editor.

You can test the skill by deploying it. When you are testing the skill then switch the testing from Off to Development using the dropdown under the navigation bar.

Step 20: Python Code

The Python code above sets up the motors connected to the EV3 Brick and tells EV3RSTORM, how to move when it receives commands from the Alexa skill, including:

  • The cards will be distributed by the combined rotations of large and medium motors in the specified direction.
  • The cards will be given away by the rotations of the medium motor only

The entire code is given in the GitHub Repo.

The project is ready, just shuffle the cards and place in the depot and enjoy the game!

Toys and Games Challenge

Runner Up in the
Toys and Games Challenge

Be the First to Share


    • Fabric Challenge

      Fabric Challenge
    • Build a Tool Contest

      Build a Tool Contest
    • Meatless Challenge

      Meatless Challenge



    1 year ago

    You can watch Lego Lau Mo on Youtube. He has another version of your card dealer. Both are great! Thus, he has some really good models!!!

    Hey Jude
    Hey Jude

    2 years ago

    Really cool project - I can see this as a great foundation to other projects - so thanks for sharing! That said, deadling 'from the bottom' might get your Bot kicked outta the casino xD


    Reply 2 years ago

    Thanks for your concerns!