Avatar for joppiesaus

joppiesaus

Member since Apr 2015 • Last active Jul 2015
  • 2 conversations
  • 10 comments

I like to do stuff
http://joppiesaus.function1.nl/

Most recent activity

  • in General
    Avatar for joppiesaus

    Yes
    You don't even need to power it via the USB, you could also power it by connecting it to BAT_IN and the GND pin(the two front pins), as long as the input voltage is ≥ 3.5 & ≤ 16v!

    On-board 3.3v 250mA voltage regulator, accepts voltages from 3.5v to 16v

  • in General
    Avatar for joppiesaus

    You are right. But this is actually not a problem if the data is 100% random, because the chance that the message is "Attack from the north" is the same as "Attack from the south", or "I like cats so much!!"
    But your key can be very large! You could pick different or random indexes from the key. Maybe that's a solution.
    Or come up with something else.

  • in General
    Avatar for joppiesaus

    Is XOR Encryption with the One-Time pad an option for you?
    If the key you use is random, this encryption will be uncrack-able.
    And the encrypted message isn't longer then the not-encrypted message.

    Here's some pseudo-code:

    var key = <random data>
    var message;
    function encryptMessage()
    {
      message ^= key;
    }
    
    function decryptMessage()
    {
       message ^= key;
    }
    
  • in JavaScript
    Avatar for joppiesaus

    I'm having the same problem here: The current random generator is based on the state of the machine and time. If you disconnect the power and reconnect it again, the number sequence will be the same, which is for some usages not suitable.
    I've thought about fixes for it: Adding a number of how many times it has booted or analog reading something unused(getting random noise).
    I'm not a RNG expert thought, but randomness should always be unpredictable.

  • in JavaScript
    Avatar for joppiesaus

    Thanks a lot! I often forget those kinds of things. Now it works!

  • in JavaScript
    Avatar for joppiesaus

    So I'm still enjoying to work on my fruitmachine, but the way I implement multiple timeouts don't seem to work correctly.
    Basically, I've 3 LED's, or fruits - or wheels, and I stop them one by one in order of time. When I spin the wheel, I tell it when to stop spinning. It works by just setting the velocity of the wheel to 0.

    Wheel.prototype.spin = function(stopt) // stopt = stoptime
    {
      this.vel = (2 + Math.random() * 5) / 40; // give the wheel a velocity
      setTimeout(this.stop, stopt); // tell it when to stop
    };
    

    Then you have the stop function

    Wheel.prototype.stop = function()
    {
      this.vel = 0.0;
    };
    

    The spinning happens when the user clicks the button. At that time, spin is called(not Wheel.spin)

    function spin()
    {
      for (var i = 0; i < N_LEDS;) // loop trough all wheels, spin them
      {
        wheels[i].spin((++i * 500));
      }
      
      setTimeout(function(){
         //... other code. It checks some win conditions and lights and stuff after every wheel stopped.
      }, (N_LEDS + 2.5) * 500);
    

    But, only the last setTimeout seems to be called.
    What am I doing wrong?

    Here's the full code.

    • 6 comments
    • 2,922 views
  • in General
    Avatar for joppiesaus

    It works! It really works! Too bad I accidentally override reset(). Thanks!
    EDIT: Maybe a warning in the Web IDE when you override reset() or any of the core functions?

  • in General
    Avatar for joppiesaus

    Interesting, but I don't think that's the issue. I changed onInit() to init(), but that didn't help.

Actions