Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Zufallszahl aus bestimmten Zahlen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Zufallszahl aus bestimmten Zahlen

    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      groundlevel last edited by

      Hi Leute,
      ich hoffe Ihr könnt mir weiterhelfen. Wie kann ich eine Zufallszahl aus vorher definierten Zahlen generieren?
      Also z.B. ich möchte eine Zufallszahl aus diesen hier: 5, 7, 15 und 20.
      Hintergrund ist, dass ich verschiedene Effekte eines LED Stripes schalten möchte als Zufall aber da einige dabei sind die ich nicht mag 🙂
      Danke schonmal!
      Greetz

      Thomas Braun Homoran 2 Replies Last reply Reply Quote 0
      • Thomas Braun
        Thomas Braun Most Active @groundlevel last edited by Thomas Braun

        @groundlevel sagte in Zufallszahl aus bestimmten Zahlen:

        Wie kann ich eine Zufallszahl aus vorher definierten Zahlen generieren?

        Gar nicht. Das ist ja keine Zufallszahl mehr dann. 🙂

        1 Reply Last reply Reply Quote 0
        • Homoran
          Homoran Global Moderator Administrators @groundlevel last edited by Homoran

          @groundlevel sagte in Zufallszahl aus bestimmten Zahlen:

          Also z.B. ich möchte eine Zufallszahl aus diesen hier: 5, 7, 15 und 20.

          geht bestimmt einfacher, aber ich würde eine zufallszahl zwischen 5 und 20 generieren, das ergebnis auf 5, 7, 15 oder 20 prüfen. wenn true übergeben, wenn false Generator nochmals starten

          bahnuhr 1 Reply Last reply Reply Quote 0
          • bahnuhr
            bahnuhr Forum Testing Most Active @Homoran last edited by bahnuhr

            @groundlevel sagte in Zufallszahl aus bestimmten Zahlen:

            Zufallszahl aus diesen hier: 5, 7, 15 und 20.

            oder so:

                var arr = [5,7,15,20];
                var v_random = Math.floor(Math.random() * arr.length);
                log (arr[v_random]);
            

            mfg
            Dieter

            1 Reply Last reply Reply Quote 0
            • R
              Rushmed Most Active last edited by

              Im Blockly vll. so:

              d54e0612-1e29-4f33-8700-c7dff9e344eb-grafik.png

              G 1 Reply Last reply Reply Quote 1
              • G
                groundlevel @Rushmed last edited by

                @rushmed
                Funktioniert sowas von gut 🙂 Danke!!! Euch anderen auch!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                Support us

                ioBroker
                Community Adapters
                Donate

                457
                Online

                31.9k
                Users

                80.2k
                Topics

                1.3m
                Posts

                5
                6
                268
                Loading More Posts
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes
                Reply
                • Reply as topic
                Log in to reply
                Community
                Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                The ioBroker Community 2014-2023
                logo