Color Roulette

Hee Gus,

Is this what you folks name, freaking easy …

:stuck_out_tongue: :dance: :clap:

seriously looking sweet as - you guys rock

Hahaha, wow, it looks great! Can’t wait for video!

Ready…here is a video

WARNING: you may get too excited and buy a LOT of LEDs to make your own! I would say just buy a bag of 100, you will use them all :slight_smile:

Have fun…

[url]- YouTube

Cool looks good.

Very nice video, Gus. The project looks great and so does the new LCD component! My eyes went :o when you flipped the chassis over to expose all of Robert’s handwork. Holy crap Robert, you must have the patience of a saint to do that!

Haha chris, you could say that.

but nothing a marathon of family guy while soldering wont solve :wink:

This just keep getting better and better. I added large font the graphical display driver. We now have 3 font sizes. The large one look awesome!

Take a look :slight_smile:

I just finished coding it. There are many games that you can make using the same hardware but I chose this.

  1. LED spins continuously
  2. when a user presses a button on a blue LED, they get 30 points, and 50 point for yellow
  3. When a pleaser reaches 500, they win
  4. when someone wins, you hear some sounds and the LEDs blink randomly
  5. I also added something so it is changing the speed every 5 seconds. Changing speed will guarantee that you will not master the game

Here is the code and I will get you some video later


using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.Graphics.Simple128x64;

public class Program
{
    // Get IO40 ready, we have 2 of them
    static I2CDevice I2C = new I2CDevice(null);
    static FEZ_Components.IO40 IO40_1 = new FEZ_Components.IO40(I2C, 0);
    static FEZ_Components.IO40 IO40_2 = new FEZ_Components.IO40(I2C, 1);

