Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 captainjonsparrow · Jul 12, 2018 at 03:20 AM · switcharduinoweb server

Button Press with ESP8266 Working in Desktop Unity Program but not on Phone

Hello,

I've connected a 5-way tactile switch to an ESP8266 module and am using the Arduino IDE to program it. I've also connected my Arduino code to Unity3D. Essentially, if the button is pressed, my Arduino program prints the direction that the button was pressed in onto an automatically updating web server. In my Unity code, I read the text from the webpage and pan the scene according to the direction printed there. This is working perfectly on my laptop, but once I build and run the Unity program onto an Android phone, the panning no longer works. The phone and the ESP8266 are both on the same WiFi network. The button directions print fine when I go to the IP address on the phone, so I'm assuming that the problem is with the Unity code. Does anyone know what is wrong? Below is my code. Thank you!

 using System;
 using System.Collections;
 using System.IO.Ports;
 using System.Collections.Generic;
 using UnityEngine;

 public class StreetViewCamera: MonoBehaviour {
   
 private string textFromWWW;
 private string url = "http://192.168.1.10/"; // <-- enter your url here

 IEnumerator GetTextFromWWW()
 {
     WWW www = new WWW(url);

     yield return www;

     if (www.error != null)
     {
         Debug.Log("Ooops, something went wrong...");
         Debug.Log(www.error);
     }
     else
     {
         textFromWWW = www.text;
         Debug.Log(textFromWWW);
     }
 }
 private void Update()
 {
     StartCoroutine(GetTextFromWWW());
     Boolean  up = true;
     Boolean down = true;
     Boolean left = true;
     Boolean right = true;
     Boolean center = true;
     Boolean empty = true;

     try
     {
       //isolates the single letter indicating the direction from the rest of textFromWWW
        string stringText = Convert.ToString(textFromWWW);
         string substring = stringText.Split('^')[0];
         Debug.Log("SUB: " + substring);
         int index = ((substring.Length) - 1); //index of last character, which will be the direction reading
         string reading = Convert.ToString(substring[index]); //convert to string from char
         Debug.Log("READING: " + reading);

         while (up && reading.Equals("U")){
             movein();
             up = false;
         }
         while (down && reading.Equals("D"))
         {
             moveout();
             down = false;
         }
         while (left && reading.Equals("L"))
         {
             moveleft();
             left = false;
         }
         while (right && reading.Equals("R"))
         {
             moveright();
             right = false;
         }
         while (center && reading.Equals("C"))
         {
             Debug.Log("center running");
            center = false;
         }
         while (empty && reading.Equals("E"))
         {
             Debug.Log("empty running");
            empty = false;
         }
         subZInput = 0;
         subXInput = 0;
     }
     catch (System.Exception)
     {
     }
 }

 private void movein(){
     transform.position += transform.forward * 50 * Time.deltaTime;
 }
 private void moveout()
 {
     transform.position += transform.forward * -50 * Time.deltaTime;
 }

 private void moveleft()
 {
     transform.position += transform.right * -50 * Time.deltaTime;
 }
 private void moveright()
 {
     transform.position += transform.right * 50 * Time.deltaTime;
 }

}

Comment
Add comment · Show 2
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 hexagonius · Jul 12, 2018 at 04:51 AM 0
Share

how about debugging the code? using adb logcat -s Unity or attaching your IDE setting break points?

avatar image captainjonsparrow · Jul 12, 2018 at 01:50 PM 0
Share

I tried going to adb, but the ter$$anonymous$$al keeps saying [process completed] before I can type in a command. I've looked at my bash.profile, but there's nothing in it that causes the error that I can see. I'm creating a new server now on my laptop and trying to see if the problem is with the server or with the phone.

0 Replies

· Add your reply
  • Sort: 

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

88 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 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 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 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

Weapon Switching 1 Answer

add case in swicth, from editor unity 0 Answers

Can the two of telephone system be linked and how? 0 Answers

How to switch and unlock game characters in real time 0 Answers

Slow reading from Unity via Arduino!! URGENT! 3 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