Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by compufreek · Apr 07, 2014 at 01:20 AM · androidarduino

Unity on android controlling arduino

Hello! I want to build a gui interface for my phone with which i could controll an arduino connected to the phone via USB and i was wondering if that is possible in unity ? all i found was for PC and i was wondering if its possible with android

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image device2014 · Jul 06, 2014 at 04:07 PM 0
Share

why USB ? you can use Bluetooth : Android & $$anonymous$$icrocontrollers / BLuetooth

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by supernat · Apr 07, 2014 at 01:45 AM

The only 2 kickers might be with utilizing USB and having to pay for Unity Pro, but it most likely is possible.

You can create your own Android Java classes, drop them into the Plugins folder under Android, and access them in your JS or C# scripts using the JNIHelper and other JNI classes that Unity provides.

Additionally, you can drop other libraries that you didn't write into the same folder (assuming they are very modular and don't require anything beyond Unity's limitations, but generally speaking the only limitation I know of is the minimum supported SDK.)

Lastly, you can get plentiful access to the contexts and main activity through specific Unity function calls on the Java side, and Unity provides an API to send messages back from Java into your Unity scripts.

JNIHelper allows you to allocate instances of Java classes, call methods of those classes, and call methods of static classes (no allocation needed). I generally keep everything static, or at least as much as I can, to keep it simple.

For instance, if you have Arduino jars and want to call the methods to them, you can drop those jars into the Plugins/Android directory and use the JNIHelper class to directly communicate with them. Note, I believe you need Unity Pro (or mobile pro?) to use plugins, so this may be a limiting factor in cost for you.

Also, the JNI layer is very slow (it won't keep you from running at 30 hz or anything) and very small. You can only send small numbers of strings synchronously (like 512 by default I think) before the JNI overflows and crashes your app. This means even if you sent only 511 strings in an array once each frame, you're in trouble, because garbage collection hasn't had time to clean the JNI stack. So then you have to build in some delay between sending large string arrays (or anything else). Just keep this in mind in your design.

If you're just sending small numbers of bytes each frame, you should be fine.

Learning Android is not too difficult (easier than learning JNI), and I would say that if you don't need cross-platform support, you should probably just do the app in native android code (use Android Studio IMO), unless you want more than just UI (i.e. pretty graphs, cool 3D animations, etc), then use Unity if you can.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by device2014 · Jul 06, 2014 at 04:06 PM

why USB ? , there's a plugin that allow you to add Bluetooth connection between your Android device and Arduino. Android & Microcontrollers / Bluetooth

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ehermite · Aug 23, 2014 at 01:07 AM 0
Share

isn't any other plugin allow to access arduino bluetooth via iOS?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Arduino - Unity3d communication via wifi 1 Answer

Send data from Android to Arduino via RPi 3 WiFi 0 Answers

How to use BLE pluging 1 Answer

How to use open accessory of android in unity? 0 Answers

Android Bluetooth 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges