AnalogIn,DigitalIn,Pwmout

25 Jun 2012

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

27 Jun 2012

In the following code statement character1= pc.getc() blocks execution of if(button1==1){statement1;...;}; but if(character1=='a'){statementx1;statementx2;...} is executed normally

while(1){
character1= pc.getc() ; button1=Digitalinput1; if(button1==1){statement1;statement2; ... };

if(character1=='a'){statementx1;statementx2;...} 
}//end while

Any explanation why ?

27 Jun 2012

The 1 should be in quotes, i.e. '1' for a character as is the 'a'.

27 Jun 2012

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.

while(1){
  if (pc.readable()) {
    character1= pc.getc() ;  
    if(character1=='a'){statementx1;statementx2;...}
  };

  button1=Digitalinput1;
  if(button1==1){statement1;statement2; ... };
}