Ejemplo n.º 1
0
    public void Sirene(int freq)
    {
        if (!okay)
        {
            return;
        }

        for (int j = 0; j < 2; ++j)
        {
            for (int i = 0; i < 25; ++i)
            {
                speaker.Beep(10, freq + i * 20);
                Thread.Sleep(7);
            }

            for (int i = 0; i < 25; ++i)
            {
                speaker.Beep(10, freq + 24 * 20 - i * 20);
                Thread.Sleep(7);
            }
        }
    }
    private static string UID  = "ABC";    // Change to your UID

    static void Main()
    {
        IPConnection         ipcon = new IPConnection();                   // Create IP connection
        BrickletPiezoSpeaker ps    = new BrickletPiezoSpeaker(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                                         // Connect to brickd
        // Don't use device before ipcon is connected

        // Make 2 second beep with a frequency of 1kHz
        ps.Beep(2000, 1000);

        System.Console.WriteLine("Press enter to exit");
        System.Console.ReadLine();
    }