Working with the Buckaroo plant water device bolted to Micro:bit.
I really wanted to make the Threshold a variable, which was adjusted up/down with A/B buttons.
BUT, the IF statement appears to only support comparing a variable to a fixed number. Not another variable.
And I can't seem to find how to set a variable = another variable - still another variable.
What AM I missing?
regards,
Neal
Can't IF Compare a Variable to a Variable?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dastels
- Posts: 15831
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Can't IF Compare a Variable to a Variable?
Any two things can be compared as long as they are similar enough types.
Can you post your code, it sounds like something is a little off.
Dave
Can you post your code, it sounds like something is a little off.
Dave
- mnopneal
- Posts: 13
- Joined: Tue Apr 13, 2021 11:53 am
Re: Can't IF Compare a Variable to a Variable?
Thanks for the reply. It looks like if the IF block already compares "Reading" < 950, then you can't just type in another variable name instead.
Rather you have to pick the variable, and then drag it.
Rather you have to pick the variable, and then drag it.
- dastels
- Posts: 15831
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Can't IF Compare a Variable to a Variable?
AH Makecode.. missed that. You should be able to drag the desired variable to replace the constant.
Dave
Dave
- johnpark
- Posts: 985
- Joined: Wed Mar 25, 2009 2:15 pm
Re: Can't IF Compare a Variable to a Variable?
yes, you can drag the variables from the VARIABLES category into the comparison block. https://makecode.com/_8gbADXa0uAXt
Please be positive and constructive with your questions and comments.