Avatar for Kaermorhen

Kaermorhen

Member since Mar 2015 • Last active Mar 2015
  • 1 conversations
  • 2 comments

Most recent activity

  • in General
    Avatar for Kaermorhen

    Thanks a lot DrAzzy with

    setInterval(updateLed,100);
    

    added on i have what i want change of a led during movement of my hand, previously i messed up with brackets "{" after else.

    currenty i'm using DMIS in my work, but it isn't a lot of programming to do, due to the fact that there are a lot of ready to go functions to use in software (PC-DMIS) - I think i try learning Java on code.org for learn how to don't stuck by syntax.

    I'm impressed of how fast Espruino forum works.

  • in General
    Avatar for Kaermorhen

    Hi,

    Finally I have bought some hardware to my espruino boards and I have a question:

    I started with code from distance sensing robot:

    var TRIG = A0; // ultrasonic trigger
    var ECHO = A1; // ultrasonic echo signal
    var MOTORS = [A3,A2,B10,B11]; // pins for the motors
    
    var t1 = 0;
    var dist = 0;
    var inManouver = false;
    
    // Get the distance from the sensor
    setWatch(function(e) { t1=e.time; }, ECHO, { repeat:true, edge:'rising'  });
    setWatch(function(e) { var dt=e.time-t1; dist = (dt*1000000)/57.0; },  ECHO, { repeat:true, edge:'falling' });
    // 20 times a second, trigger the distance sensor
    setInterval("digitalPulse(TRIG,1, 10/1000.0)",50);
    

    i'm trying to make for e.g.

    Led1 on if distance sensing between 10 and 20 cm
    Led2 on if 20 and 50 cm
    Led3 ......

    tried with switch (case) and multiplue ifs always fail, what is the best way to achive this functionality?

    I have also some general question about some book / tutorial on Java for total newbie before making some serious code.

    Thanks in advance for help.

    BR
    Max

Actions