Timeline for Multiple if else statements for distance-triggered LEDs
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 20, 2022 at 15:06 | history | bumped | Community Bot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Nov 20, 2022 at 17:36 | comment | added | jsotola | the code in the pastebin is different from the code in your question ... you already posted code in your question ... why would you say that you don't know how to post code? | |
Nov 19, 2022 at 22:12 | comment | added | Varonne | @jsotola I don't know how to post full code here other than pastebin - pastebin.com/BWVjdr1S - this works and leds turn on and off as they should. Take a look if you have the time, let me know if there's a better way to format it, as you can pretty much tell I'm not very well versed at this :D | |
Nov 19, 2022 at 19:07 | comment | added | jsotola |
put serial.print statements inside the if blocks for debugging purpose
|
|
Nov 19, 2022 at 19:04 | comment | added | jsotola |
then you did not post your real code... think about this ... which if statement will execute when shortestDist = 5 ?
|
|
Nov 19, 2022 at 18:39 | comment | added | Varonne | I rearranged the "else if shortestDist" by going "if shortestDist biggest value", else if smaller value and it works, as far as I can see it behaves properly | |
Nov 19, 2022 at 17:25 | comment | added | jsotola |
you have a logic error in your code ... else if (shortestDist < 10) will never execute ... think about what you are telling your program to do
|
|
Nov 19, 2022 at 15:09 | answer | added | st2000 | timeline score: 0 | |
Nov 19, 2022 at 13:23 | history | asked | Varonne | CC BY-SA 4.0 |