Flag for Running Pi?

Is there a “flag” that we could use in our code to check if a sketch is running on a Pi? For example

if(RASPI == true) { 
// do our pi code
}

I’m using the Upload to Pi tool, so ideally this flag could be set automatically rather than having to change the code manually each time

You could get the OS. Check these links:

https://forum.processing.org/two/discussion/6862/system-specs
https://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/
The ideal way to detect a raspberry pi from java (jar) - Stack Overflow

Kf

@robotgrrl There are ways to do this, e.g. by doing

if ("arm".equals(System.getProperty("os.arch"))) {
  // ...
}

But more generally I’d be curious to learn which parts of your code need changing when you go from one to the other! :slight_smile:

Hth

1 Like