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

Error "operator '==' cannot be applied to types 'false'"
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Error "operator '==' cannot be applied to types 'false'"

by Mathpun on Sat Feb 15, 2020 2:48 pm

hello -- I am trying to use my CPX in makecode to just display the color it detects by the color sensor -- I am going off this example and tweaking it: https://makecode.adafruit.com/73435-24525-19966-55549 From this project: https://learn.adafruit.com/florabrella/ ... playground

SO I am copying the portion that just uses the color sensor and getting this error --
"Error "operator '==' cannot be applied to types 'false' or 'true'"" (see image attached) OR see my actual code here:
https://makecode.com/_4d1P79DKAUEf

CAN anyone help me figure out how to do this in makecode? What about if I wanted to add some neoxpixels? Just the single one that you can sew on (https://www.adafruit.com/product/1260)

LMK thanks so much!
Attachments
Screen Shot 2020-02-15 at 10.46.50 AM.png
Screen Shot 2020-02-15 at 10.46.50 AM.png (157.58 KiB) Viewed 103 times

Mathpun
 
Posts: 43
Joined: Mon Feb 19, 2018 1:35 pm

Re: Error "operator '==' cannot be applied to types 'false'"

by V2man on Sat Feb 15, 2020 8:12 pm

Right click on true Boolean block in the set colorsense block. to get help on BOOLEAN.
Right click on the cyan color of the if block to get help on the CONDITIONAL block. Unfortunately, the help documentation does not have an example of a Boolean Conditional! See the method below.
boolean_conditional.PNG
boolean_conditional.PNG (120.46 KiB) Viewed 91 times


Here's a micro:bit guide. It's useful. https://makecode.microbit.org/blocks/logic
Attachments
CPX-Boolean_Conditional.uf2
(282 KiB) Downloaded 4 times

V2man
 
Posts: 704
Joined: Mon Dec 03, 2018 12:38 am

Re: Error "operator '==' cannot be applied to types 'false'"

by V2man on Sat Feb 15, 2020 11:48 pm

Misspelling: colosense should be colorsense.
Conditional block is just looking for a Boolean answer of true or false. Should I execute the next steps or skip.
In your code Makecode is complaining that you did not define the Boolean variable colorsense and rainbow. Once you do define colorsense as true or false the conditional statement will be happy as shown below. However the strip block is looking for 3 numbers, (98, 54, 175). You cannot assign a Boolean variable to a number variable in your code example. This guide discusses colors https://learn.adafruit.com/fancyled-library-for-circuitpython/colors

boolean_conditional1.PNG
boolean_conditional1.PNG (70.64 KiB) Viewed 75 times

V2man
 
Posts: 704
Joined: Mon Dec 03, 2018 12:38 am

Please be positive and constructive with your questions and comments.