So, I decided that its enough for my young brother and sister wasting their money in the stupid malls games and will make my home game arena!
Luckily I had an old computer table which was about to be thrown, the 15mm wood will help a lot to make strong bases. (Kids games needs to be 10x military ratings)
Starting with a simple one, Sparkfun Simon game in a big scale, basically I'll buy their kit replacing the switches with big domes
I started today with the base, can't continue as I have only one dome push button
First, I took dimensions of available wood real-estate and choose the appropriate part, its a 30*48 cm surface with about half meter height
face is shown below, dimensions in mm
then I proceeded to cutting with jigsaw and drilling, added duct tape on the edges and the result:
void ShiftData (uint8_t Data)
{
//[ld,d,rd,dot,ru,u,lu,m]
uint8_t SSArray[]={
0,0,0,1,0,0,0,1, //0
1,1,0,1,0,1,1,1, //1
0,0,1,1,0,0,1,0, //2
1,0,0,1,0,0,1,0, //3
1,1,0,1,0,1,0,0, //4
1,0,0,1,1,0,0,0, //5
0,0,0,1,1,0,0,0, //6
1,1,0,1,0,0,1,1, //7
0,0,0,1,0,0,0,0, //8
1,0,0,1,0,0,0,0 //9
};
CLEARBIT(ControlPort,RCLK_Pin);
for (uint8_t i=0; i<8; i++)
{
if (SSArray[8*Data+i]==0) CLEARBIT(ControlPort,Data_Pin);
else SETBIT(ControlPort,Data_Pin);
SETBIT(ControlPort,SRCLK_Pin);
CLEARBIT(ControlPort,SRCLK_Pin);
}
SETBIT(ControlPort,RCLK_Pin);
}
void DisplayDigit(uint8_t HighDigit, uint8_t LowDigit)
{
// Send data starting with HIGH Digit
ShiftData(HighDigit);
ShiftData(LowDigit);
}
void DisplayNumber(uint8_t Number)
{
if ((Number>=0) && (Number<10))
{
DisplayDigit(0,Number);
}
else if ((Number>9) && (Number<100))
{
DisplayDigit(Number/10,Number%10);
}
else
DisplayNumber(0);
}
Then modified the "game_mode()" function as below
Luckily I had an old computer table which was about to be thrown, the 15mm wood will help a lot to make strong bases. (Kids games needs to be 10x military ratings)
Starting with a simple one, Sparkfun Simon game in a big scale, basically I'll buy their kit replacing the switches with big domes
I started today with the base, can't continue as I have only one dome push button
First, I took dimensions of available wood real-estate and choose the appropriate part, its a 30*48 cm surface with about half meter height
face is shown below, dimensions in mm
then I proceeded to cutting with jigsaw and drilling, added duct tape on the edges and the result:
To be continued ... after getting Simon kit and Dome Push buttons
Finally, got them, oh and Sparkfun did an awesome job by replacing bulb with LED so I don't need to waste time modifying it :)
Then I decided to display current level, I modified the code as following:
Added definitions:
#define ControlPort PORTC
#define RCLK_Pin PINC0
#define SRCLK_Pin PINC1
#define Data_Pin PINC2
#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))
void ShiftData (uint8_t Data);
void DisplayDigit(uint8_t HighDigit, uint8_t LowDigit);
void DisplayNumber(uint8_t Number);
and added the function below at bottom of code (I wrote function my self, got the CLK concept from bildr)
void ShiftData (uint8_t Data)
{
//[ld,d,rd,dot,ru,u,lu,m]
uint8_t SSArray[]={
0,0,0,1,0,0,0,1, //0
1,1,0,1,0,1,1,1, //1
0,0,1,1,0,0,1,0, //2
1,0,0,1,0,0,1,0, //3
1,1,0,1,0,1,0,0, //4
1,0,0,1,1,0,0,0, //5
0,0,0,1,1,0,0,0, //6
1,1,0,1,0,0,1,1, //7
0,0,0,1,0,0,0,0, //8
1,0,0,1,0,0,0,0 //9
};
CLEARBIT(ControlPort,RCLK_Pin);
for (uint8_t i=0; i<8; i++)
{
if (SSArray[8*Data+i]==0) CLEARBIT(ControlPort,Data_Pin);
else SETBIT(ControlPort,Data_Pin);
SETBIT(ControlPort,SRCLK_Pin);
CLEARBIT(ControlPort,SRCLK_Pin);
}
SETBIT(ControlPort,RCLK_Pin);
}
void DisplayDigit(uint8_t HighDigit, uint8_t LowDigit)
{
// Send data starting with HIGH Digit
ShiftData(HighDigit);
ShiftData(LowDigit);
}
void DisplayNumber(uint8_t Number)
{
if ((Number>=0) && (Number<10))
{
DisplayDigit(0,Number);
}
else if ((Number>9) && (Number<100))
{
DisplayDigit(Number/10,Number%10);
}
else
DisplayNumber(0);
}
Then modified the "game_mode()" function as below
static int game_mode(void)
{
nmoves = 0;
while (nmoves < MOVES_TO_WIN) {
DisplayNumber(nmoves+1);
uint8_t move;
/* Add a button to the current moves, then play them back */
add_to_moves();
play_moves();
/* Then require the player to repeat the sequence. */
for (move = 0; move < nmoves; move++) {
uint8_t choice = wait_for_button();
/* If wait timed out, player loses. */
if (choice == 0)
return 0;
toner(choice, 150);
/* If the choice is incorect, player loses. */
if (choice != moves[move]) {
return 0;
}
}
/* Player was correct, delay before playing moves */
delay_ms(1000);
}
/* player wins */
return 1;
}
On the hardware side, I've connected the two seven segment displays with two 8Bit Shift Registers as on the bildr example, pinout from arduino tutorial
result:
and after fixing the segment on place:
and turning power ON
Done! :D
No comments:
Post a Comment