The quality of your tutorials is the highest I have seen so far. You are very gifted teacher :) It seems what you are doing you are doing it the best (cnc, microprocessors&electronics, video tutorials, etc.). And the most interesting things - it seems you have learned them yourself. Congratulations and thanks so much!
Thanks Golgor. All of the ports of this microcontroller provide pull up resistors. Remember that this is important for setting the pin high and connecting the button to ground. If you do the reverse (connecting the button to 5v and setting the pin low) , then you will need to provide a pull down resistor in the circuit.
On the atmega32, I believe all ports have pull up resistors according to the beginning of the datasheet where it introduces the ports. Yes, if you use PORTB |= 1
All of the manuals that you will need is actually installed when you install winavr. Just look in the "all programs" under the start menu and then under the winavr selection. You will see the winavr user manual and the avr-libc manual.
you are an AWESOME teacher. and very very generous (because I know how much time and effort you need to put in order to come up with this kind of HIGH QUALITY video and well organized teaching). BTW, you made me back to RIGHT track on embedded systems (and programming) again. thanks a lot.
@amtpdb1 I am getting around to fixing the playlist. It's just missing one video; however, it's best to go to the newbiehack website and follow the narrative and videos on the site in the intended order. Additionally, there are many updates and revisions that will be posted from time to time on the site that will help the viewer understand the process.
I can't remember using an inductor in parallel with a capacitor in any of my videos, even mentioning it. If I did mention an inductor at all, it would have been associated to an application note in a datasheet.
The capacitor is used as a filtering device (low pass filter) and is actually done with a capacitor and resistor. The capacitor connected across the pin and ground and the resistor connected across the pin and vcc.
@axel1973w Thanks. I actually have my formal education in Architecture (U of Miami) and a Masters in Urban Design (UC Berkeley). All of this stems from my passion for electronics, engineering, woodworking, and programming. I was a programmer prior to my education in architecture, but I'm taking a break in architecture at the moment, but hope to participate in competitions soon (as time permits). CNC is a huge passion for me at the moment and embarking on various robotics in the future.
Great series of beginner tutorials!!!! You inspired me. i got the parts, soldered board, even unassembled usbtinyisp and went through the tutorials using WINAVR and Mac Waiting for the advance series. (hint...hint)
I now realized how guys become good professors and teachers.....You've got good teaching skills sir.....Thanks for the illustrative examples....But here's a suggestion.....Instead of only using red colored wires for all the pins...use color codings like red for Vcc, black for Gnd....It makes viewers to understand things in an intuitive way.
Solid core hookup wire. Just make sure it is not stranded wire which are like a bunch of little tiny wires inside of the insulation of the wire. Also, make sure to get the correct gauge so they fit inside of the tie strips.
i cant seem to locate a useful manual for the win avr compiler, is there a link that i can find it? what i would like to know is what all the fuctions are like above where you did if(bit_is_clear(PINB,5)) to read a digital pins state, if i had a list of these things it would be very helpful, thanks
Hello man, i love your videos but i have a question about this one, what if i want to make the button work even when i have a long else function? for example if my else function is about 10 secs i have to wait 10 secs before i press the button again because otherwise it would be ignored, thanks!
I can not seem to find the videos in order or in some cases, I can't find the one that follows! Found #1,2,3 then 6 in micro-controllers! 3 to 6 and then I was lost! Do you have a listing somewhere so that I can find the order of the different series? Thanks
hi PaTrick im from philipine... can you help me.. can i program at89c51 when i push the push down swicht start blink the ledlight 5 times and stop at the sametime have a display 7 segment count 1 to 5.. what the code i use? hope you hepl me..
If I understood everything correctly you used the pull-up resistor when you put the PORTB |= 1 >> PINB1; There are not Pull-up resistor on all ports right? What I have read it is recommended to use the pull-up resistor when using buttons. Can you clarify this? Thanks for AWESOME tutorials. :)
+a00000z100 bit_is_clear is a macro available when you include io.h. Check the AVR Libc from Atmel here: www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__sfr_1gad188fb0fbfd923bdb01294072367d024.html
I have a 12hmz osc that came with my board. i added #define F_CPU 12000000UL before the delay.h header but the led still blinks way faster than yours? at 100ms it blinks as if it was at 10ms and at 10ms it blinks so fast that the led remains on. Can you lead me in the right direction?
When I add this in to my program, it takes much longer to compile and I end up with the flash size being 30768 bytes. Without it, the size is only 2702 bytes. if (bit_is_clear(PIND, 3)) { delaypixel = 2; }
Could you also write something like If(PINB1 == 1) { } Else { } ? It just seems an awful complicated way of checking a pin value? Correct me if I'm wrong, but I am coming from a PIC background, which didn't use C.......... :-\
Your tutorials are really good and Thanks. Where can I find a list of system functions and libraries for my attiny, such as the bit_is_clear() function.
Resistance = Volts / Current R = V/I V = difference between the volts of the source and volts of the led = Vs - Vled I = Led current rating R = (Vs - Vled) / I Example: if the led is 2 volts and the supply is 5 volts and the current rating for the led is .01 amps (one milliamp), then: R = (5 volts - 2 volts) / .01 amps R = 3 / .01 = 300 ohms You can use a value above the result, but the higher the value, the dimmer the led will be.
for calculate a resistor you use this U:I=R means Voltage=Amphere x Ohm. For calculate the resistor for a green LED most times they need up to 2,0 Volt (good idea to take a look at the datasheed of the led)for example:If you want to use a LED on a 5 Volt electrical circuit you got to know how many voltage and amperes the LED need for light up.VDD = 5 Volt - VDDled = 2 Volt (datasheet)Iled = 20mA (what means that the LED need 0,02 A)VDD - VDDled (5 Volt - 2 Volt) = Rest Voltage for the resistor !Iled = 0,02 ANow use U = R x I or set it back lke see next !R = U : I means Resistor = Voltage : CurrentR = 3Volt : 0,02 Ampere = 150 Ohm remember always to use Ampere if you use this formula for getting the right plans!Always use the right Units for calculate because in the most of datasheets the current unit is assign to (mA) so you first got to calulate it in the form of Ampere (A) !
I'm sure you already knew this, but you forgot to include "#define F_CPU" to define your clock speed. At the end of this video, when you said the LED was toggling every 100ms and 10ms respectively, the LED was actually toggling about every 1000ms and 100ms. Perhaps the default clock speed is 1MHz and you were using 8? Great videos thus far though, thanks a lot!
Yes, it essentially takes up the MCU while it waits. Delay is useful in maintaining a single process and ensuring nothing interrupts that. As such if you want to omit that it is just the opposite, use an interrupt. Keep watching the tutorials and these are covered in a later video!
Checking to see if the bit PINB1 is clear is the same as saying low, ground, 0 or anything else that implies that it is not a high reading. Bit being clear is 0 or low, or ground. Bit being set is 1 or high or 5v (in this case, but could be other high voltage values like 3.3, 1.8 etc. depending on the chip used).
So i added an Inductor in parallel with a capacitor to my 5V and GND pins on my atmega 324p and it burned my board 0_o i heard you say that on one of your videos.. did u actually do that, without burning up your board?
The button is connected to ground and PINB1. If the PINB1 is set low (ground), then there would be no change on the pin because ground connected to ground is no change. when we set PINB1 to high, then when the button is pressed, the signal will be set to low when the button is pressed, so the microcontroller will sense a change on that pin.
In fact, when a port or a pin is in input. And this port is set to hi. This active a internal pull-up resistor. If you dont do this, you could add a external 10k resistor to Vcc (5v) on pin PINB1. But it's easy and cheaper to add a code line.
Hello your *tutorials* helps me alot and i was rebuild *some of them from beginning* and learn verry much !On a actual *tutorial* about *BUTTONS* i'll remind you that prouberly Forget about *PNP or NPN Transistors* because they Need a *Signal* to shift an *electrical circuit* in many time of one secounf*Maybe remind on it in your next *tutorial well be verry helpfull !Nice work !
Got idea to teach something about *bitwise operations* like you show us in your good declared videos because i was'nt know *nothing about that stuff* ! ;)Prouberly on a long *code*, it may *help* to *invert* arguments for what *looking for* !Thanks you a lot !*Verry smart* ! :D
Following Code is working with Atmel Evaluationsboard on Versoin 2.01 for poeple who want to try this code (whitout warranty ) !* (only copy code insight of the //Hier beginnt die Initialisierung and //Hier endet die Initialisierung or clear the *comment out of the code ! //Hier beginnt die Initialisierung #include #include int main(void) { DDRD = 0b01100000; //initialisiert das DATA DIRECTION REGISTER für PORT D und setzt die im Bitmuster abgegebenen PINS als Ausgänge PORTD = 0b01100000; //schaltet die LEDs am PORTD sowie AUSGABEPIN 5 und 6 *0b|7|6|5|4|3|2|1|0*, auf + 5Volt VDD //Es beginnt eine Endlosschleife welcher das in Klammern aufgeführte Argument übergeben wird. while (1) //wenn das in Klammern aufgeführte Argument zutrifft, werden die Anweisungen in den geschweiften Klammer ausgefuehrt. { (PORTD) = 0b01000000; //PORTD ist als *Ausgangspin* am Ausgang 6*, deklariert ! _delay_ms(10); //*Wartzeit für ein *zehntel einer Sekunde*, um ggf. die Entprellzeit bidiengt *mechanischer Herkunft* zu verarbeiten !* DDRD = 0b00100000; //führt einen VERGLEICH des Ausgangspins am PORT D und dessen Ausgang an Pin D5 durch ! PORTD = 0b00100000; //setzt Ausgangspin 6 auf einen *Highlevel*, von + 5 Volt ! _delay_ms(100); //wartezeit von einer Sekunde ! DDRD = 0b01000000; //*jetzt*, wird der Zustand des Ausgangspins des als *Global geltetendes Arguments welcher ursprünglich *global als somit *Ausgabepin*, initiert wurde, in dieser **while*,*ENDLOSSCHLEIFE*, // auf EINGABE oder AUSGAGE, hin geprüft ! //Werke: Einmalig bei der Initierung, den *Variablen* können im Verlauf eines Programmes, unterschiedliche Werte erhalten. //Konstanten allerdings keinesfalls ! } }//Hier endet die InitialisierungSometimes it's a got idea to take a *RED wired cable* for the positive VCC and a *BLACK wired cable* for the negative GND rail and for *technical knowledge and for *pysical acknowledge* it doesn't matter what *Kind or whst colour* the cable got !Be sure but don't use so much of voltage because current alway flown from A to B and not why current was attaked by coulorblind ;)
it actually would, if the microcontroller could provide much more current. You could easily calculate, if you knew the exact resistance of wire and button. Lets assume that it's about 0.001 Ohm in total for pressed button, cables and capacitor. Your Voltage has to drop from 5V at the microcontroller to 0V at ground. So you would need to have a current of U = R*I => I = U/R = 5V/0.001Ohm = 5000 A. The microcontroller cant possible provide so much current, as this needs a powersupply of 25kW (also, everything would melt down before). So instead the Supply Voltage drops.
Grayhamper I don't get this. Can you please explain that a little better? I went through comments to ask this same question. I thought pushing the button would make the input read high, but instead you have the code in is_clear, which I would have thought would be if the button is not pressed. I'm a tad confused by this.
Grayhamper Nevermind. I after starting 2 videos up I noticed you say that the pin read the ground signal when pressed. Now I get it. But one thing I want to understand is... So, with code, you are sending the pin 5v but when the button is pressed the 0v from ground overrides that 5v? I know it's not that important. I just like to know why something is working as opposed to just knowing it works. Thanks.
Nivlekius Read high means: 5V between the Pin and Ground. Read low means: 0V between Pin and Ground. If the Button is pressed, the Pin is directly connected to Ground - without any significant resistance. If we use Ohm's Law ( R = U/I ), we can see that the Voltage between Pin and Ground is U = R * I. Now, obviously the Pin provides a Voltage of 5 V so U should be 5V. If you calculate the required Current I for that (considering R is close to 0, so like i said above ~ 0.001 Ohms), you need a Current of 5000 Amps for that, which means you need a Powersupply of 5000A * 5V = 25kW to achieve that. Now obviously the Powersupply and the Microcontroller are not build to do that. What actually happens is that the Voltage drops before the point where the Microcontroller reads it. So the Pin has an internal Resistance before the Point where the Pin is read, lets call it Ri, which leads to a Voltagedrop, lets call it Ui. So If there is no resistance between Pin and Ground, the current I is increasing, as it can flow freely now. but the increased Current leads to a higher Voltagedrop before the Readpoint, Ui = Ri * I. This reduces the Voltage U, as 5V = U + Ui has to be true. So to conclude: The Internal Resistance acts as a Voltage splitter. It splits 5 V into internal Voltage Ui and external Voltage U by the Ratio of their respective Resistances Ri and R. So U/Ui = R/Ri. Theirfor the Voltage between Pin and Ground is already 0 at the Readpoint if R ~ 0.
I use XOR in a toggling scenario. The AND NOT is used to make sure a bit is 0. If I used XOR not knowing the current state of the bit, it could write a 1 in that bit instead.
Those delays do not look correct. A 10ms delay should change State 100 times per second and 100ms should change state 10 times per second. Do you need define F_CPU so it can correctly calculate the delay? Or am I missing something?
The quality of your tutorials is the highest I have seen so far. You are very gifted teacher :) It seems what you are doing you are doing it the best (cnc, microprocessors&electronics, video tutorials, etc.). And the most interesting things - it seems you have learned them yourself. Congratulations and thanks so much!
Thanks Golgor. All of the ports of this microcontroller provide pull up resistors. Remember that this is important for setting the pin high and connecting the button to ground. If you do the reverse (connecting the button to 5v and setting the pin low) , then you will need to provide a pull down resistor in the circuit.
Thanks. They also serve really well for brushing-up. Enjoy.
Love the game shop type music when you were adding the jumper wires for vcc and ground.
Bestest simplified example of Capacitor
Thanks!
On the atmega32, I believe all ports have pull up resistors according to the beginning of the datasheet where it introduces the ports. Yes, if you use PORTB |= 1
That was the best explanation of a capacitor I've ever heard!
Thanks!
All of the manuals that you will need is actually installed when you install winavr. Just look in the "all programs" under the start menu and then under the winavr selection. You will see the winavr user manual and the avr-libc manual.
you are an AWESOME teacher. and very very generous (because I know how much time and effort you need to put in order to come up with this kind of HIGH QUALITY video and well organized teaching).
BTW, you made me back to RIGHT track on embedded systems (and programming) again.
thanks a lot.
Thanks. That pin is actually pin 1 since the pins are indexed from 0.
@amtpdb1 I am getting around to fixing the playlist. It's just missing one video; however, it's best to go to the newbiehack website and follow the narrative and videos on the site in the intended order. Additionally, there are many updates and revisions that will be posted from time to time on the site that will help the viewer understand the process.
Thanks for yours videos, very understandable and easy!
Very nice explanation how capacitor works !
Thank you.
@kiffing Thanks. I was going for elevator music, but when I found this loop, I really thought it fit well.
I can't remember using an inductor in parallel with a capacitor in any of my videos, even mentioning it. If I did mention an inductor at all, it would have been associated to an application note in a datasheet.
Can we Use Pull Up Resistor instead of a Capacitor.?
The capacitor is used as a filtering device (low pass filter) and is actually done with a capacitor and resistor. The capacitor connected across the pin and ground and the resistor connected across the pin and vcc.
@axel1973w Thanks. I actually have my formal education in Architecture (U of Miami) and a Masters in Urban Design (UC Berkeley). All of this stems from my passion for electronics, engineering, woodworking, and programming. I was a programmer prior to my education in architecture, but I'm taking a break in architecture at the moment, but hope to participate in competitions soon (as time permits). CNC is a huge passion for me at the moment and embarking on various robotics in the future.
Great series of beginner tutorials!!!! You inspired me. i got the parts, soldered board, even unassembled usbtinyisp and went through the tutorials using WINAVR and Mac
Waiting for the advance series. (hint...hint)
You are a good teacher. Thank you.
Thank you!
I now realized how guys become good professors and teachers.....You've got good teaching skills sir.....Thanks for the illustrative examples....But here's a suggestion.....Instead of only using red colored wires for all the pins...use color codings like red for Vcc, black for Gnd....It makes viewers to understand things in an intuitive way.
very good water example! i love it.
03:07 how are these red wires called you are using there who work like jumper wires, but are much smaller? I could not find them to buy anywhere.
Solid core hookup wire. Just make sure it is not stranded wire which are like a bunch of little tiny wires inside of the insulation of the wire. Also, make sure to get the correct gauge so they fit inside of the tie strips.
Absolutely excellent videos and website!
i cant seem to locate a useful manual for the win avr compiler, is there a link that i can find it? what i would like to know is what all the fuctions are like above where you did
if(bit_is_clear(PINB,5)) to read a digital pins state, if i had a list of these things it would be very helpful, thanks
Thank you patrick!!! its a wonderful tutorial you have provided us!
Thanks
but how did you know the capacitor value aside from experience?????? That didn't give me a clue how to do such calculating myself.
Can I explain memory management organization for 8051 microcontroller
Thanks!!
Hello man, i love your videos but i have a question about this one, what if i want to make the button work even when i have a long else function? for example if my else function is about 10 secs i have to wait 10 secs before i press the button again because otherwise it would be ignored, thanks!
I can not seem to find the videos in order or in some cases, I can't find the one that follows! Found #1,2,3 then 6 in micro-controllers! 3 to 6 and then I was lost! Do you have a listing somewhere so that I can find the order of the different series?
Thanks
sir which kind of wires you using with breadboard ?
how to buy it from ebay ?
hi PaTrick im from philipine... can you help me.. can i program at89c51 when i push the push down swicht start blink the ledlight 5 times and stop at the sametime have a display 7 segment count 1 to 5.. what the code i use? hope you hepl me..
Great tutorials Sir...
You doing a great Job
Thanks for this nice explanation.
If I understood everything correctly you used the pull-up resistor when you put the PORTB |= 1 >> PINB1;
There are not Pull-up resistor on all ports right? What I have read it is recommended to use the pull-up resistor when using buttons. Can you clarify this?
Thanks for AWESOME tutorials. :)
thank you so much, just a quick question, should we call the IF function ( bit_is_clear) or we can call it any else such as if (X (PINB, 1)
+a00000z100 bit_is_clear is a macro available when you include io.h. Check the AVR Libc from Atmel here: www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__sfr_1gad188fb0fbfd923bdb01294072367d024.html
It looks like your oscillator is set incorrectly because 100ms is taking about 1000ms.
anajonesr:
Thanks for responding. I went to newbie and watched the other ones. Thanks
I have a 12hmz osc that came with my board. i added #define F_CPU 12000000UL before the delay.h header but the led still blinks way faster than yours? at 100ms it blinks as if it was at 10ms and at 10ms it blinks so fast that the led remains on. Can you lead me in the right direction?
When I add this in to my program, it takes much longer to compile and I end up with the flash size being 30768 bytes. Without it, the size is only 2702 bytes.
if (bit_is_clear(PIND, 3))
{
delaypixel = 2;
}
Could you also write something like If(PINB1 == 1) { } Else { } ? It just seems an awful complicated way of checking a pin value? Correct me if I'm wrong, but I am coming from a PIC background, which didn't use C.......... :-\
Your tutorials are really good and Thanks. Where can I find a list of system functions and libraries for my attiny, such as the bit_is_clear() function.
Question, how do you know what resistor value to use in series with the LED?
Do you still need to know?
no prouberly still about to learn !
Resistance = Volts / Current
R = V/I
V = difference between the volts of the source and volts of the led = Vs - Vled
I = Led current rating
R = (Vs - Vled) / I
Example: if the led is 2 volts and the supply is 5 volts and the current rating for the led is .01 amps (one milliamp), then:
R = (5 volts - 2 volts) / .01 amps
R = 3 / .01 = 300 ohms
You can use a value above the result, but the higher the value, the dimmer the led will be.
I explain this in the following video: th-cam.com/video/zRotGzBhx08/w-d-xo.html
for calculate a resistor you use this U:I=R means Voltage=Amphere x Ohm. For calculate the resistor for a green LED most times they need up to 2,0 Volt (good idea to take a look at the datasheed of the led)for example:If you want to use a LED on a 5 Volt electrical circuit you got to know how many voltage and amperes the LED need for light up.VDD = 5 Volt - VDDled = 2 Volt (datasheet)Iled = 20mA (what means that the LED need 0,02 A)VDD - VDDled (5 Volt - 2 Volt) = Rest Voltage for the resistor !Iled = 0,02 ANow use U = R x I or set it back lke see next !R = U : I means Resistor = Voltage : CurrentR = 3Volt : 0,02 Ampere = 150 Ohm remember always to use Ampere if you use this formula for getting the right plans!Always use the right Units for calculate because in the most of datasheets the current unit is assign to (mA) so you first got to calulate it in the form of Ampere (A) !
I'm sure you already knew this, but you forgot to include "#define F_CPU" to define your clock speed. At the end of this video, when you said the LED was toggling every 100ms and 10ms respectively, the LED was actually toggling about every 1000ms and 100ms. Perhaps the default clock speed is 1MHz and you were using 8?
Great videos thus far though, thanks a lot!
Doesn't the _delay-command halt the program so that it won't register any presses while it delays? Is there a way to omit this?
Yes, it essentially takes up the MCU while it waits. Delay is useful in maintaining a single process and ensuring nothing interrupts that. As such if you want to omit that it is just the opposite, use an interrupt. Keep watching the tutorials and these are covered in a later video!
what do mean by checking whether the bit is clear or not, the clear implies??
Checking to see if the bit PINB1 is clear is the same as saying low, ground, 0 or anything else that implies that it is not a high reading. Bit being clear is 0 or low, or ground. Bit being set is 1 or high or 5v (in this case, but could be other high voltage values like 3.3, 1.8 etc. depending on the chip used).
So i added an Inductor in parallel with a capacitor to my 5V and GND pins on my atmega 324p and it burned my board 0_o i heard you say that on one of your videos.. did u actually do that, without burning up your board?
Just a small doubt. What is the use of the command which sets PINB1 to a high reading?
The button is connected to ground and PINB1. If the PINB1 is set low (ground), then there would be no change on the pin because ground connected to ground is no change. when we set PINB1 to high, then when the button is pressed, the signal will be set to low when the button is pressed, so the microcontroller will sense a change on that pin.
In fact, when a port or a pin is in input. And this port is set to hi. This active a internal pull-up resistor. If you dont do this, you could add a external 10k resistor to Vcc (5v) on pin PINB1. But it's easy and cheaper to add a code line.
Hello your *tutorials* helps me alot and i was rebuild *some of them from beginning* and learn verry much !On a actual *tutorial* about *BUTTONS* i'll remind you that prouberly Forget about *PNP or NPN Transistors* because they Need a *Signal* to shift an *electrical circuit* in many time of one secounf*Maybe remind on it in your next *tutorial well be verry helpfull !Nice work !
Got idea to teach something about *bitwise operations* like you show us in your good declared videos because i was'nt know *nothing about that stuff* ! ;)Prouberly on a long *code*, it may *help* to *invert* arguments for what *looking for* !Thanks you a lot !*Verry smart* ! :D
Following Code is working with Atmel Evaluationsboard on Versoin 2.01 for poeple who want to try this code (whitout warranty ) !* (only copy code insight of the //Hier beginnt die Initialisierung and //Hier endet die Initialisierung or clear the *comment out of the code !
//Hier beginnt die Initialisierung
#include
#include
int main(void)
{
DDRD = 0b01100000; //initialisiert das DATA DIRECTION REGISTER für PORT D und setzt die im Bitmuster abgegebenen PINS als Ausgänge
PORTD = 0b01100000; //schaltet die LEDs am PORTD sowie AUSGABEPIN 5 und 6 *0b|7|6|5|4|3|2|1|0*, auf + 5Volt VDD
//Es beginnt eine Endlosschleife welcher das in Klammern aufgeführte Argument übergeben wird.
while (1) //wenn das in Klammern aufgeführte Argument zutrifft, werden die Anweisungen in den geschweiften Klammer ausgefuehrt.
{
(PORTD) = 0b01000000; //PORTD ist als *Ausgangspin* am Ausgang 6*, deklariert !
_delay_ms(10); //*Wartzeit für ein *zehntel einer Sekunde*, um ggf. die Entprellzeit bidiengt *mechanischer Herkunft* zu verarbeiten !*
DDRD = 0b00100000; //führt einen VERGLEICH des Ausgangspins am PORT D und dessen Ausgang an Pin D5 durch !
PORTD = 0b00100000; //setzt Ausgangspin 6 auf einen *Highlevel*, von + 5 Volt !
_delay_ms(100); //wartezeit von einer Sekunde !
DDRD = 0b01000000; //*jetzt*, wird der Zustand des Ausgangspins des als *Global geltetendes Arguments welcher ursprünglich *global als somit *Ausgabepin*, initiert wurde, in dieser **while*,*ENDLOSSCHLEIFE*,
// auf EINGABE oder AUSGAGE, hin geprüft !
//Werke: Einmalig bei der Initierung, den *Variablen* können im Verlauf eines Programmes, unterschiedliche Werte erhalten.
//Konstanten allerdings keinesfalls !
}
}//Hier endet die InitialisierungSometimes it's a got idea to take a *RED wired cable* for the positive VCC and a *BLACK wired cable* for the negative GND rail and for *technical knowledge and for *pysical acknowledge* it doesn't matter what *Kind or whst colour* the cable got !Be sure but don't use so much of voltage because current alway flown from A to B and not why current was attaked by coulorblind ;)
your videos have helped me a lot. thanks
n00b question, why does it reads 0 volts when you press the button?; shouldnt it still read the 5V?
it actually would, if the microcontroller could provide much more current. You could easily calculate, if you knew the exact resistance of wire and button. Lets assume that it's about 0.001 Ohm in total for pressed button, cables and capacitor. Your Voltage has to drop from 5V at the microcontroller to 0V at ground. So you would need to have a current of U = R*I => I = U/R = 5V/0.001Ohm = 5000 A. The microcontroller cant possible provide so much current, as this needs a powersupply of 25kW (also, everything would melt down before). So instead the Supply Voltage drops.
Grayhamper I don't get this. Can you please explain that a little better? I went through comments to ask this same question. I thought pushing the button would make the input read high, but instead you have the code in is_clear, which I would have thought would be if the button is not pressed. I'm a tad confused by this.
Grayhamper Nevermind. I after starting 2 videos up I noticed you say that the pin read the ground signal when pressed. Now I get it. But one thing I want to understand is... So, with code, you are sending the pin 5v but when the button is pressed the 0v from ground overrides that 5v? I know it's not that important. I just like to know why something is working as opposed to just knowing it works. Thanks.
Nivlekius Read high means: 5V between the Pin and Ground. Read low means: 0V between Pin and Ground. If the Button is pressed, the Pin is directly connected to Ground - without any significant resistance. If we use Ohm's Law ( R = U/I ), we can see that the Voltage between Pin and Ground is U = R * I.
Now, obviously the Pin provides a Voltage of 5 V so U should be 5V. If you calculate the required Current I for that (considering R is close to 0, so like i said above ~ 0.001 Ohms), you need a Current of 5000 Amps for that, which means you need a Powersupply of 5000A * 5V = 25kW to achieve that.
Now obviously the Powersupply and the Microcontroller are not build to do that.
What actually happens is that the Voltage drops before the point where the Microcontroller reads it.
So the Pin has an internal Resistance before the Point where the Pin is read, lets call it Ri, which leads to a Voltagedrop, lets call it Ui. So If there is no resistance between Pin and Ground, the current I is increasing, as it can flow freely now. but the increased Current leads to a higher Voltagedrop before the Readpoint, Ui = Ri * I. This reduces the Voltage U, as 5V = U + Ui has to be true.
So to conclude:
The Internal Resistance acts as a Voltage splitter. It splits 5 V into internal Voltage Ui and external Voltage U by the Ratio of their respective Resistances Ri and R. So U/Ui = R/Ri. Theirfor the Voltage between Pin and Ground is already 0 at the Readpoint if R ~ 0.
That was a complex mouthful, but I think I understand now. Thank you very much
Great tuts !
Thanks a lot!
Why didn't we used the XOR (^) instead of AND NOT
DDRB ^= 1
I use XOR in a toggling scenario. The AND NOT is used to make sure a bit is 0. If I used XOR not knowing the current state of the bit, it could write a 1 in that bit instead.
can we use debounce via software?
Yes, the video should be in the playlist
Those delays do not look correct. A 10ms delay should change State 100 times per second and 100ms should change state 10 times per second. Do you need define F_CPU so it can correctly calculate the delay? Or am I missing something?
Probably video editing.
thank you
Ur videos are of great help..
bt i did't understand the bitwise operation in this programming.
DDRB&|=1
great stuff, but please, do something with your nails ...
Thanks.