ambiguous error with Pins

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 606
Joined: Mon May 12, 2008 10:55 am

ambiguous error with Pins

Post by SeeCwriter »

Using a NANO with v2.9.2.
Why do I get error "conversion from 'PinIO' to 'WORD' is ambiguous" for each of the following:

Code: Select all

WORD val = Pins[23];
WORD val = (WORD) Pins[23];
WORD val = ( Pins[23] ) ? 1:0;
But no error with:

Code: Select all

int  val = Pins[23];
BYTE val = Pins[23];
if ( Pins[23] ) 
  iprintf( "The pin is low" );
sulliwk06
Posts: 118
Joined: Tue Sep 17, 2013 7:14 am

Re: ambiguous error with Pins

Post by sulliwk06 »

I would be surprised if the "WORD val = ( Pins[23] ) ? 1:0;" didn't work. I think the PinIO class just only implements the conversion operators for int, BYTE, and bool. That 3rd example should be using the bool conversion and assigning 1 or 0 to your WORD, does it give that same conversion error?

I would either just add the WORD operator to the PinIO class or go with "WORD val = (bool) Pins[23];"
Post Reply