16. Arduino for Production! AVR ATmega32 - Creating a Push Button Library

preview_player
Показать описание
Purchase my new book: Arm Microcontroller Programming and Circuit Building Volume 1

Please watch: "Buildyourcnc CNC Router on Love Yurts"
Patrick's Tip Jar:
bitcoin:1Gtawd29Sgu5CdvfUnkRg1YBfowCawjFdH
Ether:0xa962365100011B79097A7bb9DD51A53eE98266bb
If you have found this video to be helpful, consider making a tip. Thanks.
This is a video on creating a push button library that also contains software debouncing. The video also contains a wealth of debugging and is a great way to determine how I go about making a program work. The debugging portion of these videos are usually edited out, but I kept it in for this video to offer this experience.

Equipment that I use to make videos:
Рекомендации по теме
Комментарии
Автор

I've started watching these videos, they're really helping me to learn AVR C, and it's actually quite difficult finding good quality stuff on the net that isn't just flashing an LED. Most of the things you find are for Arduino, so just to say keep up the good work on the real microcontroller programming.

peaps
Автор

You can use any operation that is associated with a pin function in a library. There really is no constraint on how you would use the registers in a microcontroller as long as it conforms to the c language. Just remember that you are just changing bits in a register like you change bits in a number, or reading changing bits from an outside influence.

PatrickHoodDaniel
Автор

Thank you so much. I am very motivated and you will see many more, soon to come.

PatrickHoodDaniel
Автор

Amazing Patrick..really helping me with my experience with MC U's
Thanks a ton for such a wonderful series

beighnadeem
Автор

Your lessons given me so much on understanding programming

Lancelot
Автор

Hey, you may pass the number of buttons to array by using malloc/calloc functions.
It will look like this:

char InitButtons(int numberofButtons)
{
     char* Pressed;
     Pressed =
     [...]
     access Pressed like normal array Pressed[index] or by pointer *(Pressed + index)

     free(Pressed);
}

Eukaryotas
Автор

@Diptaparna Biswas don't let data sheets intimidate you. As a newbie, that is the main document you should study. I will have a computer to chip communication video very soon.

PatrickHoodDaniel
Автор

You don't need array If you initialize the variables inside the the main function
Maybe this will also be useful to free some memory? At the cost of cpu cycles?

SerajEmad
Автор

Fanastic tutorial very well explained and demonstrated.

Please keep these going :)

richardscott
Автор

Patrick, Great work with all you tutors I have to say I've learn so much. Do you have the ButtonPress.c file so I could make this library? Also is it possible to download MrLCD too? Could I use an interrupt in a library or does that have to happen in the main function? I was to make a simple traffic light library init would have pins and timing. I've been following along using an ATMega16 since I don't have a ATMega32. Can you do a tutor using jtag ice for debugging a simple program.Thanks Don

Frisky
Автор

One thing I noticed and I could be wrong, the part of the library that checks confidence level of the button being set low or off. I think this is redundant, if the confidence level isn't there that the button is pressed then it must be off so we are confident automatically that it is off if we are not confident it is on. Example if you take out the button off confidence level you simply remove the lag from letting go of the button as the LED will turn off at first 0 input and not go back on again unless the confidence level in the button pushed returns a 1. Disclaimer: I've never built a circuit before and I am using your stuff to learn, this seems to work logically but i have no idea if it works in practice, when I get the stuff to make this I will test my theory.

jasolandry
Автор

Thanks Pat for the replies I'll get to work starting with some simple stuff first.

Frisky
Автор

Hi,
These are awesome videos and I would like to thank you for this work. I landed on the channel while searching about I2C protocol. I just started watching other stuff as well.

I would just like to add one thing about writing the executable code in the h file. It is almost never a good idea to write everything in the h file.
Eg if in future, we are creating some libraries with some static functions, which are helping only the public interfaces, we will want to hide them from other modules. Well this is not applicable in this example, but you can still point out that it is a good practice to have a c file for the modules, as a new developer might unknowingly develop a bad habit of writing everything in a h file.

mehulajax
Автор

Thanks a lot for this video series. I want to learn how to use the avr to send/receive data from computer. Please suggest me if you have any such video or other resourse. I'm only a newbie so please don't ask me to read any datasheet.

DiptaparnaBiswas
Автор

Could I use an "output compare interrupt" in a library or does that have to appear in the main function? I was to make a simple traffic light library.

Frisky
Автор

Awesome Videos, thanks Patrick :) I can script LUA, but i didn't know anything about C++ before, but you really help to understand it :)
One thing i noticed, why do we pass the buttonNumber to the Library? Couldn't we just leave that, since the script will not call the function twice at a time? So it will not mix up anyways, right? (If i understand C++ so far :P)

Spidermoritz
Автор

Could use vectors instead of integer arrays for dynamic memory management

parvikdave
Автор

Thumbs up because I watched this cleaning and slicing carrots.

lebeyes
Автор

Is there an advantage to using the notepad vs the atmel studio?

Nate_dog
Автор

do we really need to use number of buttons? we can call the function multiple times for multiple buttons, I guess.

sifatmunim
join shbcf.ru