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

Ғылым және технология

Support me for more videos: / greatscott
Previous video: • DIY Soldering Station
Arduino Basics 101: • Arduino Basics 101: Ha...
Arduino Basics 102: • Arduino Basics 102: Co...
Facebook: / greatscottlab
Twitter: / greatscottlab
You can get Arduino boards here (affiliate links):
Aliexpress:
Arduino Uno: s.click.aliexpress.com/e/_dT2...
Arduino Nano: s.click.aliexpress.com/e/_dUL...
Arduino Pro Mini: s.click.aliexpress.com/e/_d62...
FTDI board: s.click.aliexpress.com/e/_dV4...
Ebay:
Arduino Uno: rover.ebay.com/rover/1/711-532...
Arduino Nano: rover.ebay.com/rover/1/711-532...
Arduino Pro Mini: rover.ebay.com/rover/1/711-532...
FTDI board: rover.ebay.com/rover/1/711-532...
Amazon.de:
Arduino Uno: amzn.to/2ljDLFL
Arduino Nano: amzn.to/2ljnq3J
Arduino Pro Mini: amzn.to/2kMv0ly
FTDI board: amzn.to/2ljvuRY
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
(incompetech.com)

Пікірлер: 413

  • @SireSquish
    @SireSquish6 жыл бұрын

    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.

  • @cdurch1

    @cdurch1

    3 жыл бұрын

    Agreed. He went from 101, to 102, (undergraduate classes) to class 506 (doctorate class). I pride myself in being able to at least follow Great Scott in most of his videos, even if I couldn't necessarily repeat what he said... but in this case, let's just say if he comes out with a 104 class I'm going to pretend i didn't see it! LOL

  • @djtoddles8750
    @djtoddles87505 жыл бұрын

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

  • @cwill6491
    @cwill64915 жыл бұрын

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

  • @robcean
    @robcean6 жыл бұрын

    I love the handwriting when you explain!

  • @gautampassi3863
    @gautampassi38637 жыл бұрын

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

  • @greatscottlab

    @greatscottlab

    7 жыл бұрын

    No problem :-)

  • @UhtredOfBamburgh
    @UhtredOfBamburgh5 жыл бұрын

    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.

  • @jasonking1284

    @jasonking1284

    3 жыл бұрын

    Well , you got a choice when you include Macdonalds...

  • @bettorapetto
    @bettorapetto5 жыл бұрын

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

  • @rikvdmark
    @rikvdmark6 жыл бұрын

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

  • @cw41486
    @cw414867 жыл бұрын

    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.

  • @Tronex2009
    @Tronex20092 жыл бұрын

    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!

  • @danielpiotrowski1681
    @danielpiotrowski16817 жыл бұрын

    I am glad to see more advanced arduino topics. I would love to see more!

  • @richardsteen4340
    @richardsteen43404 ай бұрын

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

  • @willofirony
    @willofirony7 жыл бұрын

    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.

  • @drakoky6894

    @drakoky6894

    2 жыл бұрын

    Arduino Is a framework, not an IDE, is different, you can use Arduino framework in many others MCU.

  • @n0t0
    @n0t07 жыл бұрын

    Thank you Scott! This was very valuable to me - you definitely earned my subscription.

  • @dca24100
    @dca241007 жыл бұрын

    Thanks for explaining the different registers clearly. I can use this info to improve some of the projects I have done!

  • @DamaKubu
    @DamaKubu6 жыл бұрын

    Omg I didn't understand a thing back few months but now this is just what I needed. Love ya

  • @dudeskidaddy
    @dudeskidaddy7 жыл бұрын

    Inspiring me to go a little deeper into my arduino projects. Thanks!

  • @BlackDawn
    @BlackDawn7 жыл бұрын

    I don't get anything but i still watch

  • @Gamerdu45

    @Gamerdu45

    7 жыл бұрын

    And you feel kinda bad about it dont you. like me.

  • @dieselgeezer18

    @dieselgeezer18

    5 жыл бұрын

    @@Gamerdu45 Me too :(

  • @shetsanjay

    @shetsanjay

    3 жыл бұрын

    If you are interested not much will stop you from learning. It is a. fun and useful hobby. So go ahead and get some batteries resistors and LEDs. :)

  • @Mippi12

    @Mippi12

    3 жыл бұрын

    @@shetsanjay chill man

  • @Mippi12

    @Mippi12

    3 жыл бұрын

    @@Gamerdu45 go through datasheet , try to understand it. It'll take some time but worth it . That is it.

  • @tdtrecordsmusic
    @tdtrecordsmusic7 жыл бұрын

    Yes, we need more of this kind of stuff !!

  • @rionaldy
    @rionaldy7 жыл бұрын

    Thank you so much Scott! I really need this info for my college assignment

  • @Tracks777
    @Tracks7777 жыл бұрын

    I enjoyed your video :)

  • @cwgreenley
    @cwgreenley7 жыл бұрын

    Very nicely done!

  • @aniketakabir1572
    @aniketakabir15727 жыл бұрын

    awesome as always. Keep up the good content

  • @jneirag98
    @jneirag987 жыл бұрын

    Excellent video! Finally, I can understand the way to change pwm resolution. Thanks you so much!

  • @thesavagedog28t61

    @thesavagedog28t61

    7 жыл бұрын

    lomin 456 😂

  • @DerFailer
    @DerFailer7 жыл бұрын

    Thanks I've learned a lot from your video, even after messing around with arduinos for years :)

  • @RDarrylR
    @RDarrylR6 жыл бұрын

    Cool! I finally understand the bitwise operations in Arduino code now. Thanks!

  • @asadkhan7441
    @asadkhan74417 жыл бұрын

    And again great job and thanks for the video!

  • @touhvang
    @touhvang7 жыл бұрын

    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.

  • @greatscottlab

    @greatscottlab

    7 жыл бұрын

    No, Part 3 was the last part.

  • @cr4zypi3t
    @cr4zypi3t7 жыл бұрын

    Really great video again! I study Applied Informatics in Germany atm (thats why im already familiar with bitmanipulation etc.) and got my first Arduino when I was 14, but never actually thought increasing the performance through bitmanipulation. Man lernt nie aus :)

  • @avejst
    @avejst7 жыл бұрын

    thanks for sharing. Nice to this more geeged way to manipulate the ADC's and PWM output, in a more strait forward way. 👍

  • @electro3976
    @electro39767 жыл бұрын

    Excellent tutorial as always

  • @viniciusfriasaleite8016
    @viniciusfriasaleite80163 жыл бұрын

    What a great video!

  • @rubikon7648
    @rubikon76484 жыл бұрын

    You are great Scott!!

  • @TurbineResearch
    @TurbineResearch3 жыл бұрын

    Your handwriting is absolutely amazing

  • @tb303wpf1
    @tb303wpf111 ай бұрын

    You sir, are the sorcerer supreme. 🧙‍♂️

  • @Maisonier
    @Maisonier3 жыл бұрын

    Amazing videos !!

  • @robertallencad1
    @robertallencad14 жыл бұрын

    You're super duper smart man I'm going to be really studying your stuff thank you

  • @jozef8817
    @jozef88177 жыл бұрын

    great series keep moving forward

  • @piiumlkj6497
    @piiumlkj64975 жыл бұрын

    Well scott , you're great !

  • @RizLazey
    @RizLazey7 жыл бұрын

    ok thanks mr.GreatScott for arduino 103, now i learn much about arduinos ;-)

  • @Escarii66
    @Escarii667 жыл бұрын

    Really helpful video, thanks!

  • @greentea5593
    @greentea55932 жыл бұрын

    Thanks for a great video

  • @algharyafiable
    @algharyafiable7 жыл бұрын

    Thank you very much for your all video always Learning from you helpful useful Thanks

  • @claudiocastillo8235
    @claudiocastillo82355 жыл бұрын

    un gran vídeo amigo, excelente :)!!!

  • @COCCLASHERZ1
    @COCCLASHERZ17 жыл бұрын

    Nice Work!

  • @francescoviscomi4258
    @francescoviscomi42583 жыл бұрын

    most useful tutorial ever

  • @ky-effect2717
    @ky-effect27177 жыл бұрын

    this is extremely useful Thanks!

  • @TrentMurray
    @TrentMurray7 жыл бұрын

    Loving these videos, you have earned a Patreon subscriber!

  • @greatscottlab

    @greatscottlab

    7 жыл бұрын

    Awesome! Thank you.

  • @salutoitoi
    @salutoitoi7 жыл бұрын

    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

  • @UpcycleElectronics

    @UpcycleElectronics

    7 жыл бұрын

    Lazy is a relative term.

  • @UpcycleElectronics

    @UpcycleElectronics

    7 жыл бұрын

    ***** Who has the patience to read the entire datasheet for less than a 6 figure salary? Would you do it for the wonderful KZread comments and around $200 that you get paid over 6 months to a year? ... while working at a full time job? Subjecting yourself to YT comments is like working in the customer service industry. You just do your job for a paycheck while a crowd of ignorant imbeciles feels like they have a right to treat you like a verbal punching bag.

  • @UpcycleElectronics

    @UpcycleElectronics

    7 жыл бұрын

    *****​​ I understand what you mean. When I learned to paint cars it took me forever to wrap my head around estimating time. I finally learned to make an honest assessment of the work, then quadruple it, and I would be right on the money. It's important to learn from both the internal mindset, and for communication with a customer. After being partially disabled, I picked up electronics. Learning those important bits to look for seems quite the challenge without buying a $30k to $50k, 4 year, guided reading program, but I'm probably just slow. I think it takes the right mindset and patience to isolate the necessary details. Sometimes it seems 'lazy' is the person unwilling to get up off the couch, other times it's the person that hasn't read the entirety of "The Art of Electronics." We're all wondering along different parts of the path to understanding this stuff.

  • @Northaxe

    @Northaxe

    7 жыл бұрын

    he probably meant in general

  • @MrJason005
    @MrJason0057 жыл бұрын

    That was a good lecture on bit math

  • @subclox
    @subclox7 жыл бұрын

    I click the "like" button before view. Because I always like GreatScott!'s videos.

  • @blue_name_warrior
    @blue_name_warrior5 жыл бұрын

    greatscott,油管EE科普界专门负责高三总复习的优秀教师

  • @marwanahmed317
    @marwanahmed3177 жыл бұрын

    holy shit i didn't understand anything

  • @RichardEricCollins

    @RichardEricCollins

    7 жыл бұрын

    There is nothing wrong in that. :) And what is cool you get to have the fun learning what it was he was doing.

  • @Gamerdu45

    @Gamerdu45

    7 жыл бұрын

    I think about my school if i should quit now and not suffer in other years i study electrotechnics.

  • @iMiilk182

    @iMiilk182

    7 жыл бұрын

    Gamerdu45 if you like to know this stuff, which I presume you do since we are here, don't quit. Electronics seems hard at the beginning but it gets pretty simple once u understand some concepts. I've studied 3 years as eletronical technician (dont know how to name it in english), now heading to second semester in electronic engineering and I was lost too in the first weeks :)

  • @Gamerdu45

    @Gamerdu45

    7 жыл бұрын

    Thank you i really like this stuff but it is kinda hard for me. But i will try my best.

  • @RichardEricCollins

    @RichardEricCollins

    7 жыл бұрын

    There was a time that I did not know any off it. It takes time to learn but if you keep chipping away you'll get there. I'm no mastermind, just someone who, like you, wanted to learn. Maybe just start with basic logic operators and binary. Once you understand that you'll then will see that all he was doing was flipping some bits on and off. Good luck and above all, have fun learning. :) The buzz you get when the penny drops is awesome.

  • @aljazrozic
    @aljazrozic7 жыл бұрын

    great video

  • @melodeeaaron
    @melodeeaaron7 жыл бұрын

    Very interesting... Reminds me of the "Good Old Days" of programming in assembly to speed up subroutines in a C (or BASIC) program. Brought back a lot of old memories. Not all of them good! I'd like to see a tutorial on interfacing an Arduino to the Dallas/Maxim 1Wire network.

  • @ConnorWidtfeldt
    @ConnorWidtfeldt7 жыл бұрын

    Your handwriting is phenomenal...

  • @vitos1k
    @vitos1k7 жыл бұрын

    This one is very usefull video! Thanks a bunch i always wanted to start converting my slow arduino code to fast code via registers

  • @TheDarknessViper
    @TheDarknessViper7 жыл бұрын

    Thank you very much ! I was using a similar code to that in my multi-level inverter controller digitalWrite(outPin, HIGH); delayMicroseconds(50); but it didn't accept float values , nor variables . I think now i can manipulate your method to make it more accurate

  • @softsouls1
    @softsouls17 жыл бұрын

    you are awesome!

  • @aravindrangavel5131
    @aravindrangavel51317 жыл бұрын

    Bit math section was little confusing .Thanks for your effort scott learnt a lot.

  • @brandondaniels9471

    @brandondaniels9471

    7 жыл бұрын

    Just a little confusing? I had to ice my brain after trying to follow that section.. :-)

  • @sirmiro2
    @sirmiro27 жыл бұрын

    I love this series! I just hope you can make a dimmer for 220V lighting controlled by a pot or some code. :-P

  • @yisussable
    @yisussable7 жыл бұрын

    finally one of his vídeos i do get it completly. just cause i did also read the entire datasheet for a school project 😂

  • @kulgan96
    @kulgan967 жыл бұрын

    it sounds really cool it's a lot more complicated but you can do really cool stuff at a lower level.

  • @thorntontarr2894
    @thorntontarr28944 жыл бұрын

    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

  • @ximos8824
    @ximos88247 жыл бұрын

    i like your ideas

  • @nomunsheikh1312
    @nomunsheikh13125 жыл бұрын

    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.

  • 7 жыл бұрын

    wow! Nice tips, thanks! Now I have to read the 328p datasheet for complementary studying

  • @MCsCreations
    @MCsCreations7 жыл бұрын

    Really nice. :)

  • @thangnguyen4207
    @thangnguyen42074 жыл бұрын

    i love your projects LoL

  • @jairogon81
    @jairogon816 жыл бұрын

    Lazy?!?! I somewhat understood it but I got to practice instead of just watching the video. Your a genius

  • @gauravjoshi747
    @gauravjoshi7477 жыл бұрын

    when i learned​ this things in my engineering class i only concentrate just because of my electronics teacher is hot , this time my mind start boiling but great video great Scott

  • @shahbazkhan-jj7ve
    @shahbazkhan-jj7ve5 жыл бұрын

    relentlessly waiting for ur reply!!!!!!!!

  • @harysantos
    @harysantos4 жыл бұрын

    and if you incorporate the goto loop; at the end it will short the off phase as the rising and get faster frequency

  • @PeterMedvesek
    @PeterMedvesek7 жыл бұрын

    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 :)

  • @federicoscozzafava886
    @federicoscozzafava8867 жыл бұрын

    It would be nice if you could give some insights on how to write efficient code (in particular interrupts, watchdog timer and low power handling)

  • @TheS1l3ntOne
    @TheS1l3ntOne5 жыл бұрын

    It's very very good

  • @Alpatecx
    @Alpatecx6 жыл бұрын

    Arduino is awesome!!!

  • @whitefields5595
    @whitefields55954 жыл бұрын

    Scott. Thanks for doing all this and helping us. It is a bit. Too fast for me though and some of the things you appear to edit out maybe useful after all? It is impossible to get the pace right for everyone, but if you go a bit slower, the bright folk can always increase the speed.

  • @ernievirata2551
    @ernievirata25515 жыл бұрын

    Great ....interesting

  • @mnx4me
    @mnx4me7 жыл бұрын

    Thank you

  • @rkrakib9563
    @rkrakib95637 жыл бұрын

    thank u sir.

  • @lslakhvirsingh1984
    @lslakhvirsingh19846 жыл бұрын

    It's interesting video.

  • @avinashbharti505
    @avinashbharti5054 жыл бұрын

    i am fan of your videos, do you wanna know why ? because its GREAT. Scott.

  • @saulobernal3161
    @saulobernal31615 жыл бұрын

    You do have a EEPROM video tutorial? Your videos are very useful! Thank you so much!

  • @ferdinand5375
    @ferdinand53754 жыл бұрын

    I like to call you "King of Arduino".

  • @williefleete
    @williefleete7 жыл бұрын

    This will be handy for setting unused pins on a mega2560 to non floating/input with pull up. without a whole bunch of digital write or pin mode commands

  • @calyodelphi124
    @calyodelphi1247 жыл бұрын

    I'm definitely going to have to rewatch this a few times over to take notes because all of this is a bit over my head. @~@

  • @codingwithalfred
    @codingwithalfred2 жыл бұрын

    So smart :)

  • @macro312
    @macro3127 жыл бұрын

    Question on the last advance example, was all that bit math used to change the sampling rate? What was the need to keep the bits with X's? (Or was the first 6 bytes toggled for something else?)

  • @r3vis3dsmil39
    @r3vis3dsmil397 жыл бұрын

    From another topic. Will you do a video how to do my own 3d printer from old cd/dvd readers using any magic stuff (can be with 3d pen)? Actually Im bad at these things and ur the only ytber that explains so well everything :)

  • @neutrongiron
    @neutrongiron7 жыл бұрын

    The "b" in bxxxxxxxx stands for binary I believe.

  • @virkotho5057

    @virkotho5057

    7 жыл бұрын

    quite close, but B0111111 is a #defined value (search for binary.h). A binary value can be written as 0b011111 .

  • @dpneber

    @dpneber

    7 жыл бұрын

    Long story short from above convo. BXXXXXXXX will only work with Arduino IDE. Reason is, the actual syntax of XXXXXXXb isn't supported by all Arduino systems, and you can't use a marco that starts with a number in your #define

  • @bur1t0

    @bur1t0

    6 жыл бұрын

    That's pretty much what I remembered, but on checking (with a compiler), XXXXb is not valid syntax (it is valid MASM/TASM syntax, which I think is where I was remembering it from). 0bXXXX is the correct C syntax for this. test.c: In function 'main': test.c:5:29: error: invalid suffix "b" on integer constant printf("int = %d ", (int) 0001b );

  • @cheesecake667

    @cheesecake667

    5 жыл бұрын

    @@virkotho5057 Luckily I new that but I think he should have said it too. Now some people think its the way to write binary numbers

  • @Remy561
    @Remy5617 жыл бұрын

    Great guide, but as I study Embedded Systems I totally get that people never having used bit math or bit masking have no clue what the video is about. I'd definitely like to see if there is even more in depth stuff to learn!

  • @iqbalnurfadhillah9455
    @iqbalnurfadhillah94557 жыл бұрын

    i think you're advanced in arduino..nice info

  • @minanovkiril
    @minanovkiril7 жыл бұрын

    hi scott. you say 101, does this mean that you have another 100 videos on arduino xDD. if you do, i would luv to see them. tnx for all you've done for my knowledge by now. the chennel is awesome. great!

  • @agustinarturoreynososantos1514
    @agustinarturoreynososantos15146 жыл бұрын

    Hello, do you have a video on the basic usage of that oled display?

  • @makeit525
    @makeit5257 жыл бұрын

    I very like u great scott!

  • @Explore-Gobal
    @Explore-Gobal3 жыл бұрын

    My project requires 16 or more leds, for a runway chaser sequence with a very small footprint. I'm trying to simulate runway lights on a small aircraft carrier. Maybe three or four leds, the first one at 100%, second at 75%, third @ 50%, and fourth @25% chasing from left to right in a repeating pattern. As soon as the four leds reach midpoint in the travel direction, another set of four leds follows from the start position, so you will have two sets chasing from left to right, and so on. When the first set reaches the end, it starts over again from the beginning, same with the second set. I have looked all over the web and have had nothing that fits all the criteria. Doing it on an UNO will not work as there just isn't enough room in the model for the large board. 555 timers with a shift register won't work as most don't have a way to make the fading effect. Can you help me with a solution? Thank you.

  • @Really2950
    @Really29507 жыл бұрын

    @GreatScott! Please let us know lots of your opinion. We want to know the reasons behind why you choose one way/thing over another. Also, project suggestion : make a pc power supply into a bench power supply.

  • @linearburn8838
    @linearburn88387 жыл бұрын

    Is there a way to map a digital signal with arduino for instance I want to emulate a NZXT hue+ so what i have in mind is hook a adrino up inline with the hue+ read the digital output for the hue+ led controler and then use the recorded singnal to controle the led's.

  • @greatdaddy4710
    @greatdaddy47105 жыл бұрын

    GREATSCOTT! YOU SHOULD DEFINITELY MAKE A VIDEO EXPLAINING HOW TO BUILD A CIRCUIT, CODE, APP AND ZERO CROSSING CIRCUIT WHICH CAN CONTROL AT LEAST 5 AC LIGHT BULBS AND BE ABLE TO NOT ONLY TURN THEM ON/OFF BUT DIM EACH ONE OF THEM SEPARATELY VIA BLUETOOTH HC-06 AND ANDROID APP. THAT WILL BE A CHALLENGE!!!

Келесі