Going Beyond Arduino # 5, Part 2: Blink using Timer 0

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024
  • In continuing with the theme of blinking LEDs, this video shows the viewer how to use Timer/Counter 0 to generate the time delay between each LED. Some more programming techniques are introduced:
    Running a process as a state machine,
    The switch statement, and
    Writing an interrupt service routine.
    The full video was going to be longer than an hour, so it was split into two parts, this is Part 2. Part 1 is linked below:
    • Going Beyond Arduino #...
    Link to the code:
    github.com/hol...

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

  • @garyrowlands8537
    @garyrowlands8537 7 ปีที่แล้ว

    Hi Craig, great video, interesting and informative as all your videos are. Thank You.
    I have completely moved over to AS7 now and while the learning curve is not small, the rewards are starting to happen and for sure I am helped by what you are putting up here in youtube.
    Regards

    • @craighollinger9972
      @craighollinger9972  7 ปีที่แล้ว

      Thanks for your comment. It all gets easier as you lay down the groundwork.
      I certainly don't mean to dis the Arduino coding system as it is a great place to get started, but it does have it's limitations.

    • @garyrowlands8537
      @garyrowlands8537 7 ปีที่แล้ว

      Im sure nobody thinks you are dissing Arduino. It is a fantastic resource however, there are tools for jobs and some jobs need specific tools.
      I am currently putting together a few clips setting out some of my learning experiences and hope to pass on in a similar manner to yourself. :)
      I have only been doing the whole Arduino then to 'C' journey for 6 months now but it's like the biggest game of three dimentional chess I could imagine.
      Learn the rules and the playing field, then just let your imagination go. Should have done it years ago, bt, better late than never.

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

      Good luck with your channel. Making videos is fun.

  • @schwartzenheimer1
    @schwartzenheimer1 4 ปีที่แล้ว

    Excellent.

  • @SA-oj3bo
    @SA-oj3bo 6 ปีที่แล้ว

    Explained very well, thanks!

    • @craighollinger9972
      @craighollinger9972  6 ปีที่แล้ว

      Thanks!

    • @SA-oj3bo
      @SA-oj3bo 6 ปีที่แล้ว

      Do you know a good beginners course for ATSAMD21? Kind regards.

    • @craighollinger9972
      @craighollinger9972  6 ปีที่แล้ว

      You could start here: th-cam.com/users/AtmelCorporationvideos. There are some videos specific to the ATSAMD21, but you will have to hunt for them. Fair warning, you'll be on a steep learning curve. It's a lot more complex processor than the ATMEGA328.
      Good luck!

    • @SA-oj3bo
      @SA-oj3bo 6 ปีที่แล้ว

      yes I think it is very complex, especially the USB part is new, I hoped you would offer some course maybe :-) because I saw links to ATMELSAM in your studio window :-) Thanks!

    • @craighollinger9972
      @craighollinger9972  6 ปีที่แล้ว

      You did as I'm currently designing a product that will use the ATSAMD21 chip, so I'm getting familiar with it. Problem is, making videos takes a lot of time and I don't have much to spare right now. Something for me to keep in mind in the future when I get more time.

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

    thanks

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

    You never did initialize ledState. The 'default' case would be an excellent use for this. If ledState starts with random number greater than ledState6, default case sets it to ledState0.

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

      No need to explicitly initialize ledState, this is done in cstartup() before main() is called. It will be zero (ledState0) when the program starts. Good programming practice would dictate though, ledState be explicitly initialized to zero in the declaration (ie: uint8_t ledState = 0;).

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

      @@craighollinger9972 Thanks for the reply. I didn't know about cstartup(). Why did you specifically initialize the var for LED_DELAY_COUNT? Habit?

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

      @@CollinBaillie ledDelay needed to be a specific value other than zero before the program started. I could have used a statement in main() to initialize it (eg: ledDelay = LED_BLINK_TIME;) but the way I did it is a shortcut. BTW: cstartup() will only initialize global variables (those declared outside of functions) or variables declared as static inside functions.

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

    Excellent series! After watching this I studied it very slowly and inched through it over and over again making sure that I understood every little detail and then I decided to try and port it over to an ATMEGA32 that I had laying around and I learned a ton! Thanks for the content! I posted a 12 second clip of my successful ATMEGA32 experiment at th-cam.com/video/B08lzcjfIaA/w-d-xo.html

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

      Glad you got something out of my video. Good luck on your future endeavors in the ATMEGA world.