Microcontrollers and stuff A blog by Derk Vedelaar


JY-MCU 3208 Game of life arduino code

I finally took the effort to make my game of life code arduino compatible. I can now run the game of life on an arduino and use the displays just as displays. You still need to uplaod empty code to the onboard avr or completely desolder it though.

I simply updated the code on the old place. After getting the code the arduino stuff is in the "arduino" folder. If you want to upload an empty project to your boards you can find an example in the "empty" folder.

There are 2 libraries which you can simply copy to your arduinos library folder. I would like to invite you to read the public functions in the header files in the source code (libraries/gameoflife/src/gameoflife.h and libraries/ht1632c/src/ht1632c.h). The comments will tell you pretty well what the functions will do.

I also copied them here for reference:

The game of life available functions:

// Constructor, width in bytes (6 = 48 pixels) height in pixels
gameoflife(uint8_t w, uint8_t h);

// This is the field that contains the current display data
// works similar to field[width][height]
uint8_t** field;

// Fill the field with random data
void randomfield(uint16_t seed);
// Calculate next generation
void step();
// Count all the cells in the current field
uint8_t countcells();
// Returns true if nothing interesting is happening anymore in the field
// Generations is the amount of generations that are watched for changes
bool is_dead(uint8_t generations);


The HT1632C available functions:

//Constructor, enter the ports and pins of your display configuration
ht1632c (
volatile uint8_t* const cs_ddr, 
volatile uint8_t* const cs_port, 
const    uint8_t         cs_pin, 
volatile uint8_t* const wr_ddr, 
volatile uint8_t* const wr_port, 
const    uint8_t         wr_pin, 
volatile uint8_t* const data_ddr, 
volatile uint8_t* const data_port, 
const    uint8_t         data_pin);
//Pins to output and initialize HT1632C
void start(void);
//Turn off HT1632C
void stop(void);
//Blink all the leds every quarter a second
void start_blink(void);
//Stop blinking
void stop_blink(void);
//Set the brightness of the display. Possible values: 0..15
void set_brightness(const uint8_t brightness);
//Setting for how your display's are connected. Possible values: 0..3
void set_com_option(const uint8_t option);
//Start sending data to the display. Give the address where you want to start sending
void begin_sent_data(const uint8_t address = 0);
//Sent data to the display. Every time called the next row will be sent to the display
void sent_data(const uint8_t byte);
//Finish sending data
void finish_sent_data();

Posted by Derk

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.