How to do multiple tasks in Arduino | Beginners | millis() function

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ค. 2024
  • Have you ever felt difficulties while trying to do multiple tasks in Arduino?
    If yes, this video is for you 😉.
    Arduino is not built to do multiple tasks at the same time. It doesn’t support Multithreading like any classic computers you have. It executes instructions one by one in a queue.
    But the good news is… Still, you can do some tricks to make an illusion of doing multiple tasks at the same time.
    Article: www.amritaryal.com.np/posts/c...
    Media where you can contact me:
    Github: github.com/Amritaryal44
    Instagram: / its_elixir44
    Facebook: / techsbyamrit
    Twitter: / amritaryal44
    Some images used in this video are from rawpixel.com and pngtree.com.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 145

  • @CaptTambo
    @CaptTambo 2 ปีที่แล้ว +62

    This is the most helpful video I've found explaining the millis function so far. However, I'm still a bit confused. I'll practice and learn hopefully.

    • @explorerpragun431
      @explorerpragun431 2 ปีที่แล้ว

      Same

    • @YouKnowMeDuh
      @YouKnowMeDuh 2 ปีที่แล้ว +9

      If it helps, basically, instead of using a command that halts command execution (delay) he's simply comparing times in a conditional statement to control when the light turns on/off. Using delay, the loop() function takes 2 seconds to complete before it runs again in the initial code, because the delay there is 2 seconds. This leaves very little time for the Arduino to realize when a button press occurs in the latter part of the code. Without using delay, the loop runs at a much higher speed and thus condition checks run much faster.
      For example, let's assume this code is short enough that without delays, loop() running a single time only takes 100 milliseconds at 5:17. So in one second, loop() runs 10 times. So the loop would check for a button press every 10 milliseconds while also checking whether the current time is a minimum of 1000 milliseconds after the last time stamp we saved to the prevTime() variable. Since prevTime() is only set when the condition statement is true, it remains whatever value it was set to eg. 5000 until the difference between the previously saved time and the currently reported time (time continuously updates during program execution), is greater than 1000 ms.
      He probably should have set it to >=1000ms because technically, the LED would always be on for slightly longer than the intended 1 second otherwise.

  • @brutalshiteater
    @brutalshiteater 2 ปีที่แล้ว +14

    That was very helpful, it's amazing how you are able to explain the complex problem of multitasking in such an understandable way.

  • @ThePhaaze
    @ThePhaaze 2 ปีที่แล้ว +4

    This video was extremely comprehensive.
    Thank you so much and have a wonderful day!

  • @zatkolucas7838
    @zatkolucas7838 2 ปีที่แล้ว +2

    What an explanation, just what is was looking for. THANKS!

  • @stonynotdusty
    @stonynotdusty 2 ปีที่แล้ว +2

    That was super good. May God bless you for helping others with this.

  • @deebiga1781
    @deebiga1781 2 ปีที่แล้ว +2

    That was comprehensible! Thank you.

  • @joshuaoduroadu5376
    @joshuaoduroadu5376 ปีที่แล้ว +1

    The best explanation of the millis function to date I have watched.
    Thanks for sharing.
    I will try this approach hopefully make good progress.

  • @alirazakyara5676
    @alirazakyara5676 ปีที่แล้ว

    This is Razak from Ghana and I just want to say thank you very much

  • @willmaxwell2184
    @willmaxwell2184 2 ปีที่แล้ว +3

    Great job explaining this in great detail. I have 2 projects in mind to do but couldn't figure out the delay problem. With Millis it all makes since. Back to do some coding. I will have a question in the near future though.

  • @Mattbe72
    @Mattbe72 ปีที่แล้ว

    Simple and efficient 10 min of video ! Thanks a lot 😀

  • @Shivaaayy
    @Shivaaayy 2 ปีที่แล้ว +2

    Awesome solve all my doubts regarding parallel processing in Arduino

  • @Th3_Gael
    @Th3_Gael 18 วันที่ผ่านมา

    You need to make more arduino tutorials.
    This was short, to the point and showed the full concept unlike other videos where I've been trying to piece it together from several videos.

  • @ashikislam232
    @ashikislam232 8 หลายเดือนก่อน

    This was a very helpful and educational video. Thank you, Sir!

  • @vinothn4228
    @vinothn4228 9 หลายเดือนก่อน

    This is really a great video . I literally decided to move some 32bit controllers like ESP32 for some multitasking abilities. But, now you made it easier than i thought 💭 😁.

  • @ineffige
    @ineffige 2 ปีที่แล้ว +5

    Perfect! This the best video explaining multitasking on Arduino I have ever seen. Fantastic job mate!

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน

      If that is true then you haven't looked into ESP32
      ESP32 Multitasking shits all over this and then some

    • @ineffige
      @ineffige 7 หลายเดือนก่อน

      @@martinkuliza I needed this for Arduino not esp32

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน

      @@ineffige
      OK, I guess.
      if you want to make life hard for yourself, go for it.
      I also know how to implement Multi Tasking (Not like in this video) but as you would in ESP32 using FreeRTOS as well
      I'm not suggesting you should do it,
      I'm just saying
      YOU CAN DO IT
      YOU CAN TRY IT
      YOU CAN INSIST ON MAKING YOUR LIFE DIFFICULT
      or you can transition to something that will make your life easier
      don't get me wrong
      I'm from 70s Electronics, i have Massive respect for Arduino
      but fact is fact, Arduino doesn't compare to ESP32
      which is why Arduino Dev Boards are now being sold with Bluetooth and WiFi Integrated
      the issue with these boards is still
      Even though they have WiFi and Bluetooth
      They haven't increased in memory
      they don't have dual core processing
      Its sad to admit, But Arduino is Dying
      to persist through a problem using band aid solutions like milli's
      is to continue to make your life difficult for no reason
      but hey.... WHATEVER MAKES YOU HAPPY MATE

    • @ineffige
      @ineffige 7 หลายเดือนก่อน

      @@martinkuliza lol. If I wanted tips for esp32 I would search for it not Arduino. Why so bitter dude

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน

      @@ineffige
      Bitter ???
      No. I'm not bitter
      I'm offering advice. LOL
      Where did you get bitter from ?
      No..... Not bitter, Just trying to make life easier for people.
      it's commonly understood that if you have a delay issue using delay() in Arduino you move to millis.
      AND THAT'S WHERE MOST PEOPLE GET STUCK
      Mainly because they don't know about ESP32 (Most people don't) it's nothing to be ashamed about
      I'VE PERSONALLY BEEN DOWN THIS ROAD.
      When i saw the video and the word MULTI TASKING i assumed he was going to talk about task creation in ESP32, Instead he went on about Arduino
      Multi Tasking in Arduino is a real pain staking process, Later down the track you realize, you should have gone with ESP32
      so, I'm not bitter
      I'M GIVING YOU THE FORESIGHT OF MY EXPERIENCE
      I'm trying to help you, I"m not bitter
      OK, so tell me this then,
      if you're aware of ESP32, and Arduino's Memory and core limitations
      as well as increased price
      why do you continue to use it

  • @theIMMUNICORN
    @theIMMUNICORN ปีที่แล้ว +1

    This explanation is excellent. Very helpful & thank you ..!

  • @msunrl8577
    @msunrl8577 2 ปีที่แล้ว +1

    Big thanks! High quality explaination

  • @scalt8367
    @scalt8367 9 หลายเดือนก่อน

    That's a very good video, thanks !

  • @alx8439
    @alx8439 ปีที่แล้ว

    Amrit, you're amazing in explaining things. You should be a school teacher! Love you

  • @pranab1234
    @pranab1234 2 ปีที่แล้ว +1

    Excellent. Thank you for this.

  • @manuramnishad3028
    @manuramnishad3028 2 ปีที่แล้ว

    You are great sir continue this type video ❤️👍🙏🙏

  • @smacool2975
    @smacool2975 ปีที่แล้ว +1

    Thanks for the fantastic video explanation.. I meant to ask, what is the difference between your way and using interrupt function?

  • @user-me4vu9mt8c
    @user-me4vu9mt8c หลายเดือนก่อน

    an extremely useful and easy to understand guide, keep up the good work!

  • @TheLostPig
    @TheLostPig 2 ปีที่แล้ว +1

    Beautiful work. Thank you

  • @ZookeeperJohnG
    @ZookeeperJohnG 2 ปีที่แล้ว +1

    VERY well explained, Thank You!

  • @theJonnymac
    @theJonnymac 3 หลายเดือนก่อน

    great video, clear, well throught out. Just great!!!!

  • @rajarshimondal1343
    @rajarshimondal1343 5 หลายเดือนก่อน

    This was truly well detailed and informative video, I was going to make a home automation project with a clock in it, this might solve my problem. Thank you so much ❤❤

  • @bipradasmandal6811
    @bipradasmandal6811 2 ปีที่แล้ว

    Great concept & good explanation

  • @m.fadhiilhaekal7693
    @m.fadhiilhaekal7693 9 หลายเดือนก่อน

    Very good explanation tysm

  • @JorgeLuis-po5uq
    @JorgeLuis-po5uq 8 หลายเดือนก่อน

    Very interesting 👌 I will try to make it to my own Arduino thanks 😊

  • @bob-ny6kn
    @bob-ny6kn 2 ปีที่แล้ว +9

    This method of timing has real-world use. The aviation industry uses an inter-device protocol with a "bus list" format with sub loops inside a main loop. You determine priority devices and add hardware interrupts, but the loops continues indefinitely.

    • @teamwinston2902
      @teamwinston2902 8 หลายเดือนก่อน

      yeah thats my problem i have a timer which runs perfectly but i want that my loop also work with that timer but my code stuks in that loop and the timer dont run

  • @bernardgonthier4646
    @bernardgonthier4646 ปีที่แล้ว

    Very very well explained 👏 easy comprehensive speech and pictures. Hope you want to do more sketches off arduino statements.

  • @dougsteel7414
    @dougsteel7414 2 ปีที่แล้ว +1

    Really clear explanation!

  • @mohammadsamer4541
    @mohammadsamer4541 2 ปีที่แล้ว +1

    Excellent explanation, thank you

  • @JB-20
    @JB-20 ปีที่แล้ว

    Thanks for sharing your knowledge.

  • @kushalpoudel392
    @kushalpoudel392 3 ปีที่แล้ว +20

    Who is here before 1 million ?

    • @prashantpant2876
      @prashantpant2876 3 ปีที่แล้ว +2

      Present sir

    • @samithasilruwan5033
      @samithasilruwan5033 2 ปีที่แล้ว +2

      Some code is invisible...

    • @ant-dev
      @ant-dev 2 ปีที่แล้ว +1

      @@samithasilruwan5033 ill show YOU whats not invisible

    • @alexanderpetrov3259
      @alexanderpetrov3259 ปีที่แล้ว

      I'm here watching this with 2K likes and 1K subscribers.

    • @abusufiyan3991
      @abusufiyan3991 8 หลายเดือนก่อน

      Not me

  • @ilijamajcen5426
    @ilijamajcen5426 3 หลายเดือนก่อน

    you have a nice way of explaining. thanks

  • @adipurnama_workshop
    @adipurnama_workshop 2 ปีที่แล้ว +1

    Great explanation, thank you

  • @enthusiasts7278
    @enthusiasts7278 2 ปีที่แล้ว

    it seems very useful, but it's a bit confusing for me. Sir, I wonder if I can use it with 2 codes if there is an ''if'' and ''else" statement, for example, I have combined ultrasonic sensor and water level sensor but the program seems can't run properly. Can you help me, sir?

  • @unitedcolorsofmydick
    @unitedcolorsofmydick 2 ปีที่แล้ว

    Great job indeet. Thanks

  • @artursrikmanis
    @artursrikmanis ปีที่แล้ว

    such a good video!!!❤

  • @TON-vz3pe
    @TON-vz3pe ปีที่แล้ว

    Really helped. Thanks man.

  • @---------______
    @---------______ 5 หลายเดือนก่อน

    This was very helpful, thank you

  • @SamBatti88
    @SamBatti88 2 หลายเดือนก่อน

    Hi, does currentTime starts count when the Arduino is powered ON or when the loop si starting excuting ? Thank you

  • @anokhautomation4453
    @anokhautomation4453 ปีที่แล้ว

    Very very useful tutorial 👍👌

  • @muhammadm1237
    @muhammadm1237 2 ปีที่แล้ว

    Wonderful bro 😎

  • @benbenameur8429
    @benbenameur8429 11 หลายเดือนก่อน

    Is there a way with the millis() for the stepper motor tourn only one revolution?

  • @SiliconSoup
    @SiliconSoup ปีที่แล้ว

    A very important method for embedded design.

    • @amrit5
      @amrit5  ปีที่แล้ว

      Yes it is 🥰😅

  • @abhijitbhoir692
    @abhijitbhoir692 2 ปีที่แล้ว

    Can you show how to use millis with pca9685 to controll multiple servo runnig on overlapping time interval

  • @onezerodev1756
    @onezerodev1756 ปีที่แล้ว

    Good explanation. Thank you

  • @markenciso
    @markenciso 11 หลายเดือนก่อน

    Tysm you did a good job teaching!

  • @govindaaryal2202
    @govindaaryal2202 4 หลายเดือนก่อน

    This is very helpful video, Please make videos for beginners from the basic level.

  • @mohammadrezaoveisi2480
    @mohammadrezaoveisi2480 ปีที่แล้ว

    🔥🔥🔥🔥🔥

  • @mais_it2318
    @mais_it2318 2 หลายเดือนก่อน

    I am curious about what will happen with program, when current time variable will be overloaded. So it will be zero, when previous time is a big number.

  • @teamwinston2902
    @teamwinston2902 8 หลายเดือนก่อน

    bro you have explained very well can i get your help in something ?. i have a timer which operates with 4 buttons and i have function in a loop which will run for 40 seconds . and now i want that my timer and my loop function runs together at same time . can i do that ?

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน

      "and i have function in a loop"
      You mean you have a Loop IN A FUNCTION
      YES YOU CAN DO THAT
      However, instead of killing yourself with Arduino
      Why don't you pop over to ESP32
      Learn about Multi Tasking thefollowing FREE RTOS COMMANDS
      xTaskCreate (Focus on this)
      xTaskCreatePinnedToCore (This is popular but over rated but sometimes useful)
      if that alone doesn't help you , Learn about
      Queues
      Semaphore
      Mutexes
      See, Unlike processes in Arduino, In ESP32 You don't do this...
      void setup()
      {
      }
      void loop()
      {
      }
      Instead you do this
      void setup()
      {
      }
      void Function1()
      {
      YOUR ONE TIME CODE GOES HERE
      for(;;)
      {
      YOUR LOOP CODE GOES HERE
      }
      }
      void loop()
      {
      }
      AND YOU CAN CREATE AS MANY FUNCTIONS AS YOU WANT
      AND EACH FUNCTION CAN BE ASSIGNED PRIORITY with the following line
      xTaskCreate(Function_1, "Function 1", 2000, NULL, 1, &Function1 );
      The priority is the "1"
      this will allow you to dictate which programs runs first, second or at all
      so long as you understand THE TASK STATES OF RTOS
      www.freertos.org/RTOS-task-states.html
      Your problem is greatly simplified if you use ESP32 and FreeRTOS
      In Arduino Functions run BY DEFAULT Sequentially
      In ESP32 BY DEFAULT
      Assuming all Functions are set to the same priority
      THEY ALL EXECUTE AT THE SAME TIME
      There is nothing for you to set
      LOL

  • @user-mh3vj1yg1x
    @user-mh3vj1yg1x 2 หลายเดือนก่อน

    u should try full length arduino master class for beginner to help them out .. ,it would be helpful for sure

  • @Abdelrahman_Hosny
    @Abdelrahman_Hosny ปีที่แล้ว

    Very helpful, Thanks

  • @azmrblack
    @azmrblack ปีที่แล้ว +1

    millis will overflow at some point (iirc 49.7 days) causing an issue of previous vs. current.

  • @raziallahverdiyev6637
    @raziallahverdiyev6637 2 ปีที่แล้ว +1

    Taks

  • @micah2936
    @micah2936 ปีที่แล้ว

    Wow I had no idea. I always thought an interrupt pin was necessary

  • @kevalnakar6269
    @kevalnakar6269 ปีที่แล้ว +1

    Well done brother
    Jay Hind

  • @mezzofresh3521
    @mezzofresh3521 2 ปีที่แล้ว

    Your awesome bro

  • @lewisd56
    @lewisd56 ปีที่แล้ว +2

    using millis() works, but your code will fail after millis() is reset to 0. Another method of achieving pseudo multi-tasking is treating each task as an object containing a few methods to maintain and check an internal counter. A caveat with this is that exact timings can be a little hard to achieve. Say you want to blink an LED every 1 second, you use an object representing the LED task, within this object you have a counter variable, a checkCounter() method and a switchState() method, in your main loop, you call LED.checkCounter() every, lets say 10ms, the checkCounter() method implements the same check as you are doing with millis(), but checks its internal clock, after hitting a threshold of in this case 100, it calls switchState() and resets the counter to 0. as you add more tasks, you simply call their checkCounter() methods one after another in the loop. This avoids messy code in the loop and makes tasks self contained, making your program much clearer. Additionally, you are not having to do maths with unsigned longs, which will take far more clock cycles than a well chosen data type for an internal counter, which in some cases could just be a single byte. Using objects also lets you do other forms of multitasking, such as priority based, you can even maintain a list of tasks that can be added to providing a far more versatile multitasking environment.

    • @ikeabuchi1
      @ikeabuchi1 ปีที่แล้ว

      hint 2's complements for roll ober

    • @lewisd56
      @lewisd56 ปีที่แล้ว

      @@ikeabuchi1 it will still fail, the code is checking 'if greater than', it will fail at the roll over, the first iteration after the rollover will fail, unless you check the absolute difference.

  • @9a1cool
    @9a1cool ปีที่แล้ว

    very good sir!

  • @roshankc6755
    @roshankc6755 3 ปีที่แล้ว

    great

  • @warriorexe3708
    @warriorexe3708 ปีที่แล้ว

    Very helpful : ).

  • @AryanSingh-lo6ng
    @AryanSingh-lo6ng ปีที่แล้ว

    taks

  • @kifahzaidan4505
    @kifahzaidan4505 ปีที่แล้ว

    THANKS A LOT
    CAN YOU PLEASE POST VIDEO FOR THE (CONTROLLING OF DC MOTOR 'ACTUATOR ' PROGRAMABLE POSITION WITH MEMORY BUTTONS USING ARDUINO.
    BEST

  • @4000phil
    @4000phil ปีที่แล้ว

    Clear, simple, effective. What software did you use to create the explanations, for instance at 5:31 when you show the elapsed time. thanks

    • @amrit5
      @amrit5  ปีที่แล้ว

      Generated with python using opencv

  • @soorajjayashankar3768
    @soorajjayashankar3768 9 หลายเดือนก่อน

    😍👍

  • @kkcsynzx6250
    @kkcsynzx6250 ปีที่แล้ว

    How to get different PWM speed Outputs from different pins

  • @mohammedsiddig7975
    @mohammedsiddig7975 2 ปีที่แล้ว

    helpfully!!!!!!!!!!

  • @zubble7144
    @zubble7144 3 หลายเดือนก่อน

    Your code may creep, should the accumulation of run times of the other tasks cause your timer to advance 2 ticks in one trip of loop(). Instead of global prevTime, use prevTime_T1, prevTime_T2, ..., initialize each in setup. Then each task should compare currentTime minus its own prevTime_Tn > its own interval to trigger task code. AND last part of task advances its prevTime_Tn by its interval (iow not set to currentTime). If you desire for the code to be a bit pickier, get currentTime before each task filter.

  • @unglaubichuberlieber8048
    @unglaubichuberlieber8048 ปีที่แล้ว

    gut...sehr gut !!!

  • @thierrybeaulieu4403
    @thierrybeaulieu4403 2 ปีที่แล้ว +3

    Yo I might see a problem with this technique. The way that millis() works is that it's going to use ISR: Interrupt structured routines. Every 1 millisecond, an ISR routine is going to be launch and a timer is goign to be incremented. However, aren't we limited by the a maximum amount of millisecond that an interger can take? Every approximately 65 000 millisecond or 65 secondes, the program would crash because the timer would restart

    • @mihaiocnaru5260
      @mihaiocnaru5260 2 ปีที่แล้ว +3

      There's no problem with it
      everytime the counter reaches it's MAX_INT it rollover to 0 and continue from there
      No code crashes

    • @akirchner3
      @akirchner3 2 ปีที่แล้ว +6

      @@mihaiocnaru5260 No code crash problem, but when millis() rolls over to 0 the comparison of the current value of millis() to the pervious will fail to work as intended

    • @StanleyPinchak
      @StanleyPinchak 3 หลายเดือนก่อน

      ​@@akirchner3depends on how you do the comparison. Unsigned integer types in C++ have wrapping overflow semantics. This means that additions that overflow and subtractions that underflow can still give the correct answer as long as you work with delta t and not absolute t values.

  • @remi19999
    @remi19999 2 ปีที่แล้ว

    Can I use this method when the processes depends on each others and starts if the user sends signal ? Like the user will send signal to activate some continuous servos as chosen by the user (each servo has its own delay) and when the servos start rotating the DC motors will work as well.

    • @amrit5
      @amrit5  2 ปีที่แล้ว

      Yes it will work even when processes depend on each other but having a delay on a process should be avoided for proper functioning.

    • @remi19999
      @remi19999 2 ปีที่แล้ว

      @@amrit5 Actually I understood and tried it , it works but not as I want because my program depends on the user so I want to make constats of time provided by the function millis() because the millis starts counting when the arduino board is on not when the user send the signal to activate the motors ... but its not possible inside arduino loop funcrion to save the current value of milli time. I am thinking of a solution to save the time inside the loop so I can run the DC motor after the servo complete one rotation using the solution you presented.

  • @karenhammon8410
    @karenhammon8410 7 หลายเดือนก่อน

    Another way is to use one delay at the bottom and count the number of cycles of the loop function.

    • @amrit5
      @amrit5  3 หลายเดือนก่อน

      Nice hack

  • @liamstone3437
    @liamstone3437 6 หลายเดือนก่อน

    The one thing I did not catch was how the input of 255 typed into the serial monitor was able to change the value of led brightness.

  • @rushigaikwad7683
    @rushigaikwad7683 2 ปีที่แล้ว +1

    Hello sir can u help me with this problem.....i want to operate 2 relay having 50ms time gap in it when i pushed a button
    i used delay function but it doesnt work can u write code with millis
    i want like this (S=switch, R=relay)
    S1 = R1(50MS)R2
    S2 = R1(50MS)R4
    S3 = R1(50MS)R3
    S4 = R2(50MS)R4
    S5 = R2(50MS)R3

    • @amrit5
      @amrit5  2 ปีที่แล้ว +1

      Fetch the millis code I have mentioned in the video and replace delay function with it. Set 50ms interval and put the second relay operation code inside it.

  • @bencotech9141
    @bencotech9141 ปีที่แล้ว

    thank you so much. the ant is searching for task 5 😅

  • @cksmaya
    @cksmaya 2 ปีที่แล้ว

    THANK YOU

  • @luciferreficul1926
    @luciferreficul1926 3 ปีที่แล้ว +1

    Very cool! One very minor issue in your demonstration from 5:28. Maybe you intended for >= ?

    • @amrit5
      @amrit5  3 ปีที่แล้ว +1

      Thank you for letting me know. I didn't notice that. It should be >=

  • @arduinomaquinas
    @arduinomaquinas ปีที่แล้ว +1

    subscribed to the channel, Like 2.2 K 👏👏👏

  • @mekimr9736
    @mekimr9736 2 ปีที่แล้ว

    Thank you so much))

  • @maokai8310
    @maokai8310 หลายเดือนก่อน

    thank you

  • @susanghimire517
    @susanghimire517 3 ปีที่แล้ว

    Noice

  • @danthor45
    @danthor45 ปีที่แล้ว

    i dond do many dasks ad same dime.

  • @maciejzdrojewski7345
    @maciejzdrojewski7345 ปีที่แล้ว

    Thanks!

  • @jankesik
    @jankesik 2 ปีที่แล้ว +1

    I see one problem :) you don't tell how to fix the max ~25 Days working Error :)

  • @addibbaaj2
    @addibbaaj2 ปีที่แล้ว

    This video is a godsend, thanks for the tutorial mate!

  • @greenplayz3058
    @greenplayz3058 ปีที่แล้ว +1

    hello aryal brother

  • @VoeViking
    @VoeViking 2 ปีที่แล้ว

    I use Metro.h instead of millis

  • @RanaRao_Chandrachur
    @RanaRao_Chandrachur ปีที่แล้ว

    Professor, I have a request, sir 🙏, there are a lot of tutorials about atmega, Arduino and ESP8266 but *what about AT89s52 [8051 families]??* the AT89s52 is a very basic microcontroller that we read in our college,
    and my problem is "I'm making a digital clock [7-segment] using AT89s52 (NO RTC) but the time drifts about 5.6 seconds in every hour!! and this At89s52 microcontroller doesn't have any function like millis() inside AT89s52's IDE(Microvision Keil software), and a book suggests to play with the ppm and fix the error.But, yet the problem is At89s52 is not like Arduino , so Professor, I need your help, can u please make a dedicated video on this?? so that everyone will learn a lot, or u can also help me by writing about the solution below 🙏"
    BTW I'm using a 16MHz crystal with this microcontroller and using timer_0 to generate a 25ms delay and using interrupt_1 to count that 40times so that there will be 1 second completed, but that's not the problem I guess.. I just need your help.. .🙏🙏

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน

      Instead of coming here for the answer
      WHY DON'T YOU GO TO THE ARDUINO FORUM ?
      I also have some advice for you if you go there
      1. THEY EXPECT YOU TO DO YOUR OWN WORK AND RESEARCH THERE
      2. They don't like it when you are in school or Uni and say
      "I have this project...........what's the answer ?"
      We are not there to do your work for you
      We are volunteers on the site
      WE ASSIST YOU........ We don't do the work for you.
      Remember that important point and you'll be fine
      3. When asking a question follow this format
      - Introduce yourself briefly
      - Explain what Hardware you are using and What IDE and Version you are using.
      - Briefly describe the project
      - Explain your problem IN DETAIL
      - EXPLAIN WHAT YOU HAVE DONE SO FAR TO TRY TO FIND THE SOLUTION.
      (if you skip this part, you won't have a pleasant time on that forum) doing this DEMONSTRATES you have done something , and you can't lie because we can tell if you're lying, so make sure YOU ACTUALLY HAVE DONE RESEARCH
      - Post your code USING THE CODE BUTTON, do not just post it to the forum
      (if you don't know how, Ask the forum and they will tell you) there is a button at the top called /Code/ Press that .
      - Provide a schematic of your project, even if it's hand drawn.
      Don't skip this as they will demand it before you get any answer .
      If you do those things, you'll get a lot of assistance
      if you don't you'll probably get told "we don't do your homework for you"
      also, if your code was written by an A.I. DO NOT POST IT, they hate that .
      But coming here to get the answer is not the right thing to do

    • @RanaRao_Chandrachur
      @RanaRao_Chandrachur 7 หลายเดือนก่อน

      @@martinkuliza U wrote these much words for me, Just to help me. 🥺🥺 OMG, u r such a kind and nice person, who gave his time to guide me.
      Thanks brother ❤️❤️❤️
      Love u from India ❤️

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน +1

      @@RanaRao_Chandrachur
      "U wrote these much words for me, Just to help me."
      YES I DID
      "OMG, u r such a kind and nice person, "
      YOU'RE WELCOME, THANK YOU
      Question : Why are you using AT89S52 if that's the problem.
      is it a course parameter that you need to use this architecture.
      if yes... WHY ? What's the purpose of doing it
      if your'e allowed to use another board, i would suggest not Arduino but ESP32 Wroom
      But if it must be that, then 1 thing you can be certain of is this...
      THE LECTURER WILL KNOW THAT A SOLUTION EXISTS
      therefore it can be done
      The lecturer will have a lesson they want to teach you, Know what the lesson is and you'll be closer to the solution.

    • @RanaRao_Chandrachur
      @RanaRao_Chandrachur 7 หลายเดือนก่อน +1

      @@martinkuliza Actually yes, I was learning At89S52. And I got the solution, I will use RTC using I2C interface. There was a solution with the interrupt and using good crystal but they are not even giving decent results, so I decided to use a RTC ds3231 that is temparature independent, means it automatically resolve it's frequency drift based on inbuilt temperature sensor.
      Yes Esp is the best option as it syn using internet.
      And once again Thanks brother stay safe, healthy and happy ❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️

    • @martinkuliza
      @martinkuliza 7 หลายเดือนก่อน +1

      @@RanaRao_Chandrachur
      You're Welcome...
      RE
      "Yes Esp is the best option as it syn using internet."
      I actually wasn't referring to the internet feature of it... but.. Yes you can do that as well

  • @r4bb1t
    @r4bb1t 5 หลายเดือนก่อน

    What is the problem with millis() % 1000 == 0 ?

    • @amrit5
      @amrit5  3 หลายเดือนก่อน

      millis() doesn't stop counting. If you stuck somewhere for 1-2 ms, you'll probably miss it.

  • @Sekhar_Home
    @Sekhar_Home 2 ปีที่แล้ว

    Very nice explained boss.. i will ask some queries regarding my project on ur mail.. pls resond it.

  • @frosty1433
    @frosty1433 3 หลายเดือนก่อน

    Just use interrupts

  • @dallas_barr
    @dallas_barr ปีที่แล้ว

    9:50 There was LITERALLY a bug in your system ! 😀

  • @kythuatphanmem3078
    @kythuatphanmem3078 10 หลายเดือนก่อน

    8:00 task 3

  • @salc9593
    @salc9593 ปีที่แล้ว

    Hello Amrit Aryal, thank you for posting this video as It's been helpful towards my understanding of Arduino coding. Question: I would like to blink the 1st LED 5 times - for (int i=0; i

  • @PoFengChen
    @PoFengChen 9 หลายเดือนก่อน

    Unclear, you did not explain what the millis(). Can you confirm that millis() is the time between START time (program starts) and Current time (command executes).