    public static void SetLED(Int64 led)
    {
        IO40_1.WritePort(0, (byte)led);
        IO40_1.WritePort(1, (byte)(led >> (8 * 1)));
        IO40_1.WritePort(2, (byte)(led >> (8 * 2)));
        IO40_1.WritePort(3, (byte)(led >> (8 * 3)));
        IO40_1.WritePort(4, (byte)(led >> (8 * 4)));
        IO40_2.WritePort(0, (byte)(led >> (8 * 5)));
    }
    public static void Main()
    {

        Random rnd = new Random();
        // to make some sounds
        PWM speaker = new PWM(PWM.Pin.PWM5);
        // init the display
        FEZ_Extensions.Large128x64Display.Initialize(FEZ_Pin.Digital.Di9, FEZ_Pin.Digital.Di8,
        FEZ_Pin.Digital.Di10, SPI.SPI_module.SPI1);
        GPainter paint = new GPainter();
        paint.Clear();
        FEZ_Extensions.Large128x64Display.Flush(paint.vram);
        // blink onboard LED
        FEZ_Components.LED onBoardLED = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
        onBoardLED.StartBlinking(50, 200);
        // all outputs
        IO40_1.SetPortInputs(0, 0);
        IO40_1.SetPortInputs(1, 0);
        IO40_1.SetPortInputs(2, 0);
        IO40_1.SetPortInputs(3, 0);
        IO40_1.SetPortInputs(4, 0);
        IO40_2.SetPortInputs(0, 0);
        // the large buttons
        InputPort[] btn = new InputPort[4];
        btn[0] = new InputPort((Cpu.Pin)FEZ_Pin.Interrupt.An0, true, Port.ResistorMode.PullUp);
        btn[1] = new InputPort((Cpu.Pin)FEZ_Pin.Interrupt.An1, true, Port.ResistorMode.PullUp);
        btn[2] = new InputPort((Cpu.Pin)FEZ_Pin.Interrupt.An2, true, Port.ResistorMode.PullUp);
        btn[3] = new InputPort((Cpu.Pin)FEZ_Pin.Interrupt.An3, true, Port.ResistorMode.PullUp);

        Int64 led_rotate = 1;
        Int64[] player_led = new Int64[4];
        int[] player_score = new int[4];

        const Int64 led_yellow1 = ((Int64)1 << (12 * 0));
        const Int64 led_yellow2 = ((Int64)1 << (12 * 1));
        const Int64 led_yellow3 = ((Int64)1 << (12 * 2));
        const Int64 led_yellow4 = ((Int64)1 << (12 * 3));

        const Int64 led_blue1 = ((Int64)1 << (12 * 0) + 6);
        const Int64 led_blue2 = ((Int64)1 << (12 * 1) + 6);
        const Int64 led_blue3 = ((Int64)1 << (12 * 2) + 6);
        const Int64 led_blue4 = ((Int64)1 << (12 * 3) + 6);

        const int winning_score = 500;
        const int yellow_score = 50;
        const int blue_score = 30;
        paint.Clear();
        // horizontal line
        paint.Line(0, 22, 128, 22);
        paint.Line(0, 23, 128, 23);
        //vertical line
        paint.Line(63, 0, 63, 44);
        paint.Line(64, 0, 64, 44);
        //rect
        paint.RectSE(0, 0, 127, 44);
        paint.RectSE(1, 1, 126, 45);

        FEZ_Extensions.Large128x64Display.Flush(paint.vram);
        FEZ_Extensions.Large128x64Display.Print(12, 7, "www.TinyCLR.com");

        FEZ_Extensions.Large128x64Display.Print(4, 4, "P1: " + player_score[0].ToString() + "  ");
        FEZ_Extensions.Large128x64Display.Print(4, 1, "P2: " + player_score[1].ToString() + "  ");
        FEZ_Extensions.Large128x64Display.Print(70, 1, "P3: " + player_score[2].ToString() + "  ");
        FEZ_Extensions.Large128x64Display.Print(70, 4, "P4: " + player_score[3].ToString() + "  ");
        int spin_delay = 10;
        long last_tick = DateTime.Now.Ticks;
        while (true)
        {
            for (int p = 0; p < 4; p++)
            {
                if (led_rotate == player_led[p])
                    player_led[p] = 0;
            }
            SetLED(led_rotate | player_led[0] | player_led[1] | player_led[2] | player_led[3]);
            for (int p = 0; p < 4; p++)
            {
                if (player_led[p] == 0)
                {
                    if (btn[p].Read() == false)
                    {
                        speaker.Set(2000, 50);
                        player_led[p] = led_rotate;
                        bool do_print = false;
                        switch (player_led[p])
                        {
                            case led_yellow1:
                            case led_yellow2:
                            case led_yellow3:
                            case led_yellow4:
                                player_score[p] += yellow_score;
                                do_print = true;

                                break;
                            case led_blue1:
                            case led_blue2:
                            case led_blue3:
                            case led_blue4:
                                player_score[p] += blue_score;
                                do_print = true;
                                break;
                        }
                        if (do_print)
                        {
                            FEZ_Extensions.Large128x64Display.Print(4, 4, "P1: " + player_score[0].ToString() + "  ");
                            FEZ_Extensions.Large128x64Display.Print(4, 1, "P2: " + player_score[1].ToString() + "  ");
                            FEZ_Extensions.Large128x64Display.Print(70, 1, "P3: " + player_score[2].ToString() + "  ");
                            FEZ_Extensions.Large128x64Display.Print(70, 4, "P4: " + player_score[3].ToString() + "  ");
                            do_print = false;
                            if (player_score[p] >= winning_score)
                            {
                                //we have a finner
                                paint.Clear();
                                paint.PrintLarge(30, 5, "Player " + (p + 1).ToString());
                                paint.PrintLarge(40, 30, "Wins!");
                                FEZ_Extensions.Large128x64Display.Flush(paint.vram);
                                FEZ_Extensions.Large128x64Display.Print(15, 7, "Press any button!");
                                int frequ = 2000;
                                while (btn[0].Read() == true && btn[1].Read() == true && btn[2].Read() == true && btn[3].Read() == true)
                                {
                                    frequ += 200;
                                    if (frequ > 4000)
                                        frequ = 2000;
                                    speaker.Set(frequ, 50);
                                    SetLED(rnd.Next() | ((Int64)rnd.Next() << 32));
                                    Thread.Sleep(50);
                                }
                                //reset everything
                                spin_delay = 10;
                                speaker.Set(false);
                                player_score[0] = player_score[1] = player_score[2] = player_score[3] = 0;
                                player_led[0] = player_led[1] = player_led[2] = player_led[3] = 0;
                                paint.Clear();
                                // horizontal line
                                paint.Line(0, 22, 128, 22);
                                paint.Line(0, 23, 128, 23);
                                //vertical line
                                paint.Line(63, 0, 63, 44);
                                paint.Line(64, 0, 64, 44);
                                //rect
                                paint.RectSE(0, 0, 127, 44);
                                paint.RectSE(1, 1, 126, 45);

                                FEZ_Extensions.Large128x64Display.Flush(paint.vram);
                                FEZ_Extensions.Large128x64Display.Print(12, 7, "www.TinyCLR.com");

                                FEZ_Extensions.Large128x64Display.Print(4, 4, "P1: " + player_score[0].ToString() + "  ");
                                FEZ_Extensions.Large128x64Display.Print(4, 1, "P2: " + player_score[1].ToString() + "  ");
                                FEZ_Extensions.Large128x64Display.Print(70, 1, "P3: " + player_score[2].ToString() + "  ");
                                FEZ_Extensions.Large128x64Display.Print(70, 4, "P4: " + player_score[3].ToString() + "  ");


                            }
                        }
                    }
                }
            }
            led_rotate <<= 1;
            if (led_rotate == ((Int64)1 << 48))
                led_rotate = 1;
            speaker.Set(false);
            //make it easier every 5 seconds
            if (DateTime.Now.Ticks > last_tick + (10000000 * 5))
            {
                last_tick = DateTime.Now.Ticks;
                spin_delay += 10;

                //but not toto easy
                if (spin_delay > 100)
                {
                    spin_delay = 10;
                }
                FEZ_Extensions.Large128x64Display.Print(35, 6, "Speed: " + (100 - spin_delay).ToString());
            }
            Thread.Sleep(spin_delay);
        }
    }
}

I was a bit afraid that it would look a bit “trashy” as in “not such a good design” but holy crap! this looks really neat!

Love the aluminium look and the big red buttons! Very good!

One minus:
The back is way too error-sensitive. You should have used shrink tube for all those wires.

Good good work! 8)

They isolated all of the loose open stuff with what looks like electrical tape, so I don’t there are any issues there. If something were shorting, it would be very obvious.

While we were pushing the wires through we had it short on us 3 times :smiley:

So we decided to fix that with tape

It is not done yet! There will be clear plastic on the bottom to protect the wires and keep them visible.

Some zip ties to make everything nice and neat, too, I would hope :smiley:

Actually, no! I love how it looks messy :slight_smile:

You have to be kidding, right?

The project is for a DIY event. It should not look too professional.

EXACTLY Mike! Someone already said why the LED boards are not hidden behind…why domino is not behind? This is a DIY and the point of it is that you see everything, even the messy wires :slight_smile:

Hmm… I get your point, and you are absolutely right, but I still vote for the shrinks :smiley: