コード例 #1
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D13);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D11);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D12);
            portReset = Device.CreateDigitalInputPort(Device.Pins.D07);

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));

            var config = new SpiClockConfiguration(
                speed: new Frequency(12000, Frequency.UnitType.Kilohertz),
                mode: SpiClockConfiguration.Mode.Mode0);
            var spiBus = Device.CreateSpiBus(
                clock: Device.Pins.SCK,
                copi: Device.Pins.MOSI,
                cipo: Device.Pins.MISO,
                config: config);
            var display = new Ssd1309
                          (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                          );

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font4x8();
        }
コード例 #2
0
        void Initialize()
        {
            var config = new SpiClockConfiguration(
                speed: new Frequency(12000, Frequency.UnitType.Kilohertz),
                mode: SpiClockConfiguration.Mode.Mode0);
            var spiBus = Device.CreateSpiBus(
                clock: Device.Pins.SCK,
                copi: Device.Pins.MOSI,
                cipo: Device.Pins.MISO,
                config: config);

            display = new Ssd1309
                      (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font12x16();

            buttonLeft  = new PushButton(Device, Device.Pins.D11, ResistorMode.Disabled);
            buttonRight = new PushButton(Device, Device.Pins.D10, ResistorMode.Disabled);
            buttonUp    = new PushButton(Device, Device.Pins.D09, ResistorMode.Disabled);
            buttonDown  = new PushButton(Device, Device.Pins.D12, ResistorMode.Disabled);

            speaker = new PiezoSpeaker(Device, Device.Pins.D13);
        }
コード例 #3
0
 public BaseBoard()
 {
     Button  = new Button(Pins.ONBOARD_SW1);
     Led     = new Led(Pins.ONBOARD_LED);
     Speaker = new PiezoSpeaker(Pins.GPIO_PIN_D5);
     Sensor  = new PIRSensor(Pins.GPIO_PIN_D13);
 }
コード例 #4
0
        public PiezoSpeakerApp()
        {
            pwm          = Device.CreatePwmPort(Device.Pins.D05);
            piezoSpeaker = new PiezoSpeaker(pwm);

            TestPiezoSpeaker();
        }
コード例 #5
0
        public MeadowApp()
        {
            var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue);

            led.SetColor(RgbLed.Colors.Red);

            leds[0] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D10));
            leds[1] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D09));
            leds[2] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D08));
            leds[3] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D07));

            pushButtons[0]          = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D01, InterruptMode.EdgeBoth, ResistorMode.Disabled));
            pushButtons[0].Clicked += ButtonRedClicked;
            pushButtons[1]          = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeBoth, ResistorMode.Disabled));
            pushButtons[1].Clicked += ButtonGreenClicked;
            pushButtons[2]          = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D03, InterruptMode.EdgeBoth, ResistorMode.Disabled));
            pushButtons[2].Clicked += ButtonBlueClicked;
            pushButtons[3]          = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth, ResistorMode.Disabled));
            pushButtons[3].Clicked += ButtonYellowClicked;

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D11));

            Console.WriteLine("Welcome to Simon");
            SetAllLEDs(true);
            game.OnGameStateChanged += OnGameStateChanged;
            game.Reset();

            led.SetColor(RgbLed.Colors.Green);
        }
コード例 #6
0
        void Initialize()
        {
            var onboardLed = new RgbPwmLed(device: Device,
                                           redPwmPin: Device.Pins.OnboardLedRed,
                                           greenPwmPin: Device.Pins.OnboardLedGreen,
                                           bluePwmPin: Device.Pins.OnboardLedBlue);

            onboardLed.SetColor(Color.Red);

            displayController = new DisplayControllers();

            piezo = new PiezoSpeaker(Device, Device.Pins.D09);

            button = new PushButton(device: Device, Device.Pins.D04);
            button.PressStarted += ButtonPressStarted;
            button.PressEnded   += ButtonPressEnded;

            stopWatch = new Stopwatch();

            timer          = new Timer(2000);
            timer.Elapsed += TimerElapsed;

            LoadMorseCode();

            ShowLetterQuestion();

            onboardLed.SetColor(Color.Green);
        }
コード例 #7
0
        private void InitializePeripherals()
        {
            buttons[0] = new PushButton(N.Pins.GPIO_PIN_D0, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[1] = new PushButton(N.Pins.GPIO_PIN_D1, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[2] = new PushButton(N.Pins.GPIO_PIN_D2, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[3] = new PushButton(N.Pins.GPIO_PIN_D3, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[4] = new PushButton(N.Pins.GPIO_PIN_D4, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[5] = new PushButton(N.Pins.GPIO_PIN_D5, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[6] = new PushButton(N.Pins.GPIO_PIN_D6, Netduino.Foundation.CircuitTerminationType.CommonGround);
            buttons[7] = new PushButton(N.Pins.GPIO_PIN_D7, Netduino.Foundation.CircuitTerminationType.CommonGround);

            buttonReset = new PushButton(N.Pins.ONBOARD_BTN, Netduino.Foundation.CircuitTerminationType.CommonGround);

            speakers[0] = new PiezoSpeaker(Cpu.PWMChannel.PWM_2);
            speakers[1] = new PiezoSpeaker(Cpu.PWMChannel.PWM_3);
            speakers[2] = new PiezoSpeaker(Cpu.PWMChannel.PWM_5);

            onboardLed = new Led(N.Pins.ONBOARD_LED);

            isSpeakerPlaying[0] = isSpeakerPlaying[1] = isSpeakerPlaying[2] = false;

            for (int i = 0; i < buttonSpeakerIndex.Length; i++)
            {
                buttonSpeakerIndex[i] = -1;
            }


            foreach (var button in buttons)
            {
                button.PressStarted += Button_PressStarted;
                button.PressEnded   += Button_PressEnded;
            }

            buttonReset.Clicked += ButtonReset_Clicked;
        }
コード例 #8
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D13);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D11);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D12);
            portReset = Device.CreateDigitalInputPort(Device.Pins.D07);

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));

            var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode0);

            var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            display = new Ssd1309
                      (
                device: Device,
                spiBus: bus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            graphics             = new GraphicsLibrary(display);
            graphics.CurrentFont = new Font4x8();
        }
コード例 #9
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D02);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D03);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D04);
            portReset = Device.CreateDigitalInputPort(Device.Pins.D05);

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D06));

            var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3);
            var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            Console.WriteLine("Create display driver instance");

            display = new St7789(device: Device, spiBus: spiBus,
                                 chipSelectPin: Device.Pins.D10,
                                 dcPin: Device.Pins.D01,
                                 resetPin: Device.Pins.D00,
                                 width: 240, height: 240);

            Console.WriteLine("Create graphics library");
            graphics             = new GraphicsLibrary(display);
            graphics.CurrentFont = new Font12x16();
        }
コード例 #10
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D02);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D03);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D04);
            portReset = Device.CreateDigitalInputPort(Device.Pins.D05);

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D06));

            var config = new SpiClockConfiguration(
                speed: new Frequency(6000, Frequency.UnitType.Kilohertz),
                mode: SpiClockConfiguration.Mode.Mode3);
            var spiBus = Device.CreateSpiBus(
                clock: Device.Pins.SCK,
                copi: Device.Pins.MOSI,
                cipo: Device.Pins.MISO,
                config: config);
            var display = new St7789(
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D10,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                width: 240, height: 240);

            Console.WriteLine("Create graphics library");
            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font12x16();
        }
コード例 #11
0
        void Initialize()
        {
            var onboardLed = new RgbPwmLed(
                device: Device,
                redPwmPin: Device.Pins.OnboardLedRed,
                greenPwmPin: Device.Pins.OnboardLedGreen,
                bluePwmPin: Device.Pins.OnboardLedBlue);

            onboardLed.SetColor(Color.Red);

            notes = new float[] { 261.63f, 329.63f, 392, 523.25f };

            game = new SimonGame();

            leds    = new PwmLed[4];
            leds[0] = new PwmLed(Device, Device.Pins.D10, TypicalForwardVoltage.Red);
            leds[1] = new PwmLed(Device, Device.Pins.D09, TypicalForwardVoltage.Green);
            leds[2] = new PwmLed(Device, Device.Pins.D08, TypicalForwardVoltage.Blue);
            leds[3] = new PwmLed(Device, Device.Pins.D07, TypicalForwardVoltage.Yellow);

            buttons             = new PushButton[4];
            buttons[0]          = new PushButton(Device, Device.Pins.MISO);
            buttons[0].Clicked += ButtonRedClicked;
            buttons[1]          = new PushButton(Device, Device.Pins.D02);
            buttons[1].Clicked += ButtonGreenClicked;
            buttons[2]          = new PushButton(Device, Device.Pins.D03);
            buttons[2].Clicked += ButtonBlueClicked;
            buttons[3]          = new PushButton(Device, Device.Pins.D04);
            buttons[3].Clicked += ButtonYellowClicked;

            speaker = new PiezoSpeaker(Device, Device.Pins.D12);

            onboardLed.SetColor(Color.Green);
        }
コード例 #12
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode0);

            var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            display = new Ssd1309
                      (
                device: Device,
                spiBus: bus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            graphics             = new GraphicsLibrary(display);
            graphics.CurrentFont = new Font12x16();

            buttonLeft  = new PushButton(Device, Device.Pins.D11, ResistorMode.Disabled);
            buttonRight = new PushButton(Device, Device.Pins.D10, ResistorMode.Disabled);
            buttonUp    = new PushButton(Device, Device.Pins.D09, ResistorMode.Disabled);
            buttonDown  = new PushButton(Device, Device.Pins.D12, ResistorMode.Disabled);

            speaker = new PiezoSpeaker(Device, Device.Pins.D13);

            Console.WriteLine("Initialize hardware complete.");
        }
コード例 #13
0
ファイル: BaseBoard.cs プロジェクト: WadeTsai/NetduinoDemo
 public BaseBoard()
 {
     Button = new Button(Pins.ONBOARD_SW1);
     Led = new Led(Pins.ONBOARD_LED);
     Speaker = new PiezoSpeaker(Pins.GPIO_PIN_D5);
     Sensor = new PIRSensor(Pins.GPIO_PIN_D13);
 }
コード例 #14
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing...");

            piezoSpeaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));

            TestPiezoSpeaker();
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the SoundGenerator class
        /// </summary>
        /// <param name="inputPort1">First sound-level input port</param>
        /// <param name="inputPort2">Second sound-level input port</param>
        /// <param name="pwmPort">PWM port used to drive the speaker</param>
        public SoundGenerator(IDigitalInputPort inputPort1, IDigitalInputPort inputPort2, IPwmPort pwmPort)
        {
            this.volumeIn1  = inputPort1;
            this.volumeIn2  = inputPort2;
            this.speakerPWM = pwmPort;

            this.speaker = new PiezoSpeaker(this.speakerPWM);

            this.PlayInitialSound();
        }
コード例 #16
0
        private void InitializePeripherals()
        {
            ledMelody = new Led(N.Pins.GPIO_PIN_D4);
            ledBass = new Led(N.Pins.GPIO_PIN_D2);

            speakerMelody = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D9);
            speakerBass = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D11);

            buttonPlay = new PushButton(N.Pins.ONBOARD_BTN, Netduino.Foundation.CircuitTerminationType.Floating);
            buttonPlay.Clicked += OnButtonPlay;
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: valoni/Netduino.Foundation
        public static void Main()
        {
            const int NUMBER_OF_NOTES = 16;

            float[] melody = new float[NUMBER_OF_NOTES]
            {
                NoteFrequencies.NOTE_A3,
                NoteFrequencies.NOTE_B3,
                NoteFrequencies.NOTE_CS4,
                NoteFrequencies.NOTE_D4,
                NoteFrequencies.NOTE_E4,
                NoteFrequencies.NOTE_FS4,
                NoteFrequencies.NOTE_GS4,
                NoteFrequencies.NOTE_A4,
                NoteFrequencies.NOTE_A4,
                NoteFrequencies.NOTE_GS4,
                NoteFrequencies.NOTE_FS4,
                NoteFrequencies.NOTE_E4,
                NoteFrequencies.NOTE_D4,
                NoteFrequencies.NOTE_CS4,
                NoteFrequencies.NOTE_B3,
                NoteFrequencies.NOTE_A3,
            };

            var piezo = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D5);

            while (true)
            {
                for (int i = 0; i < NUMBER_OF_NOTES; i++)
                {
                    //PlayTone with a duration in synchronous
                    piezo.PlayTone(melody[i], 600);
                    Thread.Sleep(50);
                }

                Thread.Sleep(1000);

                //PlayTone without a duration will return immediately and play the tone
                piezo.PlayTone(NoteFrequencies.NOTE_A4);
                Thread.Sleep(2000);

                //call StopTone to end a tone started without a duration
                piezo.StopTone();

                Thread.Sleep(2000);
            }
        }
