Your visual props and paper, clear voice and audio, pacing, sequencing, spiriling, and script are SO HELPFUL. You are a really good teacher. Whereever you work, you deserve a raise, promotion, and an assistant. Go get 'em tiger!
OOooof. This description is good. If you want great instructions, then watch Ben Eater's channel. There he designed an eight bit computer from scratch. He introduces each concept slowly and sometimes will make an intentional "mistake" along the way.
Long before Arduino came, we MCU programmers had always been doing this. Took quite a while to learn all those bit banging, but it was worth the time spent. Anyway, good tutorial. :)
@10:40 it is a better practice to manipulate the DDR register value by using the OR logic. For example, DDRD = DDRD | B00100000; would be a better practice because digital pins 0 and 1 aren't supposed to be meddled with as they're used for serial communication.
It's nice how you saved almost half the flash memory space, that's one nice perk of programming in a lower level language. It's just ridiculous how you did not mention literally that it will run much "faster" than Arduino "overhead". All in all, this is an excellent tutorial with zero confusion and explanation about making use of microcontroller registers using the bitwise operators.
Arduino uses the same avr gcc standard library - that means you can also use direct register access if you don't like digitalwrite >you saved almost half the flash memory space and i don't have serial print for debugging or millis for making a state machine, now i have to waste my time to get that working ...
This perfectly demonstrates the benefits of more abstract programming languages: they are more readable and less prone to bugs. It also demonstrates benefits of avoiding abstract languages in microcontrollers. Damn! Now I need to rewrite all my code 😉
The 660 page monstrosity is what enthusiasts read and understood before meta languages and corporations made money making things more high level, easier to understand, and also slower and less efficient. Now you make videos explaining what a register is. Edit: Alright, I was kind of salty. This is a pretty good video that goes into depth and is quite understandable. Have a like.
Another thing I found amazing, was the SPEED increase from doing multiple digital writes to being able to write multiple pins directly at once (as long as they are on the same port letter). It wasn't just "faster" it was Monumentally faster. When dealing with multiplexing Multiple 7 Segment LEDs, the "off segments went from having a ghost of the previous figures to being very sharp.
Brilliant! I'm in the stage of shrinking Uno projects to the ATTiny85 chip and this was invaluable. That being said, I should have watched the entire video before trying the sample code. Especially the part where the pull up resistor was turned off and I spent a half hour wondering why my LED was coming on by itself lmao.
Brilliant...nothing against adafruit...but here is the beginning of you not having to depend on another library maker for code! As an an exercise you can look at the low-level libraries that are out there and it would look more like the code in the video...great for learning! :-D
So good to have machine level programming being taught so well, hopefully this will help understanding of how micros work in reality rather than point and click abstraction it is for most programmers. Do you know of a good optimising compiler for Arduino, that can produce this level of optimised coding?
Haha you say old code but the Arduino IDE uses this method for programing the atmega32p board. PinMode() is one of the functions from the arduino IDE. This type of "old code" makes you arduino more efficient and accurate.
This is awesome! Please more tutorials on this topic. If you can,please add some references to books or so, so beginners can catch up on this topic. 👌👌
4 ปีที่แล้ว +2
Thanks for explenation. I have a question: how can we do bitwise operation if the button pin is (let say) pin 12 (PB5), and ledPin is pin 12 (PB4). I mean in digitalRead part. Do we still have to define ledPin as output ? (Because of DDRB =001000, all other pins exept 5, are inputs. )
@17:00, you spend a bit of time determining the value of a bit. The AND isolates the bit, but that's as far as you need to go. Since it also ensures every other bit is '0', all you need to do is test for non-zero (usually the second fastest test in a microprocessor). i.e. If The shift you use to test for equal to '1' is unnecessary. "HIGH" and "LOW" are typically macros for non-zero and zero, respectively. If that's how the Arduino library defines them, you woudn't even have to change your If statement.
Thank you very much for your episode, but I am still having another trouble while trying to connect two sensor in one raspberry pi board. May you please help, especially changing the address!
Really helpful video. But I have a doubt. By manipulating registers, how can we generate pwm signals. Basically I am asking for the replacement of the "analogWrite()" function. Thank you for the help.
Wait a moment! You are removing the pull-up resistor from PORTD (12:30 - 12:35). You might run into an issue here, making the Arduino unable to recognize that you release the button (input pin stays at 0V). Or am i interpreting this the wrong way? You have to set/clear ONLY the 32's position bit on PORTD when you turn the LED on/off...
The Arduino.h file has the bitRead, bitSet, bitClear, bitToggle, and bitWrite definitions that do all the bit shifting, we just enter the register and the bit
YT channel 'Joop Brokking' posted this project in 2016. Arduino makes code "human readable", in that it makes sense to beginners. The Arduino IDE is great to get acquainted with embedded, I'm 100% stoked its out there, but to make it to the 'real world project level' you have to manipulate registers without the crazy 'Playground' overhead. If you want to be freed from GitHub, you will have to learn to read the data sheets yourself, and not expect others to do the work for you. Bottom line, an ATMega328 costs less than a buck ($1) and you can get 'Blinky' working for less than 1% of the available space using a better IDE.
Remember that Arduino isn't a compiler, it's a framework that provides an abstraction layer for dealing with microcontroller functions (think of it like a collection of libraries). If you dig into the Arduino source code and look at the digitalWrite() function (github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_digital.c ), you'll see that there a lot more checks and pieces of code than just flipping bits in a register. This is what abstraction does--it makes something easier to use at the expense of speed and code size.
I come from the PIC world. Pretty much all the codes are direct register manipulation. digitalWrite() and digitalRead(), are too slow in that world too. TRIS and PORT are data direction and port registers in PICs. TRISA and PORTA are for port A as an example. Also, there is a compiler that Arduino uses. I don't remember the name, maybe avr-g++, but I know its open source.
Arduino uses whichever compiler is needed for the target microcontroller. If it's an AVR (such as the 328p), then it uses avr-g++. If it's an ARM core, then it might use something like arm-none-eabi-g++.
Nice video, I had experienced ur course on arduino helped me learn a lot if possible please come with another course on register programming on Udemy thanks for this video
Doing it by registers also makes accessing those input pins a lot faster, fairly sure the number I saw was ~56uS for DigitalWrite and using that register method brings it down to 5uS. I will find the name of the video and put it on this comment.
Hello Sir, would it be possible to write a variable (integer for example) to one of the Arduino registers and then reading the register from a PLC using modbus (through RS485 shield)? Or, is it possible to write a variable from Arduino directly into a PLC register using modbus?
The |= operator says to bitwise OR the value to the left of the operator with the value to the right and then store the result back in the value on the left. It's known as a "compound assignment operator." For example: a |= b; is the same as writing: a = a | b; Hope that helps!
I know this was a wonderful explanation. But I understood nothing. What am I missing and where do I learn it? I don't know how to interpret matter on data sheets and the terminology for starters.
What can be slightly confusing to new users, are when you are using IO pins that are not "inline" with the port Pins. Example IO pins 8 thru 13 are PINB 0 thru 5. So instead of defining the Variable as the IO pin you would want to define them as the PINB pins... So for a button hooked to IO pin 8 you would want variable as such const int bnt_pin = 0; Not const int bnt_pin = 8;
What are the little bins usually used for? Or were they made specifically for the purpose of illustrating bits? Can't think of anything that small needing a mini bin.
They are often sold as containers for SMD components, although not-removing the components from their tape reel in the first place is a better way of storing them.
Wow, I didn't know you could do this with a arduino! What would be the point of using registers on code when it does the same thing as the normal code? Am I missing something here?
Hi, Thanks a lot, its really greate effort and great knowledge. i need to do a project for a preset position linear actuator with a DC motor abd a stepper motor, with Arduino Mega or UNO but i am not able to write the code and the scheme, can you please help. Regards
What for you wrote >>btn_pin in the first line of the loop at the end of the line: int btn= (PIND & (1 btn_pin; when we have: const int btn_pin=2 and int btn is already assigned: int btn= (PIND & (1
I have a question how can I a 2 robot arm project and a motor vehicle project in one arduino uno is it possible to make it happen..?? I have been working on it for months and no use for it I don’t know if my codes is right or it won’t work ...please help me..!!
You are correct in that I did not mention high impedance mode, so thanks catching that. In AVR, high-Z is accomplished by setting the corresponding bits for DDRx and PORTx to 0, which is the same as setting the pin to input with no pull-up. So, while tri-state does exist for AVR, it's also considered an input mode. See section 1.3 in this excerpt from an AVR Primer book: bit.ly/2r2zZa1
Can someone explain why he is bit "shifting"? He says it's to retain changes made by other things while still changing the bit you want, but I can't comprehend how bit shifting accomplishes this for any case other than this specific function, which is better accomplished by just writing the bit... It sounds like a very good way to accidentally put 1's and 0's where they don't belong and disrupt other functions. WHY? You can just 'OR' it with B00000010
>WHY? You can just 'OR' it with B00000010 you can. BUT if you want to use the Bit NAMES from the avr gcc standard library then you need the bit shifting because the define constants of the bit names were not defined as the bit pattern like B00000010, the designers of the library defined the BitNames with the bit number. Like: #define FOOBIT 4 so if you want to use the defined name FOOBIT you have to turn that into your bit pattern with: (1
Hi Shawn, Awesome video, but three details that you skipped over in my opinion, (that are quite important for beginners): 1) the bit-shift to select the bit for ANDing or ORring is evaluated by the compiler while compiling and is not actually shifted by the processor-code in run-time (and therefore is exactly the same byte-code as an explicit 8-bit OR-mask): So _switches_port = switches_port [bitwiseAND] 1
1) I did not realize that the compiler actually optimizes the shifting operation. Can you tell me how this is done or point to some docs that explain it? 2) AVR uses the _BV() macro to make the code easier to read for shifting operations, which is why I show it at the end of the video. However, it's unique to the architecture/manufacturer, whereas knowing how to bit shift is more universal (which is why I showed it first).
tibor bogi aaah, that makes sense as to how the AVR compiler can optimize bit setting/clearing. It's been a long time since I've touched AVR assembly, so I had forgotten about those instructions!
Go to 5:25 and he talks about the three registers you need to be concerned with. DDRx, PORTx, and PINx. The "x" in this example is referring to the "D" port. At 6:55 he addresses this register directly.
The next episode is up! Learn about external interrupts in Arduino: th-cam.com/video/J61_PKyWjxU/w-d-xo.html
Your visual props and paper, clear voice and audio, pacing, sequencing, spiriling, and script are SO HELPFUL. You are a really good teacher. Whereever you work, you deserve a raise, promotion, and an assistant. Go get 'em tiger!
This is a great reference. Actually this is the first reference I found is comprehensive enough for me to understand the registers. Great job!
OOooof. This description is good.
If you want great instructions, then watch Ben Eater's channel. There he designed an eight bit computer from scratch. He introduces each concept slowly and sometimes will make an intentional "mistake" along the way.
It's amazing to see that what I'm learning in school actually relates to something really fascinating and useful. Well done!
Awesome video. That was the best explanation I've seen on the matter.
Thank you! Trying to figure out how to explain registers proved to be quite difficult. Glad to hear it helped!
Long before Arduino came, we MCU programmers had always been doing this. Took quite a while to learn all those bit banging, but it was worth the time spent. Anyway, good tutorial. :)
@10:40 it is a better practice to manipulate the DDR register value by using the OR logic. For example,
DDRD = DDRD | B00100000;
would be a better practice because digital pins 0 and 1 aren't supposed to be meddled with as they're used for serial communication.
It's nice how you saved almost half the flash memory space, that's one nice perk of programming in a lower level language. It's just ridiculous how you did not mention literally that it will run much "faster" than Arduino "overhead". All in all, this is an excellent tutorial with zero confusion and explanation about making use of microcontroller registers using the bitwise operators.
Arduino uses the same avr gcc standard library - that means you can also use direct register access if you don't like digitalwrite
>you saved almost half the flash memory space
and i don't have serial print for debugging or millis for making a state machine, now i have to waste my time to get that working ...
This perfectly demonstrates the benefits of more abstract programming languages: they are more readable and less prone to bugs. It also demonstrates benefits of avoiding abstract languages in microcontrollers. Damn! Now I need to rewrite all my code 😉
one of the most advanced Arduino tut I have ever seen. thank you a lot.
I have never ever seen such a positive feedback command section before. It really is an iconic video!
This is the best explanatory bit math lesson i ever followed. Thanks very much Sir.
The 660 page monstrosity is what enthusiasts read and understood before meta languages and corporations made money making things more high level, easier to understand, and also slower and less efficient.
Now you make videos explaining what a register is.
Edit: Alright, I was kind of salty. This is a pretty good video that goes into depth and is quite understandable. Have a like.
If only I could hit Like every time I'm watching this video without dropping my previous one... Thank you!!
The most wonderful thing I've seen in a long time.
As an engineering student, this video was interesting and helpful ! Thank you.
Another thing I found amazing, was the SPEED increase from doing multiple digital writes to being able to write multiple pins directly at once (as long as they are on the same port letter). It wasn't just "faster" it was Monumentally faster. When dealing with multiplexing Multiple 7 Segment LEDs, the "off segments went from having a ghost of the previous figures to being very sharp.
This is true. Manually working with registers saves you clock cycles in addition to program space.
feels like I'm enlightened! expecting more of this kind of videos! really really thankful to you!
This is the exact video I’ve been searching for to begin my bare metal journey. I wanna know all the tiny details in every nook and cranny.
Brilliant! I'm in the stage of shrinking Uno projects to the ATTiny85 chip and this was invaluable. That being said, I should have watched the entire video before trying the sample code. Especially the part where the pull up resistor was turned off and I spent a half hour wondering why my LED was coming on by itself lmao.
Brilliant...nothing against adafruit...but here is the beginning of you not having to depend on another library maker for code! As an an exercise you can look at the low-level libraries that are out there and it would look more like the code in the video...great for learning! :-D
Awesome Video! Very cool Idea with the Containers to show how to set the bits
So good to have machine level programming being taught so well, hopefully this will help understanding of how micros work in reality rather than point and click abstraction it is for most programmers.
Do you know of a good optimising compiler for Arduino, that can produce this level of optimised coding?
title should be: "level down your arduino code"
With subtitle: "Speed up your code to whole new level"
LOL that's fantastic. Love it!
you mean "old level" ahaha
Level up i think ! Because much motlre dificult to trace and understanding.
Haha you say old code but the Arduino IDE uses this method for programing the atmega32p board. PinMode() is one of the functions from the arduino IDE. This type of "old code" makes you arduino more efficient and accurate.
brilliant explanation. I look forward to seeing the follow-up video(s).
Please upload more about data register.
Great explaination !. but could you explain the analogwrite and analogread funcutions ?
I watch for two minutes and I try to like only to see I’ve already liked.
Awesome. A real expert who masters Arduino, and much more for sure.
This is awesome! Please more tutorials on this topic. If you can,please add some references to books or so, so beginners can catch up on this topic. 👌👌
Thanks for explenation. I have a question: how can we do bitwise operation if the button pin is (let say) pin 12 (PB5), and ledPin is pin 12 (PB4). I mean in digitalRead part. Do we still have to define ledPin as output ? (Because of DDRB =001000, all other pins exept 5, are inputs. )
This is an UNBELIEVABLY AWESOME TUTORIAL!!! thank you thank you thank you thank you!!!
GOD. That was so clearly put together. THANKS.
all stuff get simpler with good analogy, thanks a lot sir
@17:00, you spend a bit of time determining the value of a bit. The AND isolates the bit, but that's as far as you need to go. Since it also ensures every other bit is '0', all you need to do is test for non-zero (usually the second fastest test in a microprocessor). i.e. If The shift you use to test for equal to '1' is unnecessary. "HIGH" and "LOW" are typically macros for non-zero and zero, respectively. If that's how the Arduino library defines them, you woudn't even have to change your If statement.
Really good tutorial. As I'm new to all of this, it takes a bit to wrap around my head...
Builder's Mark newbie here too. I watched and now I’m so confused I’m thinking I need to go back to the basics... wait. Where are the basics?
That's funny. I'm writing down in my notebook as when I was at school.
Thanks, professor!
Nicely done, great example and pretty quick pace.
Thank you very much for your episode, but I am still having another trouble while trying to connect two sensor in one raspberry pi board. May you please help, especially changing the address!
Useful video. We love it. Thanks SparkFun 🙏
Great video!!! Learned a ton from this video! I’ll definitely be downloading and saving this lesson! Thanks for explaining this. 👍
very well explained, thank you for putting so much effort!!!
Really helpful video. But I have a doubt. By manipulating registers, how can we generate pwm signals. Basically I am asking for the replacement of the "analogWrite()" function. Thank you for the help.
Wait a moment! You are removing the pull-up resistor from PORTD (12:30 - 12:35). You might run into an issue here, making the Arduino unable to recognize that you release the button (input pin stays at 0V). Or am i interpreting this the wrong way? You have to set/clear ONLY the 32's position bit on PORTD when you turn the LED on/off...
The Arduino.h file has the bitRead, bitSet, bitClear, bitToggle, and bitWrite definitions that do all the bit shifting, we just enter the register and the bit
but that can't set multiple bits in one command
really good job with all your videos they a treat to watch.
If you're trying to save space and execution time, just use PORTD = B0010000 & PORTD; Saves two instructions and 3 or 4 clock ticks.
Excellent video Shawn! Definitely was a good refresher for me. :)
Most welcome, and glad it helped!
YT channel 'Joop Brokking' posted this project in 2016. Arduino makes code "human readable", in that it makes sense to beginners. The Arduino IDE is great to get acquainted with embedded, I'm 100% stoked its out there, but to make it to the 'real world project level' you have to manipulate registers without the crazy 'Playground' overhead. If you want to be freed from GitHub, you will have to learn to read the data sheets yourself, and not expect others to do the work for you. Bottom line, an ATMega328 costs less than a buck ($1) and you can get 'Blinky' working for less than 1% of the available space using a better IDE.
This is awesome! Thank you for the amazing tutorial.
I'm not clear as to why the Arduino compiler doesn't do this optimization by itself?
Remember that Arduino isn't a compiler, it's a framework that provides an abstraction layer for dealing with microcontroller functions (think of it like a collection of libraries). If you dig into the Arduino source code and look at the digitalWrite() function (github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_digital.c ), you'll see that there a lot more checks and pieces of code than just flipping bits in a register. This is what abstraction does--it makes something easier to use at the expense of speed and code size.
I come from the PIC world. Pretty much all the codes are direct register manipulation.
digitalWrite() and digitalRead(), are too slow in that world too. TRIS and PORT are data direction and port registers in PICs.
TRISA and PORTA are for port A as an example.
Also, there is a compiler that Arduino uses. I don't remember the name, maybe avr-g++, but I know its open source.
Arduino uses whichever compiler is needed for the target microcontroller. If it's an AVR (such as the 328p), then it uses avr-g++. If it's an ARM core, then it might use something like arm-none-eabi-g++.
Got it. Makes sense. Thanks.
good at reducing memory usage thanks for the tutorial
Can you share the data sheet
Nice video, I had experienced ur course on arduino helped me learn a lot if possible please come with another course on register programming on Udemy thanks for this video
I finally understood registers. Great video!
Doing it by registers also makes accessing those input pins a lot faster, fairly sure the number I saw was ~56uS for DigitalWrite and using that register method brings it down to 5uS. I will find the name of the video and put it on this comment.
Profoundly useful information presented clearly. Thank you!
I like your videos and learn a lot. Appreciate for that.
Hello Sir, would it be possible to write a variable (integer for example) to one of the Arduino registers and then reading the register from a PLC using modbus (through RS485 shield)? Or, is it possible to write a variable from Arduino directly into a PLC register using modbus?
What's the difference between:
DDRD|=(1
The |= operator says to bitwise OR the value to the left of the operator with the value to the right and then store the result back in the value on the left. It's known as a "compound assignment operator." For example:
a |= b;
is the same as writing:
a = a | b;
Hope that helps!
@@ShawnHymel In the first example of his original question:
DDRD|=(1
@@danblankenship5744 correct, you are telling the register to change its value in the second example.
Very good explanation. Goodjob
I know this was a wonderful explanation. But I understood nothing. What am I missing and where do I learn it? I don't know how to interpret matter on data sheets and the terminology for starters.
where do you get the arduino base in 8:16?
Awesome...make video on PWM control and Serial communication in Arduino by using Registers(port manipulation)...Advance Thanks...
What can be slightly confusing to new users, are when you are using IO pins that are not "inline" with the port Pins. Example IO pins 8 thru 13 are PINB 0 thru 5. So instead of defining the Variable as the IO pin you would want to define them as the PINB pins... So for a button hooked to IO pin 8 you would want variable as such const int bnt_pin = 0; Not const int bnt_pin = 8;
What are the little bins usually used for? Or were they made specifically for the purpose of illustrating bits? Can't think of anything that small needing a mini bin.
Pills.
They are often sold as containers for SMD components, although not-removing the components from their tape reel in the first place is a better way of storing them.
Wow, I didn't know you could do this with a arduino! What would be the point of using registers on code when it does the same thing as the normal code? Am I missing something here?
Hi,
Thanks a lot, its really greate effort and great knowledge.
i need to do a project for a preset position linear actuator with a DC motor abd a stepper motor, with Arduino Mega or UNO but i am not able to write the code and the scheme, can you please help.
Regards
Why the register codes completely doesn't work on my Arduino mega 2560? Is that because of pin issues?
this is good like really really good. I NEED MORE
It was very nicely done
What for you wrote >>btn_pin in the first line of the loop at the end of the line:
int btn= (PIND & (1 btn_pin;
when we have: const int btn_pin=2 and int btn is already assigned:
int btn= (PIND & (1
I have a question how can I a 2 robot arm project and a motor vehicle project in one arduino uno is it possible to make it happen..?? I have been working on it for months and no use for it I don’t know if my codes is right or it won’t work ...please help me..!!
4m47s
There are three possible states for a GPIO-pin, not two as told.
A pin can be digital in, digital out or high impedance.
You are correct in that I did not mention high impedance mode, so thanks catching that. In AVR, high-Z is accomplished by setting the corresponding bits for DDRx and PORTx to 0, which is the same as setting the pin to input with no pull-up. So, while tri-state does exist for AVR, it's also considered an input mode. See section 1.3 in this excerpt from an AVR Primer book: bit.ly/2r2zZa1
I use int sw = PIND & ( 1 > boton; for read a digital port, but if I need Read an analog port witch registers what need to do?
Excellent explanation i had met so far, thank you,
Excellent tutorial! Thank you sir!
This was fantastic! Thank you. I learned a lot.
really great video, thanks a lot!
where can i find the pdf for it and can you put the mega register onto a arduino uno?
how can I write in RFM69HCW registers ?
0 FOR INPUT, 1 FOR OUTPUT? OR VICE VERSA . WILL IT CHANGE FOR EVERY uCS
Can't wait for part 2!
could you provide a link for the datasheet
here you go mate!
www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf
Sorry but I wanted to ask what is the use of using binary when u already have inbuilt commands?
@Unknown Kapa Thanks got it. 😁😁😁
can you give me the souce code of avr .
are the code register worked in esp8266?
Very great explanation. Thank you
Never thought about that, thanks for making this this video!!!
3:20 Have to correct (? or solicit an explanation for ?) the leftmost-memory map: 0x03fff is only 16K, not 32K. Just sayin' ....
16k addresses, each one is 16bit / 2Bytes, (top of that column,)
so 32kB of program memory.
Can someone explain why he is bit "shifting"? He says it's to retain changes made by other things while still changing the bit you want, but I can't comprehend how bit shifting accomplishes this for any case other than this specific function, which is better accomplished by just writing the bit... It sounds like a very good way to accidentally put 1's and 0's where they don't belong and disrupt other functions. WHY? You can just 'OR' it with B00000010
>WHY? You can just 'OR' it with B00000010
you can. BUT if you want to use the Bit NAMES from the avr gcc standard library then you need the bit shifting because the define constants of the bit names were not defined as the bit pattern like B00000010, the designers of the library defined the BitNames with the bit number.
Like: #define FOOBIT 4
so if you want to use the defined name FOOBIT you have to turn that into your bit pattern with: (1
Hi Shawn, Awesome video, but three details that you skipped over in my opinion, (that are quite important for beginners):
1) the bit-shift to select the bit for ANDing or ORring is evaluated by the compiler while compiling and is not actually shifted by the processor-code in run-time (and therefore is exactly the same byte-code as an explicit 8-bit OR-mask): So
_switches_port = switches_port [bitwiseAND] 1
1) I did not realize that the compiler actually optimizes the shifting operation. Can you tell me how this is done or point to some docs that explain it?
2) AVR uses the _BV() macro to make the code easier to read for shifting operations, which is why I show it at the end of the video. However, it's unique to the architecture/manufacturer, whereas knowing how to bit shift is more universal (which is why I showed it first).
You are right, if somebody wants quick short code , write it in assembly, AVR have SBR CBR instruction for bit setting or clearing.
tibor bogi aaah, that makes sense as to how the AVR compiler can optimize bit setting/clearing. It's been a long time since I've touched AVR assembly, so I had forgotten about those instructions!
amazing content, very well explained
Reminds me of the peek and poke in my old Vic 20
Great video and useful ...
i still didnt get the digital read part. whats PIND
Go to 5:25 and he talks about the three registers you need to be concerned with. DDRx, PORTx, and PINx.
The "x" in this example is referring to the "D" port.
At 6:55 he addresses this register directly.
Awesome video. great work guys.
very nice video. great work thank you sir
Wait, so 1 means output and 0 means input?
That's awfully confusing, why not I= 1 and O = 0 like in microchip devices..
"32x8 General Purpose Registrers" - Good job MicroChip...
LOL you mean they forgot to put that it was 32x 8-bit registers? Because I know it's not supposed to be 256 registers :)