Jerry's Blog There's more to life than meets the eye..

22Jan/110

My first project with Netduino – Quiz Show Buzzer System

For the first Netduino/Arduino project I wanted to create a Quiz Show Buzzer System. In order to create this system I had to find some materials. If you have an old PC case, it can be a great source :).

Materials

  • (1) Netduino
  • (2) Power/Reset switch from old PC case
  • (2) LEDs (red/green) from old PC case
  • (1) PC/USB Power source

Hardware Setup

  1. Connect Green LED + (positive) wire to Netduino's digital I/O port 0 (zero)
  2. Connect Green LED - (negative) wire to Gnd port (I used one of the two on the Analog In side)
  3. Connect Red LED + wire to digital I/O port 7
  4. Connect Red LED - wire to the same Gnd port
  5. Connect Switch 1 + wire to Analog In port 5
  6. Connect Switch 1 - wire to same Gnd port
  7. Connect Switch 2 + wire to Analog In port 0 (zero)
  8. Connect Switch 2 - wire to same Gnd port
  9. Connect Netduino with PC using USB (for power)

Software

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
    public class Program
    {

        static OutputPort led;
        static OutputPort greenLed;
        static OutputPort redLed;

        public static void Main()
        {
            led = new OutputPort(Pins.ONBOARD_LED, false);
            greenLed = new OutputPort(Pins.GPIO_PIN_D0, false);
            redLed = new OutputPort(Pins.GPIO_PIN_D7, false);

            InterruptPort blueSWi = new InterruptPort(Pins.GPIO_PIN_A5, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            blueSWi.OnInterrupt += new NativeEventHandler(blueSWi_OnInterrupt);

            InterruptPort orangeSWi = new InterruptPort(Pins.GPIO_PIN_A0, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            orangeSWi.OnInterrupt += new NativeEventHandler(orangeSWi_OnInterrupt);

            InterruptPort swi = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            swi.OnInterrupt += new NativeEventHandler(swi_OnInterrupt);

            Thread.Sleep(Timeout.Infinite);

        }

        static void orangeSWi_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            if (data2 == 0)
            {
                if (!greenLed.Read())
                {
                    redLed.Write(true);
                }
            }
        }

        static void blueSWi_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            if (data2 == 0)
            {
                if (!redLed.Read())
                {
                    greenLed.Write(true);
                }
            }

        }

        static void swi_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            if (data2 == 0)
            {
                led.Write(false);
                greenLed.Write(false);
                redLed.Write(false);
                Thread.Sleep(100);
            }
        }

    }
}

Operability

The two external switches are used by players of the Quiz Show game. The internal Netduino's switch is used by the Host to reset the state of the system. This system enables the Host to know which player buzzed in first.

Media

Video

Images

Conclusion

This was a nice little quick project that helped me get my feet wet in Netduino. Let me know if you need any part of it explained further.