Blackjack

Overview

For our student project we decided to create a simple game of blackjack using the navigation switch (Digital Joystick), the uLCD, and a speaker for audio output. The navigation switch was used as a digital input to the mbed corresponding to the player deciding to hit (receiving another card) or stay. Cards were dealt at random then displayed on the uLCD. Both of the players cards are displayed face up and only one of the dealers cards are face up. The player is then asked if he would like to hit, pressing the joystick up, or stay, pressing the joystick down. After all player decisions are made the dealer must hit until he is over a value of 17 and must stay if he is dealt a value of 17 or more. The game continues until the player runs out of money.

/media/uploads/cmobley7/img_4511.jpg

Components

Hookup

mbeduLCD HeaderuLCD cable
5V=VU5V5V
GndGndGnd
TX=P28RXTX
RX=P27TXRX
P30ResetReset

500

Display Images

Paint.net was used to resize the original jpeg image to 128 by 128. The IDEs disk partition tool, RMPet, was used to create two partitions on the uSD card, one FAT and one unformatted (50/50 on a 2G uSD) . The graphics composer tool (from IDE) converted the image file and created the new image file on the unformatted partition on the SD card. This tool can also resize images and *.wmv videos for the display by selecting the file and clicking the "edit" button. It reported which sector address to use for the image (listed in project's *.GC file).

JPEG, BMP, and other encoded image files could also be stored on a filesystem on mbed such as the SD card, local filesystem, or a USB flash drive. It could be read, decoded, and sent to the display using the BLIT (BLock Image Transfer) command. A fairly complex program is required to decode image files and the RAM buffers needed for decoding use most of the available RAM on mbed, so not much is left for any other purpose such as networking or the RTOS. Information on a student project that ported simple open source JPEG and BMP file decoders to mbed for use on an earlier LCD display is available on the project’s notebook page.

/media/uploads/cmobley7/amplifier.jpg /media/uploads/cmobley7/speaker.jpg

mbedSpeakerAmplifier
5V=VU+5V
-C
mbedSparkfun Nav Switch Breakout
gnd-
P11D
P10V
Vout (3.3v) (Use Internal Pullups)+

Example Code

Import programBlackJack

Black Jack game using speaker sound, sd images, and joystick


Please log in to post comments.