

If (obd.readPID(PID_FUEL_LEVEL, FuelLVL)) If (obd.readPID(PID_AIR_FUEL_EQUIV_RATIO, AFR)) Can I use a case/switch statement with two variables Asked 11 years, 5 months ago Modified 1 year, 7 months ago Viewed 243k times 65 I am a newbie when it comes to JavaScript and it was my understanding that using one SWITCH/CASE statements is faster than a whole bunch of IF statements. If (obd.readPID(PID_INTAKE_TEMP, IntakeTemp)) int # // save/initiate PID 'value' as new name, return true on success Okay here are the 2 cases that we are trying to get working void loop()

When the vehicle is turned on, we use an OBD converter and get the data from the cars own sensors through the plug. UKhelibob sorry as septillion pointed out i didn't read the forum guide, i am sorry for that Here is an example of what the idea from us was. Switch allows you to choose between several discrete options. If you have any other suggestions to what would be a good method to creating these pages i would gladly hear them, especially if you also know some guides void loop()ĭelay(700) // delay to debounce switch, Hold it down for scroll When there are more than two options, you can use multiple if statements, or you can use the switch statement.
Arduino switch case multiple variables code#
I thought that Loop was the term used for when it is constantly going through the code "looping" it as i would say? i know the code isn't pretty, it is a mix of codes we have found onlineĪs for the Loop situation, the thing we are trying to accomplish i having multiple "pages" on our little LCD, that all have live data, from the car that we are hooking it up to, when we create on page with RPM it is fine and showing nice data, where when we create more pages it only take like a screenshot, i think the problem is the break that we use for case, how does that sound? Thank you for the tips, i am just starting out so it is really helpful, greatly appreciated. Sorry septillion, yes i didn't read the "how to forum" but i have now, so in the future i will do betterĮnglish is not my first language so sorry for any spelling errors, i hope i can keep them minor. If (obd.readPID(PID_ENGINE_OIL_TEMP, Oil)) Do you really only want to set the cursor back when you have a reading? Or do you only want to print all the stuff if you have a reading?.Do you have an external resistor on the switchPin?ĭigitalWrite(Green, rpm > 2500 ? HIGH : LOW).Try to break the code down in smaller (reuseable) pieces.And if you don't want to write it, grab a library like Bounce2. Instead of a long delay, use a proper debounce.aka, they should all start with a lowercase. use the same style for variable names.
Arduino switch case multiple variables how to#
Read the how to use the forum You clearly didn't.Need Would like help with loop in switch case Let the loop do it's looping and just do whatever you want to loop in the loop Loop in a case? Unless it's a quick loop for example to set multiple pins or something it should not loop.