コード例 #18
0
        public MeadowApp()
        {
            this.leds[0] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D10));
            this.leds[1] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D09));
            this.leds[2] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D08));
            this.leds[3] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D07));

            this.pushButtons[0] = new PushButton(
                Device.CreateDigitalInputPort(
                    Device.Pins.D01,
                    InterruptMode.EdgeBoth,
                    ResistorMode.Disabled
                    ));
            this.pushButtons[0].Clicked += ButtonRedClicked;

            this.pushButtons[1] = new PushButton(
                Device.CreateDigitalInputPort(
                    Device.Pins.D02,
                    InterruptMode.EdgeBoth,
                    ResistorMode.Disabled
                    ));
            this.pushButtons[1].Clicked += ButtonGreenClicked;

            this.pushButtons[2] = new PushButton(
                Device.CreateDigitalInputPort(
                    Device.Pins.D03,
                    InterruptMode.EdgeBoth,
                    ResistorMode.Disabled
                    ));
            this.pushButtons[2].Clicked += ButtonBlueClicked;

            this.pushButtons[3] = new PushButton(
                Device.CreateDigitalInputPort(
                    Device.Pins.D04,
                    InterruptMode.EdgeBoth,
                    ResistorMode.Disabled
                    ));
            this.pushButtons[3].Clicked += ButtonYellowClicked;

            this.speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D11));

            Console.WriteLine("Welcome to Simon");
            this.SetAllLEDs(true);
            this.game.OnGameStateChanged += OnGameStateChanged;
            this.game.Reset();
        }
コード例 #19
0
        private void InitializePeripherals()
        {
            speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);

            buttonLeft  = new PushButton(N.Pins.GPIO_PIN_D2, CircuitTerminationType.CommonGround);
            buttonRight = new PushButton(N.Pins.GPIO_PIN_D5, CircuitTerminationType.CommonGround);

            buttonLeft.Clicked  += ButtonLeft_Clicked;
            buttonRight.Clicked += ButtonRight_Clicked;

            display = new ILI9163(chipSelectPin: N.Pins.GPIO_PIN_D4,
                                  dcPin: N.Pins.GPIO_PIN_D7,
                                  resetPin: N.Pins.GPIO_PIN_D6,
                                  spiModule: SPI.SPI_module.SPI1,
                                  speedKHz: 15000);

            graphics = new GraphicsLibrary(display);
        }
コード例 #20
0
        private void InitializePeripherals()
        {
            pianoKeys[0] = new InputPort(N.Pins.GPIO_PIN_D7, true, Port.ResistorMode.PullUp);
            pianoKeys[1] = new InputPort(N.Pins.GPIO_PIN_D6, true, Port.ResistorMode.PullUp);
            pianoKeys[2] = new InputPort(N.Pins.GPIO_PIN_D5, true, Port.ResistorMode.PullUp);
            pianoKeys[3] = new InputPort(N.Pins.GPIO_PIN_D4, true, Port.ResistorMode.PullUp);
            pianoKeys[4] = new InputPort(N.Pins.GPIO_PIN_D3, true, Port.ResistorMode.PullUp);
            pianoKeys[5] = new InputPort(N.Pins.GPIO_PIN_D2, true, Port.ResistorMode.PullUp);
            pianoKeys[6] = new InputPort(N.Pins.GPIO_PIN_D1, true, Port.ResistorMode.PullUp);
            pianoKeys[7] = new InputPort(N.Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullUp);

            speakers[0] = new PiezoSpeaker(Cpu.PWMChannel.PWM_2);
            speakers[1] = new PiezoSpeaker(Cpu.PWMChannel.PWM_3);
            speakers[2] = new PiezoSpeaker(Cpu.PWMChannel.PWM_5);

            onboardLed = new Led(N.Pins.ONBOARD_LED);

            isSpeakerPlaying[0] = isSpeakerPlaying[1] = isSpeakerPlaying[2] = false;
        }
コード例 #21
0
ファイル: App.cs プロジェクト: adrianstevens/NetduinoSamples
        private void InitializePeripherals()
        {
            leds[0] = new Led(N.Pins.GPIO_PIN_D4);
            leds[1] = new Led(N.Pins.GPIO_PIN_D5);
            leds[2] = new Led(N.Pins.GPIO_PIN_D6);
            leds[3] = new Led(N.Pins.GPIO_PIN_D7);

            buttons[0] = new PushButton(N.Pins.GPIO_PIN_D10, Netduino.Foundation.CircuitTerminationType.High);
            buttons[1] = new PushButton(N.Pins.GPIO_PIN_D11, Netduino.Foundation.CircuitTerminationType.High);
            buttons[2] = new PushButton(N.Pins.GPIO_PIN_D12, Netduino.Foundation.CircuitTerminationType.High);
            buttons[3] = new PushButton(N.Pins.GPIO_PIN_D13, Netduino.Foundation.CircuitTerminationType.High);

            speaker  = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);
            spdt     = new SpdtSwitch(N.Pins.GPIO_PIN_D2);
            graphics = new GraphicsLibrary(display = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64));
            display.IgnoreOutOfBoundsPixels = true;

            SetAllLEDs(false);
        }
コード例 #22
0
        //hardware init
        private static void Initialize()
        {
            buttons[(int)SnakeDirection.Left]  = new PushButton(Pins.GPIO_PIN_D6, CircuitTerminationType.CommonGround);
            buttons[(int)SnakeDirection.Right] = new PushButton(Pins.GPIO_PIN_D4, CircuitTerminationType.CommonGround);
            buttons[(int)SnakeDirection.Up]    = new PushButton(Pins.GPIO_PIN_D5, CircuitTerminationType.CommonGround);
            buttons[(int)SnakeDirection.Down]  = new PushButton(Pins.GPIO_PIN_D7, CircuitTerminationType.CommonGround);

            buttons[(int)SnakeDirection.Left].Clicked  += LeftClicked;
            buttons[(int)SnakeDirection.Right].Clicked += RightClicked;
            buttons[(int)SnakeDirection.Up].Clicked    += (s, e) => game.Direction = SnakeDirection.Up;
            buttons[(int)SnakeDirection.Down].Clicked  += (s, e) => game.Direction = SnakeDirection.Down;

            speaker = new PiezoSpeaker(PWMChannel.PWM_4);

            var display = new PCD8544(chipSelectPin: Pins.GPIO_PIN_D9, dcPin: Pins.GPIO_PIN_D8,
                                      resetPin: Pins.GPIO_PIN_D10, spiModule: SPI.SPI_module.SPI1);

            graphics             = new GraphicsLibrary(display);
            graphics.CurrentFont = new Font8x8();
        }
コード例 #23
0
ファイル: App.cs プロジェクト: adrianstevens/NetduinoSamples
        private void InitializePeripherals()
        {
            resetButton          = new PushButton(N.Pins.ONBOARD_BTN, Netduino.Foundation.CircuitTerminationType.Floating);
            resetButton.Clicked += OnResetButton;

            tree = new InputPort(N.Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp);

            speaker  = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);
            greenLed = new PwmLed(N.PWMChannels.PWM_PIN_D5, 2.0f);
            redLed   = new PwmLed(N.PWMChannels.PWM_PIN_D6, 2.0f);

            var ssd1306 = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64);

            display             = new GraphicsLibrary(ssd1306);
            display.CurrentFont = new Font8x12();

            display.Clear(true);

            PlayBuzzer();
        }
コード例 #24
0
        private void InitializePeripherals()
        {
            leds[0] = new Led(N.Pins.GPIO_PIN_D0);
            leds[1] = new Led(N.Pins.GPIO_PIN_D1);
            leds[2] = new Led(N.Pins.GPIO_PIN_D2);
            leds[3] = new Led(N.Pins.GPIO_PIN_D3);

            buttons[0] = new InterruptPort(N.Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            buttons[1] = new InterruptPort(N.Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            buttons[2] = new InterruptPort(N.Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            buttons[3] = new InterruptPort(N.Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);

            buttons[0].OnInterrupt += OnButton0;
            buttons[1].OnInterrupt += OnButton1;
            buttons[2].OnInterrupt += OnButton2;
            buttons[3].OnInterrupt += OnButton3;

            speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D5);

            SetAllLEDs(false);
        }
コード例 #25
0
        //And finally, some test code that demonstrates using the above code to play music.

        public static void Test_PiezoSpeaker()
        {
            // setup the speaker on digital pin 5
            PiezoSpeaker speaker = new PiezoSpeaker(Pins.GPIO_PIN_D5);

            // define some tunes
            string[] tunes = new string[]
            {
                "C * F / F * F A G / F * G A F / F A + C D",                                                                 // Auld Lang Syne
                "D / D * * E D G * F# / / D / D * * E D A * G / / D / D * * + D - B G F# * E / / + C / C * * - B G A * G",   // Happy birthday
                "C C G G A A * G / F F E E D D * C / G G F F E E * D / G G F F E E * D / C C G G A A * G / F F E E D D * C", // twinkle, twinkle
                "A B + C D E F# G# A G F E D C - B A",                                                                       // melodic minor scale
            };


            // each time the button is pressed we're going to cycle to the next tune in the list
            // if we reach the end of the list, start at the beginning again.

            int which = -1;

            Button button = new Button(Pins.ONBOARD_SW1);

            button.Pressed += delegate
            {
                which++;

                if (which == tunes.Length)
                {
                    which = 0;
                }

                speaker.Play(tunes[which], 4, 333);
            };

            // as this is driven by the button being pressed, we don't need to poll
            // anything so we just put the main thread to sleep and wait... and wait... and wait...

            Thread.Sleep(Timeout.Infinite);
        }
コード例 #26
0
        private void InitializePeripherals()
        {
            leds[0] = new Led(N.Pins.GPIO_PIN_D4);
            leds[1] = new Led(N.Pins.GPIO_PIN_D5);
            leds[2] = new Led(N.Pins.GPIO_PIN_D6);
            leds[3] = new Led(N.Pins.GPIO_PIN_D7);

            buttons[0] = new InterruptPort(N.Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            buttons[1] = new InterruptPort(N.Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            buttons[2] = new InterruptPort(N.Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            buttons[3] = new InterruptPort(N.Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);

            buttons[0].OnInterrupt += OnButton0;
            buttons[1].OnInterrupt += OnButton1;
            buttons[2].OnInterrupt += OnButton2;
            buttons[3].OnInterrupt += OnButton3;

            speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);
            spdt    = new SpdtSwitch(N.Pins.GPIO_PIN_D2);
            display = new GraphicsLibrary(new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64));

            SetAllLEDs(false);
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: WadeTsai/NetduinoDemo
        //And finally, some test code that demonstrates using the above code to play music.

        public static void Test_PiezoSpeaker()
        {
            // setup the speaker on digital pin 5
            PiezoSpeaker speaker = new PiezoSpeaker(Pins.GPIO_PIN_D5);

            // define some tunes
            string[] tunes = new string[] 
            {
                "C * F / F * F A G / F * G A F / F A + C D" , // Auld Lang Syne
                "D / D * * E D G * F# / / D / D * * E D A * G / / D / D * * + D - B G F# * E / / + C / C * * - B G A * G", // Happy birthday
                "C C G G A A * G / F F E E D D * C / G G F F E E * D / G G F F E E * D / C C G G A A * G / F F E E D D * C" , // twinkle, twinkle
                "A B + C D E F# G# A G F E D C - B A", // melodic minor scale                
            };


            // each time the button is pressed we're going to cycle to the next tune in the list
            // if we reach the end of the list, start at the beginning again.

            int which = -1;

            Button button = new Button(Pins.ONBOARD_SW1);
            button.Pressed += delegate
            {
                which++;

                if (which == tunes.Length)
                    which = 0;

                speaker.Play(tunes[which], 4, 333);
            };

            // as this is driven by the button being pressed, we don't need to poll
            // anything so we just put the main thread to sleep and wait... and wait... and wait...

            Thread.Sleep(Timeout.Infinite);
        }
コード例 #28
0
ファイル: Note.cs プロジェクト: octoberclub/NetduinoDemo
 public void Play(PiezoSpeaker speaker)
 {
     speaker.Play(_frequency, _duration);
 }
コード例 #29
0
ファイル: Note.cs プロジェクト: WadeTsai/NetduinoDemo
 public void Play(PiezoSpeaker speaker)
 {
     speaker.Play(_frequency, _duration);
 }
コード例 #30
0
        public JingleBellsApp()
        {
            piezoSpeaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));

            PlayJingleBells();
        }