08 Multitasking in Arduino using millis | Servo Motor and 7-segment Display | Embedded Systems

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

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

  • @sergeiabramov282
    @sergeiabramov282 2 года назад +23

    Man, You were born to teach people, the way You explain is Brilliant! Thank You and please keep doing such amazing videos. God bless You! Respect from Russia.

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

      Thank you very much! Really appreciate your comment.

  • @abhijitroutray1896
    @abhijitroutray1896 Год назад +2

    I don't know how to appreciate you right now only i can say.. thank you so much..❤️🤝🏻

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

    Well Done!!!This is one of the few videos that start by showing the viewer what is the purpose and will be achieved. WELL DONE!!! It is structured as it should be

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

      Thank you very much! 😀

  • @notchos
    @notchos 2 месяца назад

    This video is perfectly explained thank you so much! Im currently in a Robot building event and this is going to save me.

    • @joedgoh
      @joedgoh  2 месяца назад

      Thank you and good luck! Please check my other video lesson on millis.
      ruclips.net/video/zq6tkXCn-j4/видео.html

  • @Engine-Nyandu
    @Engine-Nyandu 4 месяца назад

    This is the kind of explanation I've been looking for for a long time. I'm not even joking, you really did explain the millis function well, cuz I've been struggling with my final year project. But now I realized it was all in the delays. Thank you so much. You've made a new subscriber.

    • @joedgoh
      @joedgoh  4 месяца назад

      Thank you! Glad to be of help 😊

  • @Bit-Jauhari
    @Bit-Jauhari Год назад +1

    Your Tutorial So Clear , Great Explained, Thank you sir ! Respect from Indonesia

  • @Alexis-ev1vh
    @Alexis-ev1vh 2 года назад +2

    Thank you, I've been trying to use for loops simultaneously without using delay and you saved me.

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

      You are welcome

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

    Respect from india 🇮🇳🇵🇭

  • @educationaltechnology8363
    @educationaltechnology8363 Год назад +2

    crystal clear you're talented at explaining stuff. Well done mate!

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

    I love you, I have been searching for this for almost 4 hours

  • @Hardeepsingh-re8xn
    @Hardeepsingh-re8xn 3 месяца назад

    well done sir, excellent video.......thanks for uploading

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

    An excellently produced and very clearly explained tutorial. Many thanks. I have subscribed.

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

      Really appreciate it 😁 thank you!!

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

    You saved me from many headaches down the road I thank you. I kinda wished I would of got to watch this video before starting my program awww we learning… thank you

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

      Glad to be of help 😁

  • @chitobalazo
    @chitobalazo 6 месяцев назад

    Thank you Jeod, I have a clear understanding of this topic. Very interesting.

    • @joedgoh
      @joedgoh  6 месяцев назад

      Thank you!

  • @ChrisWilliams-pu8pj
    @ChrisWilliams-pu8pj 7 месяцев назад

    Great video! Will be watching many more. Excellent presentation!

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

      Thank you! Glad you liked it 😊

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

    Your presentation is very Nice, Easy to understand. good Job you done. Thank You.

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

      Thank you so much 🙂

  • @naboulsikhalid7763
    @naboulsikhalid7763 9 месяцев назад

    a very elegant way of teaching, like being born to be so. The explanations exceed your reputation, man you live up to your name. huge: LIKE AND SUB. I will be your follower. thank you for your effort

    • @joedgoh
      @joedgoh  9 месяцев назад

      Thank you! I appreciate your comment 🙂

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

    Thanks sir you are genius and continue this type video ❤️ I am Indian and love your content

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

      Thanks for the support

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

    Best Arduino multitasking vid ever. Super helpful. Thank you!

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

      Thank you! Pls. Share 🙂

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

    Ang galing mag turo, thanks.

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

    Excelente tutorial. Parabéns!!!

  • @PhuNguyen-we2hd
    @PhuNguyen-we2hd 8 месяцев назад

    Man, You are good from Australia.

    • @joedgoh
      @joedgoh  8 месяцев назад

      Thank you. Glad you liked it 🙂

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

    Love it! Exactly what I need it to know. Thanks

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

      Happy to know!

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

    Thanks

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

    man your video saved my life . Thanks for the great video.

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

      Thanks! Please check my other playlist, it might help you too

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

    Nice explaination

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

    You are a great teacher

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

      Thank you!!

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

    really great ,thanks for the this video

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

    Many thanks 🥰🥰🥰🥰

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

    like the way you, explain and your voice tone
    Can you make a tutorial also about the "Control Structures".. which includes if
    if...else
    for
    switch case
    while
    do... while
    break
    continue
    return
    goto

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

    good day sir
    what about when the push button is pressed and the seven segment will not reset and it will continue to run how to code it?
    thanks

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

    Very nice tutorial

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

    Great Video 🙂

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

    Hello sir "Maraming salamat" for this video😊

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

      Maraming salamat din!

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

      @@joedgoh Sir do you have any facebook site for me to visit?

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

      Sorry, wala pa po. Just this.

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

    Great lesson!!!

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

    Galing, salamat

  • @12torotoro
    @12torotoro 3 года назад

    I was able to figure it out, thanks

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

    Great video how would I be able to use millis() for an ultrasonic sensor and 2 servo motors? I'm trying to make an obstacle-avoiding robot.

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

    Love you man this was what I was looking for

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

    I want to write a code as below and I want to replace delay() function with millis().
    Please can you tell me how to write code for this?
    "
    digitalWrite(column[0], LOW);
    delay(40); //wait for 40ms before start below statement
    digitalWrite(column[1], LOW);
    delay(40);
    digitalWrite(column[2], LOW);
    delay(40);
    digitalWrite(column[3], LOW);
    delay(40);
    "

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

    Thanks, was looking for this.

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

      Welcome! Thanks

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

    Hi I am not able to turn the display on... do u have a circuit diagram or osmething ...plz let me know

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

    GREAT👍 helped me

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

    That a great video

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

    Hi, I enjoyed your video on using Millis(), I would like to know if you have or will have a video on State Machines using Arduino. Thank you for any help you may be able to provide.

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

      Hi, thanks for watching. Sorry but I don't have a video on state machine. I hope my other videos on this playlist can help you with your needs.

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

    Hi Joed. Could you do the same activity using interrupts?

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

    Hello
    when arduino receive angle (number) from Serail for exemple , the stepper motor dont finish distance to go (stop ) because Serial receive next angle . What should I do for arduino receive and let stepper motor finish distance Simultaneously ?

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

    little bit confused. why "d" hasn't been declare in no one of part of sketch in first example (7segment display counter)? it already been in the "for" loop. and it's it.

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

    How to stop the Millis function form looping ? I'm new to Programming , please help sir.

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

    Sir, takbuhan ko talaga vids mo pag may project ako 😭😂

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

      Glad to be of help Chimmie ❤

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

    Thanks!

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

      Thank you very much! ❤️

  • @12torotoro
    @12torotoro 3 года назад

    I'm working on the challenge and I'm having problems on the seven segment display, counting backwards I was able to count from 9 to 0 but when it gets to 0 it does not restart, if I I press the switch it will reset to 9, but when it gets to 0 again same problem. Will it be possible if you post the solutions. Thank you.

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

    Great work

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

    good very informative

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

      Thank you!

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

    hi
    can you plese make it with steeper , i try it but it dose not work . thanx

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

    U are a legend

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

      Thank you very much

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

    how do you make the servo arm return slowly as well?

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

    This is very informative :) Thanks

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

    Very good.....can you add my reference... thank you.,,

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

    hello
    Is there a way with the millis() for the LED tourn ON OFF only 5 ones?

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

      I am sorry, can you rephrase the question? What do you mean by 5 ones?

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

      @@joedgoh millis() infinite loop . i want led turn on off by millis() but just 5 iteration ?

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

      You just have to create a variable that counts from 1 to 5 (increment by one every blink using the millis). Then you can add a condition that your blink code should only be performed while/if the counter

  • @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

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

      It is normal to be confused when you first use this concept. It is okay to use if...else code block. You just have to understand when to properly use it. Using if...else.., only one of these code blocks gets executed at one time. But when you use, if.....if...if..., all conditions could be satisfied and be executed at one time.

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

      @@joedgoh can you check my code

  • @Hirenpanchasara
    @Hirenpanchasara Месяц назад

    Any car Crank and cam signal how to make code explain please

  • @LaxmanSingh-wh9vy
    @LaxmanSingh-wh9vy 2 года назад

    good

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

    gut gemacht !!!

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

    Thumbs up

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

    would like a lesson about array and 2d array if you have time.
    Thanks. examples using 2D array with crystal LCD BIG FONTS for Clock. I am just a newbie to Arduino.

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

      Contact me: joedgoh@gmail.com and send me your specific questions. Thanks!

  • @Hirenpanchasara
    @Hirenpanchasara Месяц назад

    How to make car Crank and cam sensor signal timerone use explain please

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

    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.. .🙏🙏

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

    Thanks, Love it.

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

      Thanks Dean!

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

      @@joedgoh brother please make a video on how to make gps using Arduino

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

      Thank you Deepak. Eventually I will, when I reach topics on IoT

  • @josepheccles9341
    @josepheccles9341 9 месяцев назад

    I use the library called "elapsed millis"

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

    You have online course

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

    actually there is a limitation. When your code gets long enough, and you have to keep the timing precise, this method does not work. As you can see that he used >= instead of ==, this is because as the loop goes on, it will skip a few count, so the longer it runs, the more errors it accumulates. It does not take long to get a 1000x of millis error and your system's diff becomes apparent.

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

    Sr. please make the code bellow becomes millis:
    Void loop () {
    if (digitaRead (tombol)==0){
    digitalWrite (led, HIGH);
    delay (3000);
    digitalWrite (led, LOW);
    delay (3000);
    digitalWrite (led, HIGH);
    delay (3000);
    digitalWrite (led, HIGH);
    delay (3000);
    }
    else {
    digitalWrite (led, LOW);
    }
    }
    How to be version millis Sr..???.

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

    thank you sir btw my i ask are you a Filipino or asian !

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

      Yes both. Filipino

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

    Greetings from Denmark. Thank you for the very interesting video. I was successful with the 1st & 2nd elements - lighting 4&5 and lighting 1to9 with delay . I was not successful with millis! I would be greatly grateful if you could spot an error in my sketch. Note my 7-segment only shows 0 and the switch has no effect. Thank you
    #include
    Servo servo1;
    int digits [10] [7] = { { 1, 1, 1, 1, 1, 1, 0}, //digit 0 //note 3 curly brackets
    { 0, 1, 1, 0, 0, 0, 0}, //digit 1 // note 2 curly brackets
    { 1, 1, 0, 1, 1, 0, 1}, //digit 2 // note 2 curly brackets
    { 1, 1, 1, 1, 0, 0, 1}, //digit 3 // note 2 curly brackets
    { 0, 1, 1, 0, 0, 1, 1}, //digit 4 // note 2 curly brackets
    { 1, 0, 1, 1, 0, 1, 1}, //digit 5 // note 2 curly brackets
    { 1, 0, 1, 1, 1, 1, 1}, //digit 6 // note 2 curly brackets
    { 1, 1, 1, 0, 0, 0, 0}, //digit 7 // note 2 curly brackets
    { 1, 1, 1, 1, 1, 1, 1}, //digit 8 // note 2 curly brackets
    { 1, 1, 1, 0, 0, 1, 1}, //digit 9 // note 2 curly brackets
    } ; //note: semi-colon!
    int d = 0;
    unsigned long startTime_display = 0;
    unsigned long interval_display = 1000;
    int servo_angle = 0;
    unsigned long startTime_servo = 0;
    unsigned long interval_servo = 20;
    void setup () {
    for (int i = 13; i >= 7; i--)
    pinMode (i, OUTPUT);
    pinMode (2, INPUT); //button on pin 2
    Serial.begin (9600);
    servo1.attach (6); //servo pin 6
    }
    void loop () {
    unsigned currentTime = millis();
    Serial.println (currentTime);
    if (currentTime - startTime_display >= interval_display) {
    startTime_display = currentTime;
    for (int i = 13; i >= 7; i--)
    digitalWrite (i, digits[d] [13 - i ] );
    d++;
    }
    if (digitalRead(2) == LOW || d == 10) d = 0; //reset d to 0
    if (currentTime - startTime_servo >= interval_servo) {
    startTime_servo = currentTime;
    servo1.write(servo_angle);
    servo_angle++;
    if (servo_angle == 180) servo_angle = 0;
    }
    }

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

    Hey can u help me for multitasking of our project

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

      I might be able to answer some of your questions, but not really help you in your project.

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

    *Q- Make Arduino millis() equivalent function for 8051 microcontroller*
    Who can write this c code??
    Hint -- Tms/(Fclock*1000)

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

    Wow, Please help me with my problem with delay in my code
    digitalWrite(relay1, LOW);// turn relay 1 OFF
    digitalWrite(relay2, HIGH);// turn
    Serial.println("M1-CW");

    delay(12000);

    digitalWrite(relay1, HIGH);// turn relay 1 OFF
    digitalWrite(relay2, HIGH);// turn
    Serial.println("M1-Stopped");
    delay(random(3000,5000));

    digitalWrite(relay1, HIGH);// turn relay 1 OFF
    digitalWrite(relay2, LOW);// turn relay 2 ON
    Serial.println("M1-CCW");
    delay(12000);
    digitalWrite(relay1, HIGH);// turn relay 1 OFF
    digitalWrite(relay2, HIGH);// turn
    Serial.println("M1-Stopped");
    delay(random(3000,5000));

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

    hindi na ba uso ang ISA card sir? 🤣

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

      Those were the days - life is simple 🤣🤣

  • @0124akash
    @0124akash 9 месяцев назад

    can you make this vdo in Hindi ? please sir

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

    Good Thing I saw this! I have a project similar to this. I do hope you can give me tips and some insights, I really am struggling and already sent to your gmail, Sir. Hope you can help me. Thank you.

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

      I"ll look into this. Thanks

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

      @@joedgoh Your way of teaching should be done nowadays. Makes learning fun and exciting. I pray more professors such as you. God Bless Sir. Respect++

  • @GoatZilla
    @GoatZilla 11 месяцев назад

    this isn't really multitasking and we should stop calling it that. it's more like manual scheduling. which is like one of the worst (if not the actual worst) things about arduino programming.

    • @joedgoh
      @joedgoh  11 месяцев назад

      Multitasking is the ability of a system to execute more than one task in a fashion that is seemingly simultaneous over a certain period of time, and a "Scheduler" plays a crucial part in multitasking. - so when you say that this is just basically scheduling of tasks, you are correct. And this multitasking in Arduino.

    • @GoatZilla
      @GoatZilla 11 месяцев назад

      @@joedgoh Multitasking has a pretty specific definition in computing. The "tasks" are processes and have contexts associated with them. To actually multitask, you switch contexts.
      There's no context switching going on here.
      This is a problem with the Arduino model. You tell people you're mutitasking but you're really not.
      I understand trying to dumb things down for the audience but there should be a practical limit for how far down you go.

    • @joedgoh
      @joedgoh  11 месяцев назад

      Hi @GoatZilla, this is not to argue with you. But to clarify things, Arduino UNO R3 is not similar to your desktop computer or a smartphone. Arduino uses a very simple processor with "no operating system", so it has no way to load and run multiple programs. Although it can only run one program at a time, that doesn't mean we can't manage multiple tasks. We only need to change how we do things. Because there isn't an operating system to help us, we have to do things ourselves. And that is how we do multitasking in Arduino. Yes it is simple, but with this simple concept, our processor is able to handle several separate tasks while staying responsive.
      If you don't want to call it multitasking because of the "technicality" of how it was defined in your computer science class in the context of operating system, that's okay. Thank you for your valuable insights.

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

    i am using millis to control 2 addressable rgb strips but it seems to not work properly could you check out the code
    #include
    #define NUM_LEDS 20
    #define LED_PIN1 2
    #define LED_PIN2 4
    #define COLOR_ORDER GRB
    #define CHIPSET SK6812
    #define BRIGHTNESS 20
    #define VOLTS 5
    #define MAX_AMPS 500
    CRGB leds1[NUM_LEDS];
    CRGB leds2[NUM_LEDS];
    unsigned long startTime_display = 0;
    unsigned long startTime_display2 = 0;
    unsigned long interval_display = 2000;
    unsigned long interval_display2 = 500;
    int j = 0;
    int i = 0;
    void setup() {
    Serial.begin(9600);
    FastLED.addLeds(leds1,NUM_LEDS);
    FastLED.addLeds(leds2,NUM_LEDS);
    FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS,MAX_AMPS);
    FastLED.setBrightness(BRIGHTNESS);
    FastLED.clear();
    FastLED.show();
    }
    void loop() {
    unsigned long currentTime = millis();
    Serial.println(currentTime);
    if(currentTime - startTime_display >= interval_display){
    startTime_display = currentTime;
    for(i=0; i= interval_display2){
    startTime_display2 = currentTime;
    for(j=0; j

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

    I type the code and review many times, say 62 times but still this annoying error display; Compilation error: 'startTime_display' was not declared in this scope, what's wrong, CODE: #include
    Servo servo1;
    //a,b,c,d,e,f,g
    int digits[10][7] = {{1,1,1,1,1,1,0}, //digit 0
    {0,1,1,0,0,0,0}, //digit 1
    {1,1,0,1,1,0,1}, //digit 2
    {1,1,1,1,0,0,1}, //digit 3
    {0,1,1,0,0,1,1}, //digit 4
    {1,0,1,1,0,1,1}, //digit 5
    {1,0,1,1,1,1,1}, //digit 6
    {1,1,1,0,0,0,0}, //digit 7
    {1,1,1,1,1,1,1}, //digit 8
    {1,1,1,1,0,1,1}, //digit 9
    };
    int d=0;
    int servo_angle = 0;
    unsigned long starTime_display = 0;
    unsigned long starTime_servo = 0;
    unsigned long interval_display = 1000;
    unsigned long interval_servo = 20;
    void setup() {
    // put your setup code here, to run once:
    for(int i = 13; i>=7; i--)
    pinMode(i, OUTPUT);
    pinMode(2, INPUT);
    Serial.begin(9600);
    servo1.attach(9);
    }
    void loop() {
    unsigned currentTime = millis();
    Serial.println(currentTime);
    if (currentTime - startTime_display>= interval_display) {
    startTime_display = currentTime;
    for(int i=13; i>=7; i--)
    digitalWrite(i, digits[d][13-i];
    d++;
    }
    if(digitalRead(2) == LOW || d == 10) d=0; //reset d to 0
    if(currentTime - startTime_servo >= interval_servo)(
    startTime_servo = currentTime;
    servo1.write(servo_angle);
    servo_angle++;
    if(servo_angle == 180) servo_angle = 0;
    }

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

      Hi. Your declaration is wrong. You typed star instead of start, as in starTime_display instead of startTime_display.

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

      @@joedgoh Thank you for your reply, Its my fault I got mistake in typing the code. I did your correction but another error come out (Compilation error: expected ')' before ';' token)

    • @JatinMakwana-bn1cj
      @JatinMakwana-bn1cj 7 месяцев назад

      Sir please send the challenges code please

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

    Thanks

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

      Thank you very much!! :)