Arduino Basics 103: Library, Port Manipulation, Bit Math, Faster PWM/ADC

preview_player
Показать описание

You can get Arduino boards here (affiliate links):
Aliexpress:
Ebay:

In this third and final epsiode of the Arduino Basics video series I will talk about how to use libraries, how you can use port manipulation to turn a pin on/off faster and how you can modify the registers of the Arduino µC with Bit Math in order to increase the frequency of the PWM Signal or the sampling rate of the ADC.

Music:
In the Hall of the Mountain King, Kevin MacLeod
Killing Time, Kevin MacLeod
Рекомендации по теме
Комментарии
Автор

Most arduino tutorials go from basics, like turn off/on a pin, flash a LED etc. and by tutorial 10 you're talking fancy talk like using for loops and so on.
With Great Scott though, the complexity is exponential. At this rate tutorial 5 will have us manipulating the universal gravity constant through software.

SireSquish
Автор

1:18 "...or a lazy person like me." If this is lazy we're all screwed.

djtoddles
Автор

I love the handwriting when you explain!

robcean
Автор

Local YouTuber Inincreases his signal frequency to 1MHz using these 2 weird lines. Electricians hate him.

2:25

cwill
Автор

Thanks for listening to us and continuing the series. :)

gautampassi
Автор

Once he started playing Xs and Os at 6:00, that was the moment I knew I was destined for a career at Burger King.

UhtredOfBamburgh
Автор

This video series is definitely very useful! I'll be able to do a lot more due to a better understanding. Thanks!

rikvdmark
Автор

holy shit i didn't understand anything

marwanahmed
Автор

Although this vid is rather old, I enjoyed watching it. I recently spent a lot of time finding this out on myself and experimenting with it. This knowledge is especially usefull when trying to play 8bit sound samples by utilizing the PWM pins and using the ADC respectively. Because you need to switch on Fast PWM and setup the prescaler correctly, this video is a nice introduction for this scenario. Great, Scott!

Tronex
Автор

I don't get anything but i still watch

BlackDawn
Автор

An excellent video. You did cram a lot into 8.22 seconds but it was ALL gold. Other viewers, who found this challenging, might like to view the video again; this time pressing pause at the end of each topic and go back until you have a feel for what Scott is telling you.

The message to be taken from this presentation is that; while the Arduino IDE/"language" does make things seem a lot simpler, it does so by hiding a lot of code in the background. This is fine for flashing LEDs but a lot of the MCU's awesome power is being hidden from you to. When one comes upon applications that need to control, or interface with, many peripherals, one will find the limitations imposed on you by the IDE, limit the applications one can tackle.

Well done, Scott, for dipping your toe into the murky world of AVR programming. Be brave, your subscribers will soon realise that it is just new, not "too difficult" and will be so grateful to you for that lesson.

willofirony
Автор

It's interesting how you say that you are lazy and then you explain parts of atmega datasheet.
Lazy for littles datasheet but ready for Atmega datasheet, like wtf haha :D

salutoitoi
Автор

I really like your videos because they are concise and force you to go deeper to understand the topic.
Congratulations!

bettorapetto
Автор

part 4 next week? looking forward to learning everything about Arduino and what I can do with it. great video as always. keep it coming.

touhvang
Автор

It is not surprising that many of those who commented (Marwan Nasr El Din) didn't 'understand anything because 'Great Scott' used an approach that confused rather than clarified how one can manipulate bits in a status register to achieve a goal. Sorry to be so lengthy, hopefully you don't reply TLDR!


The code to set a 'prescaler' value in 'ADCSRA' was NOT clearly described instead a supposedly 'clever' bit manipulation statement: "byte PS_16 = (1 << ADPS2);" was offered at 6:47. What PS_16 should equal is "100" in binary and 'Great Scott' could have done just that directly using "byte PS_16 = 0b100". Why not? And no where does he describe the value of ADPS2. I have checked the Atmel AVR 328P manual (PDF) and have not found what I found using my own program to print its value: 10 BIN which 2 DEC. Maybe Atmel or C++ use the '2' in the bit label to mean the '10 BIN'. I have found this approach used else where in Arduino code as in WInterrupts.c; however, the novice would likely not know this as I didn't know and I am not a novice.


This means that this statement: byte PS_16 = (1 << ADPS2); is equivalent to "byte PS_16 = (1 << 2);" which shifts left by 2 the '1' which sets PS_16 = 0b100 which is the desired value to use for a prescaler divisor of 16 in the ADCSRA register. ADCSRA is properly set using: " ADCSRA |= PS_16;" statement. Usually, I enjoy these videos but this one truly fails to teach the viewers. Arduino reference has good tutorial on bit math: 'Bit Math Tutorial by CosineKitty'; go there for a good background and write a sketch, too; this is how you will really learn how to manipulate bits.

thorntontarr
Автор

Please create a playlists of Arduino tutorial. I love your tutorial. I have completed the basic electronics series. But unable to find Arduino tutorial playlist.
Thank you.

nomunsheikh
Автор

The "b" in stands for binary I believe.

neutrongiron
Автор

There is two kind of people that watch this video. The ones who want to learn this and, the ones who already know the topic and they just feeling good about that they are able to understand :)

PeterMedvesek
Автор

Definitely like the pace and the details..!! Excellent tutorials..!!

richardsteen
Автор

Love this video. Thank you so much for posting and keep them coming. Love watching all your project videos and tutorials. Really helps me come up with ideas for my own personal projects.

cw