Arduino Lesson 4 - If Statements

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

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

  • @jomac_ph
    @jomac_ph 11 месяцев назад +2

    perfect video, thanks a ton man! 36 yrs old and still learning this stuff. Sharing my sketch in case anyone needs it
    int led = 13; //default LED pin, external led can also be connected to pin 13
    int vs = 9; //assigned vibration sensor to pin 9
    void setup() {
    pinMode(led, OUTPUT);
    pinMode(vs, INPUT);
    Serial.begin(9600);
    }
    void loop() {
    if (digitalRead(vs) == HIGH) {
    Serial.print("Status - ");
    Serial.println("shake detected!");
    digitalWrite(led, HIGH); //lights up Pin 13 or externally connected LED
    delay(1000); //delay before scanning again for shakes
    }
    else
    (digitalWrite(led, LOW)); //turn off led while scanning
    Serial.println("ready");
    delay(50);
    }

    • @christiankomodo
      @christiankomodo 10 месяцев назад

      I love when commenters submit their code. Thanks!

  • @theteddy08
    @theteddy08 4 года назад +5

    It only took two videos from your channel to understand WHY each action acts certain way. It was the clearest simplest explanations.

  • @degarmo187
    @degarmo187 9 месяцев назад +1

    Gotta be honest, I really like your tutorials. I've been more of a coder throughout life so that part is easy for me, but I really need a tutorial on how you know to set up the wiring on the board.

  • @xcharisma1gaming139
    @xcharisma1gaming139 3 года назад +2

    You teached me arduino better than my colege teacher did in 2 years so congrats to you clear instruction now you have a whole class waching your videos

  • @kevinolvera8124
    @kevinolvera8124 5 лет назад +2

    I find that the way he words the explanation and highlights things makes a lot of sense to me than other videos

  • @tonyverduga
    @tonyverduga 6 лет назад +5

    Hallelujah is right...it finally sank in! I'm going to watch more of your videos. Thank you Sir!

  • @growponics9170
    @growponics9170 4 года назад +3

    Yeah this is incredibly clear, and simplified. Thank you. Everyone else ive seen makes this overly complicated.

  • @Benjibits
    @Benjibits 3 года назад +1

    GREAT HELP! The project in the example wasn’t what I was doing, but needed help to format the code as arduino was a topic we lightly touched on in my digital class, fixed my issue with a nice if else statement!

  • @Frightline777
    @Frightline777 Год назад +1

    i learned MORE in these 7:25 seconds than weeks of other videos.I can say just from this 1 video...I GET IT NOW!!! Thank you
    Keep the Vids coming!

  • @HPFPVS
    @HPFPVS 2 года назад +1

    I'm getting started with Arduino kinda late, but I've been watching several videos trying to learn about coding and today thanks to you for this video, I wrote My First if/else code, and it works perfectly. Thank you the simple coding lesson

  • @MrBarca154
    @MrBarca154 6 лет назад +7

    you really have a perfect teaching style

  • @LegalSkateboarding
    @LegalSkateboarding 7 лет назад +11

    Thank you for these videos. I'm binge watching them all!

  • @Godshole
    @Godshole 3 года назад +1

    I learned basic BASIC as a teenager. I really miss the GOTO statement. This if else m'larky is making my head hurt but this has got to be the best simplification of it I have come across and short too. Thanks!

  • @christiankomodo
    @christiankomodo 10 месяцев назад +1

    Excellent video! Easy to follow and I got the same results. Thanks!

  • @szarel8868
    @szarel8868 2 года назад +2

    i like your way of explaining, its so easy to follow 👍

  • @luizr.rabello4875
    @luizr.rabello4875 7 лет назад +2

    It's amazing how you can teach so well with short videos. Thank you from Brazil!

    • @benduino7327
      @benduino7327  7 лет назад

      Lovely to hear, thanks Luiz! You're welcome from the UK haha.

  • @Ruby-ti7yt
    @Ruby-ti7yt 2 года назад

    Good video, the way you explained was easy to understood. 💐

  • @thalesbarbosa8535
    @thalesbarbosa8535 4 года назад +1

    What you call "brackets" are parenthesis; and what you call "squiggly brackets" are actual brackets.
    Other than that, great video series :)

    • @benduino7327
      @benduino7327  4 года назад +2

      gotta have some fun with it, squiggly brackets is where it's at! :P :)

  • @tonyrogers5009
    @tonyrogers5009 2 года назад

    Great Video, I'm trying to apply an IF statement to extend an actuator with a particular fingerprint and retract with another fingerprint. any advice?

  • @squidboi5769
    @squidboi5769 2 года назад

    Thank you so much, i am new to arduino and couldnt figure out why it was saying "error status 1" or whatever it was. this was the reason.

  • @iFunnnnn
    @iFunnnnn 4 года назад

    hey, How do you program multiole if statements that faction as a AND program(If x

  • @Tydem
    @Tydem 6 лет назад +1

    you're videos are perfect, awesome work!

  • @shamimayesmin6168
    @shamimayesmin6168 4 года назад +3

    It is an easy explanation...
    Thank You...

  • @yadwindersingh9494
    @yadwindersingh9494 5 лет назад

    Very nice video sir......
    Great explaination
    Please also make a video on else statement

  • @yuriu8
    @yuriu8 4 года назад

    thank you you are amazing i learned so much it the best channel on youtube

  • @gakuruvictor1276
    @gakuruvictor1276 4 года назад

    hahaha this guy is really good with the if statements and the music selection
    i really liked the song at the end hahahahahah

  • @princening679
    @princening679 5 лет назад

    Love ❤😘 u sir from India 🇮🇳 ur tutorial r excellent

  • @pritichowdhury2767
    @pritichowdhury2767 6 лет назад +2

    very very thank you for making such amazing videos.

  • @clems6989
    @clems6989 2 года назад

    Another excellent video !
    Thank You so much for your hard work here. It is appreciated ...

  • @jlr3636
    @jlr3636 5 лет назад

    Question - let’s say the void loop controls 5 LEDs each doing its own thing (blinking, flashing, etc.) and the loop takes 30 seconds to complete. If I wanted a button to control 1 of the LEDs (change it’s flashing rate), will the button need to be pressed while the code is executing that line of code, or will the program remember the button press and execute when the line of code comes around?
    Second - if the actions of the LEDs are separated with a “delay” does that cause more problems ? Would “millis” be better ?
    I enjoy your videos, thanks

  • @josephjorgensen3282
    @josephjorgensen3282 5 лет назад

    Im trying to make a sequence where it takes button one then button two and so on but not out of order do you have a video that would help thank you very much for the videos there helping a tun

  • @kevinarce4232
    @kevinarce4232 3 месяца назад

    thank you very much, for this tutorials !

  • @michalsabat4720
    @michalsabat4720 4 года назад

    Thank you very much!!!!! I was having problems with this command.

  • @1rafaelespinoza
    @1rafaelespinoza 4 года назад

    jajaja Aleluya... A....Leluya. Fantasstic way to explain something trivial. Like it very mutch. Tks 4 this

  • @xxegyzz5250
    @xxegyzz5250 4 года назад

    Thank you for these videos it helped me a lot. SUBSCRIBED

  • @srijithview
    @srijithview 3 года назад

    You have a new subscriber

  • @nimishkhot
    @nimishkhot 6 лет назад

    You are doing a great job!!

  • @musama8009
    @musama8009 5 лет назад

    why we connected a ground to button? what is its purpose??

  • @noname_963
    @noname_963 7 месяцев назад

    Ты лучший! Спасибо большое ❤

  • @xoehe617
    @xoehe617 6 лет назад

    I need a bit of help, my project wasn't working so i can here. It was very useful but didn't fix my issue, everything works but the led won't turn off.
    Here is my code:
    const int analogPin = A0;
    const int oneThreshold = 102;
    void setup() {
    Serial.begin(9600);
    pinMode(1, OUTPUT);
    }
    void loop() {
    int analogValue = analogRead(analogPin);
    if (analogValue > oneThreshold){
    digitalWrite(1, LOW);
    }
    else{digitalWrite(1, HIGH);
    }
    Serial.println(analogValue);
    delay(1);
    }
    If you have any idea of why this isn't working I would be very happy if you could help. Thanks!

  • @danielmalatji1813
    @danielmalatji1813 Год назад

    This is super💯💯💯thank you very much

  • @ricardoloramesquita5990
    @ricardoloramesquita5990 5 лет назад

    What about if I want to add another condition to the if, an "and" how would I do it?

  • @rockfireist
    @rockfireist 5 лет назад

    Nice explaination... Bro solve my problem,when input high, i want output led blink only once for 2 seconds,, but here i getting problem it always repeating....i want just like trigger.....Plz reply bro

    • @banannagar
      @banannagar 5 лет назад

      You have to not use void loop

  • @zainabid945
    @zainabid945 5 лет назад

    Nice and well explained

  • @shaunsomaru4524
    @shaunsomaru4524 5 лет назад

    Great tutorial.. Thank you. You have a new sub

  • @boowonder888
    @boowonder888 5 лет назад

    I thought I was going crazy, but now I see the switch has 3 wires instead of 2. Now I am wondering if you can use a 2 wire switch with arduino? Hmmmm........

  • @Fuka_Hua
    @Fuka_Hua 2 года назад

    how to code with 3 inpute electronics in 1 code?

  • @rho35100
    @rho35100 4 года назад

    well explained!! thanks you!!

  • @goned216
    @goned216 6 лет назад

    Hey is it possible to use memory values something like
    int DynamicMemory = (Values here)
    if (DynamicMemory < 90%...
    I think you got it, im trying to make a memory error to my project but i cant find out how...

  • @venqi
    @venqi 5 лет назад

    What is the meaning of 'int'?

  • @shlb3692
    @shlb3692 5 лет назад

    amazing videos. thank you so much bro.

  • @tauseefkhan5700
    @tauseefkhan5700 4 года назад

    error.
    expected '}' at end of input.
    its show the above error when I try to compile the sketch.
    my full sketch is below. please help.
    int button = 7;
    int led = 8;
    void setup() {
    pinMode(button, INPUT);
    pinMode(led, OUTPUT);
    }
    void loop() {
    if(digitalRead(button) == HIGH ){
    digitalWrite(led, HIGH);
    }
    else{
    digitalWrite(led, LOW);
    }

    • @benduino7327
      @benduino7327  4 года назад +1

      add one more " }" at the end of your code and it's fixed :)
      This is why i use indents in my code, it helps me keep track of which brackets belong to which statements.

    • @tauseefkhan5700
      @tauseefkhan5700 4 года назад

      @@benduino7327 thanks it worked. :)

  • @demontv8326
    @demontv8326 9 месяцев назад +1

    INPUT_PULLUP!!!!

  • @mughatoamugha9029
    @mughatoamugha9029 4 года назад

    Your are really great

  • @hellsbells056
    @hellsbells056 7 лет назад +18

    How do I make a girlfriend?

  • @lucab1733
    @lucab1733 3 года назад

    I do exactly what he says but then when its uploaded the led lights up even if i did not press the button and i wired it exactly as he did here is my code: int button = 8;
    int Led = 4;
    void setup() {
    pinMode(Led, OUTPUT);
    pinMode(button, INPUT);
    // put your setup code here, to run once:
    }
    void loop() {
    if(digitalRead(button) == HIGH){
    digitalWrite(Led, HIGH);
    }
    else{
    digitalWrite(Led, LOW);

    }

    // put your main code here, to run repeatedly:
    }

  • @mohammedaltaie9497
    @mohammedaltaie9497 7 лет назад +1

    THANK YOU FOR THE VIDEO

  • @MadZax33
    @MadZax33 5 лет назад

    Why is this telling me I don't have a previous 'if' statement?
    void loop() {
    if(digitalRead(button)==HIGH);{
    digitalWrite(led, HIGH);
    delay(600);
    digitalWrite(led, LOW);
    delay(600);
    }
    else(led, LOW);
    }

    • @benduino7327
      @benduino7327  5 лет назад

      no semicolon after if(digitalRead(button)==HIGH), that will fix it

    • @benduino7327
      @benduino7327  5 лет назад

      also use square brackets for the else statement not "( )"

    • @MadZax33
      @MadZax33 5 лет назад

      Thanks!

  • @marlowkrach6325
    @marlowkrach6325 5 лет назад

    Music name please
    EDIT: 0:24

  • @rommellazaro2085
    @rommellazaro2085 5 лет назад +1

    now i know, thanks bro

  • @jacksonoffical
    @jacksonoffical 5 лет назад

    works good

  • @GamiumGamers
    @GamiumGamers 6 лет назад

    Amazin!!

  • @unconsciouscreator3012
    @unconsciouscreator3012 4 года назад

    I'm checking the comments to see if anyone else has the if and else statement working but with the opposite effects of led on and off pattern. The only confusion that could cause this result is my LOW and HIGH statement as far as I can tell, I've also checked INPUT and OUTPUT but...opposite on off pattern achieved. So illogical!

    • @benduino7327
      @benduino7327  4 года назад

      Paste your code and I will see if there is anything that could explain it :)

    • @unconsciouscreator3012
      @unconsciouscreator3012 4 года назад

      I'm using your precise code but I'm using a basic 2 wire switch instead of a actual button since buttons weren't sent as specified in my kit. I believe that is my problem. Without following your directions to the T I won't use your time. Thank you so much for the tutorials and reply!

  • @harambematata416
    @harambematata416 5 лет назад

    your code didnt work it has errors

    • @benduino7327
      @benduino7327  5 лет назад +1

      If there is a compiling error check the text at the bottom of the software, it should tell you where your error is located. As you can see in the video, if the code is entered correctly, it works. Good luck! :)

  • @serdalsolution
    @serdalsolution 5 лет назад

    thinx bro

  • @ammulurani8285
    @ammulurani8285 4 года назад

    Teach slowly..i cant grab ur words...😀😅

  • @princening679
    @princening679 5 лет назад

    Sir i want pdf of tutorials ple