Pages: [1]   Go Down
Author Topic: Requesting help with Blackjack counter.  (Read 990 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay so I designed a device to help a user count cards in Blackjack. The idea is to have a nano board wired with a tactile switch in each shoe and servo strapped to each leg. User can click left shoe for low card, right shoe for high card, code evaluates and servos notify user to bet soft or hard.
I have wired a prototype and strung some code together, I am new to the C language and Arduino as a whole, this is my first major project. I can't seem to figure out why my code wont work. Hopefully I commented it well enough for you understand what I'm trying to make my sketch do.
I'm open to all input, chop my code up, rewrite it entirely, whatever. All I ask is that it's well commented so I can understand whats going on. Still learning C you see.
So here is what I came up with so far.
Code:
//My card counter
 
#include <Servo.h> ;
int Left_Button = 2 ;             // Left button on pin 2
int Right_Button = 3 ;           // Left button on pin 3

//Here I want declare the starting values for up to ten decks. I'm going with the standard +/- system for counting.
//To keep the device from telling me to bet to hard to often I took a conservative angle and flagged cards 2-9 as low
// and 10,J,Q,K,A as high from which I got the formula (-32) + 20 = -12/Deck.
char Shoe_Value(-12 -24 -36 -48 -60 -72 -84 -96 -108 -120) ;

Servo Left_Servo, Right_Servo ;                             // Create Servo objects
Left_Servo.attach(4) ;                                            // Servo on pin 4
Right_Servo.attach(5) ;                                          // Servo on pin 5
void setup() {
    pinMode(Left_Button, INPUT) ;                           // Left button as input
    pinMode(Right_Button, INPUT) ;                         // Right button as input
}
void loop() {
    int Initial_Shoe_Value 0 ;                                             // Create initial shoe value
    int Deck_Count 0 ;                                                      // Create Deck count
    int Card_Count 0 ;                                                      // Create card count
    int Left_Button_State = digitalRead(Left_Button) ;        // Create left button state
    int Right_Button_State = digitalRead(Right_Button) ;    // Create right button state
    Left_Servo.write(180) ;                                               // Set both servos to touch the user to notify that decks are not configured
    Right_Servo.write(180) ;                                             // Set both servos to touch the user to notify that decks are not configured
    while (Left_Button_State == LOW) {                           // Configure # of decks right button = +1 left button = move along
        if (Right_Button_State == HIGH) {
            Deck_Count = Deck_Count + 1 ;                         // Deck count +1
        }
    }
    switch(Deck_Count) {                                                 // Use switch to set card count and initial deck value
        case 1:
          Initial_Shoe_Value = Shoe_Value[0] ;
          Card_Count = Shoe_Value[0] ;
        case 2:
          Initial_Shoe_Value = Shoe_Value[1] ;
          Card_Count = Shoe_Value[1] ;
        case 3:
          Initial_Shoe_Value = Shoe_Value[2] ;
          Card_Count = Shoe_Value[2] ;
        case 4:
          Initial_Shoe_Value = Shoe_Value[3] ;
          Card_Count = Shoe_Value[3] ;
        case 5:
          Initial_Shoe_Value = Shoe_Value[4] ;
          Card_Count = Shoe_Value[4] ;
        case 6:
          Initial_Shoe_Value = Shoe_Value[5] ;
          Card_Count = Shoe_Value[5] ;
        case 7:
          Initial_Shoe_Value = Shoe_Value[6] ;
          Card_Count = Shoe_Value[6] ;
        case 8:
          Initial_Shoe_Value = Shoe_Value[7] ;
          Card_Count = Shoe_Value[7] ;
        case 9:  
          Initial_Shoe_Value = Shoe_Value[8] ;
          Card_Count = Shoe_Value[8] ;
        case 10:
          Initial_Shoe_Value = Shoe_Value[9] ;
          Card_Count = Shoe_Value[9] ;
    }
    Left_Servo.write(90)                                                                           // Set both servos back to home position
    Right_Servo.write(90)                                                                         // Set both servos back to home position
    Game_On() ;                                                                                       // Call the Game_On function
  }

void Game_On() {
    if (Left_Button_State == HIGH && (Right_Button_State == HIGH)) {     // call Dealer_Reshuffle() function if both buttons are pressed at the same time
        Dealer_Reshuffle() ;
    }
    if (Left_Button_State == HIGH) {                                                        // Add + 1 to card count if left button is pressed
        Card_Count = Card_Count + 1 ;
    }
    if (Right_Button_State == HIGH) {                                                     // Add - 1 to card count if left button was pressed
        Card_Count = Card_Count - 1 ;
    }
    if (Card_Count == >0) {                                                                    // If card cound = more then 0 call the Bet_Hard() function
        Bet_Hard() ;
    }
    if (Card_Count == <0) {                                                                   // if card count = less then 0 call Bet_Soft() function
        Bet_Soft() ;
    }
    continue ;                                                                                         // Back to top of Game_On() function
    
}

void Bet_Hard() {                                                                                 // notify user to bet hard
    Right_Servo.write(180) ;  
    Left_Servo.write(90) ;
    Game_On() ;                                                                                    // Back to top of Game_On() function
}

void Bet_Soft() {                                                        // notify user to bet soft
    Right_Servo.write(90) ;
    Left_Servo.write(180) ;
    Game_On() ;                                                          // Back to top of Game_On() function
}

void Dealer_Reshuffle() {                                                // Set servos back to home position and restart the card count
  Left_Servo.write(90) ;
  Right_Servo.write(90) ;
  Card_Count == Initial_Deck_Value ;                        // Reset card count
  Game_On() ;                                                            // Back to top of Game_On() function
}            
Also another problem that I have is with servo noise. Anyone who has ever worked with a servo knows about the audable "dzzzt" "dzzzt" that most servos make....
Naturally this would be problematic in a casino. I wired up a servo to a potentometer and notice that the servos hardly make any noise when the move "slowly".
I'm sure there is probably a way to control servo speed with code that I haven't figured out, any help in this department would be greatly appreciated.
That's pretty much what I'm working on right now. I have a diagram I made in fritzing I hope it uploads.
Thanks in advance


* Card_Counter_bb.jpg (905.44 KB, 2679x1140 - viewed 38 times.)
« Last Edit: February 18, 2013, 07:35:26 pm by Kevlar1982 » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 203
Posts: 8720
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want Shoe_Value to be an initialized array, try:

Code:
char Shoe_Value[] = {-12, -24, -36, -48, -60, -72, -84, -96, -108, -120};
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
God Member
*****
Karma: 17
Posts: 723
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You know what happens if they catch you with that right?
Logged

Croatia
Offline Offline
Sr. Member
****
Karma: 11
Posts: 445
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You know what happens if they catch you with that right?
A dark alley?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You know what happens if they catch you with that right?

Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have lived in Las Vegas and will be retiring there next year.  I have counted cards and was even asked to leave a casino -- although not trespassed. I also worked for two and a half years as a casino employee -- admittedly in marketing, but interacted with security almost daily.

That being said, here's my honest advice:

The use of an electronic device to aid in the play of any casino game is a felony.

There are sensors in many of the casinos that scan for the EM signature of home-brew devices such as the nano. You will need to heavily shield your device to avoid disaster.

The use of pager vibration motors can give you the feedback you desire without the problems of a servo.

There is no need to complicate your design by using both shoes.  You can count up and down with buttons in the same shoe.  One under the big toe and one one the side of the foot, for instance.

You can purchase a pair of "elevator" shoes which would give you lots of space for the nano and batteries.

These things can get hot.  Allow for this as you design.

A simple up/down counter implies a simple one-level (all cards have a value of +1, -1, or 0) count. If you're going to use an illegal aid, at least optimize it to the more advanced multi-level counts.

Card counting, while appearing to be daunting at first blush, isn't really that hard.  I understand the lure of using technology but if your goal is to make money, you might just be more profitable using a single-level count like Synder's Red Sevens.  There are plenty of others, but the advantages are in the 1/10ths of a percent.

Know that the casinos are not idly sitting around while armies of counters take their money.  They have instituted "no mid-deck entry" to cancel "Wonging" a deck (worth the Google search).  They also now have computer systems that automatically keep the count and identify who is varying their bets according to the count.

An expert (electronic or mental) card counter finds it hard to make much headway with the casinos' counter-measures.  There are WWW sites that are dedicated to countering the countering.

But, I digress.

Be sure that you risk being trespassed at a casino that you don't want to later visit.  I play tournament poker and would be foolish to count at a casino that hosts large poker tourneys, for instance.

Last thing: The casinos have found that so many clients carry a cell phone, they ignore the EM signatures of these devices. So maybe your best bet (pun intended) would be to use an Android or iPhone in your shirt pocket and a modified Bluetooth keyboard in your shoe.
Logged

Pages: [1]   Go Up
Jump to: