Arduino Tutorial 08 - Switch-Case and While

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024

Комментарии • 8

  • @Elstarda
    @Elstarda 10 лет назад +1

    The memory location of lightVal?
    You seem to be calling it as a int inside the while which could be setting it as new rather than replace. Try it without the int inside the while

  • @Nqrgaard
    @Nqrgaard 8 лет назад

    Hi Ryan
    What if i want to use a button to shift between 5 different cases and the cases should loop until the button i pressed again?
    Like first case is the AnalogInOutSerial, case 2 is Fade example and so on?
    I want the fade example to loop until the button is pressed and then it goes on to the next program. :)

    • @RyanBrooksInnovator
      @RyanBrooksInnovator  8 лет назад

      In this situation, you would require two additional parts. The first, would be a button checking "if" statement. Each time the button is pressed, it will do one of two things: 1) if the current case value is less than 5, add 1 to the "switch" variable (to progress to the next case) or, 2) if the switch variable is currently the 5th case, set the "switch" variable back to 1 (to restart the loop).

  • @electro3976
    @electro3976 9 лет назад

    Hi just wondering what the fix was for the While loop problem was as i have similar problem and i just can't figure it out

    • @RyanBrooksInnovator
      @RyanBrooksInnovator  9 лет назад

      +Piddy D Yes! Just don't define the variable within the while loop. Instead, define your variable before the void setup, and that should solve the problem. ;)

  • @hamid18079
    @hamid18079 9 лет назад

    Nice Ryan. Good work.
    I am working on a project based on 2 sensors which work with one LED (one will turn it On and another one will turn it off, for 3000 times (without timers)). Dont know how to use switch-case for that outcome.
    Please help.

  • @Elstarda
    @Elstarda 10 лет назад

    So would be
    lightVal = analogRead(lightPin);