Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Basic math function
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Basic math function

by AH3000bt7 on Mon Mar 16, 2020 1:46 pm

Looking for the basic math function . Have loaded latest MU editor and upgrade for Grand central station . Mu editor indicated no faults but Repl on boot shows faults .

One line is problem
Line 41
While True:
If Switch1. value > C :

The Repl states line 41
TypeError: unsupported for __gt__: 'Direction' , 'int

Have no problems with the setup of input and output prior to line 41
Have looked for basic math ( >,< ,&,+ ,= ,- ) in documentation and have not been able to find any for CircuitPython
Thanks

AH3000bt7
 
Posts: 9
Joined: Tue Nov 27, 2018 12:05 pm

Re: Basic math function

by westfw on Mon Mar 16, 2020 4:18 pm

I believe the complaint is that one of the variables in your if statement is a "direction", and one of them is just an "integer", and there is no implemented way to compare them (it'd be like "is North greater than 10")

It make sense that the editor would not detect this level of error; syntactically, it's fine, and the failure depends on the types that the variables have at run-time.

westfw
 
Posts: 1732
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Basic math function

by AH3000bt7 on Mon Mar 16, 2020 6:48 pm

Your statement makes sense . Thanks for the reply
I was under the impression that an input .value could only be 1 or 0 . true or false
The C can it be set to one of these, with in a math statement. ?

As I need to compare apples to apples and not 10 to the north

AH3000bt7
 
Posts: 9
Joined: Tue Nov 27, 2018 12:05 pm

Re: Basic math function

by AH3000bt7 on Mon Mar 16, 2020 7:46 pm

Your statement makes sense . Thanks for the reply
I was under the impression that an input .value could only be 1 or 0 . true or false
The C can it be set to one of these, with in a math statement. ?

As I need to compare apples to apples and not 10 to the north

AH3000bt7
 
Posts: 9
Joined: Tue Nov 27, 2018 12:05 pm

Re: Basic math function

by westfw on Mon Mar 16, 2020 11:16 pm

I can't tell without seeing more of the code you're trying to use.

westfw
 
Posts: 1732
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Please be positive and constructive with your questions and comments.