A program uses two AnalogIn (p19,p20) one PwmOut (p24) and two DigitalIn(p5,p6)
It looks as if DigitalIn does not respond according to code
Is there any explanation other than faulty code i.e utilization of pins in above combination
Thank you Markos
A program uses two AnalogIn (p19,p20) one PwmOut (p24) and two DigitalIn(p5,p6)
It looks as if DigitalIn does not respond according to code
Is there any explanation other than faulty code i.e utilization of pins in above combination
Thank you Markos
In the following code statement character1= pc.getc()
blocks execution of if(button1==1){statement1;...;};
but if(character1=='a'){statementx1;statementx2;...} is executed normally
In the following code statement character1= pc.getc()
blocks execution of if(button1==1){statement1;...;};
but if(character1=='a'){statementx1;statementx2;...} is executed normally
<<code>>
while(1){
character1= pc.getc() ; button1=Digitalinput1; if(button1==1){statement1;statement2; ... };
if(character1=='a'){statementx1;statementx2;...}
}//end while
<</code>>
Any explanation why ?
pc.getc() is a blocking operation. It does not return until you press a key.
If you want to check first if there is a character waiting then use pc.readable();
The digital inputs like button1 are not blocking and can be called anywhere anytime.
pc.getc() is a blocking operation. It does not return until you press a key.
If you want to check first if there is a character waiting then use pc.readable();
The digital inputs like button1 are not blocking and can be called anywhere anytime.
<<code>>
while(1){
if (pc.readable()) {
character1= pc.getc() ;
if(character1=='a'){statementx1;statementx2;...}
};
button1=Digitalinput1;
if(button1==1){statement1;statement2; ... };
}
<</code>>
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
A program uses two AnalogIn (p19,p20) one PwmOut (p24) and two DigitalIn(p5,p6) It looks as if DigitalIn does not respond according to code Is there any explanation other than faulty code i.e utilization of pins in above combination Thank you Markos