This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:c4eng:fall2023:projects:ptb2 [2023/10/26 03:22] – mwinter4 | notes:c4eng:fall2023:projects:ptb2 [2023/10/26 03:25] (current) – [if-else] mwinter4 | ||
---|---|---|---|
Line 16: | Line 16: | ||
The if else statement essentially means that " __if__ this condition is true do the following thing, __else__ do this thing instead" | The if else statement essentially means that " __if__ this condition is true do the following thing, __else__ do this thing instead" | ||
+ | An easy way to write an if statement that executes when our button is pressed, is just to simply combine functions: | ||
+ | < | ||
+ | if(digitalRead(BUTTON)){ | ||
+ | // | ||
+ | } | ||
+ | </ | ||
+ | With this method, there is no need to write out a full expression. You can simply evaluate within the if statement. | ||
=====staying within a range===== | =====staying within a range===== | ||