element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino and Bluetooth
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 11 replies
  • Answers 1 answer
  • Subscribers 390 subscribers
  • Views 1022 views
  • Users 0 members are here
  • mit_appinventor
  • hc06
  • appinventor
  • bluetooth®
  • arduino
Related

Arduino and Bluetooth

Former Member
Former Member over 10 years ago

I am working with the arduino uno and an HC-06 bluetooth module. My project is for my job and in the end will control the processes of a laser cutting head. basically we have an app that is the "control panel" and controls the arduino. the arduino then controls a PLC which then is sent elsewhere to sensors and the laser. I have the basics done I think but I am stuck trying to figure out how to make the arduino read if there is an error in the system and show a notice message on the app. Also in the app there is a numbers only text box that will be used to manually send measurments to tell the laser where to be. I have no idea how i would write that in arduino. Any help is useful. Here is my code so far...

 

 

int x0 = 13;

int x1 = 12;

int x2 = 11;

int x3 = 10;

int x4 = 9;

int y5 = A0;

 

 

void setup()

{

  Serial.begin(9600);

  pinMode(x0, OUTPUT);

  pinMode(x1, OUTPUT);

  pinMode(x2, OUTPUT);

  pinMode(x3, OUTPUT);

  pinMode(x4, OUTPUT);

  digitalWrite(x0, LOW);

  digitalWrite(x1, LOW);

  digitalWrite(x2, LOW);

  digitalWrite(x3, LOW);

  digitalWrite(x4, LOW);

}

 

 

 

 

 

 

void loop()

{

  delay(100);

  String t;

  while(Serial.available()) {

    t += (char)Serial.read();

  }

 

 

  if(t.length()){

     if(t == "pp on") {

       digitalWrite(x2, HIGH);

       digitalWrite(x0,LOW);

       digitalWrite(x1,LOW);

       digitalWrite(x3, LOW);

       digitalWrite(x4, LOW);

       }

     else if (t == "pp off") {

       digitalWrite(x2, LOW);

      }

    if(t == "auto on") {

      digitalWrite(x0, HIGH);

      digitalWrite(x1,LOW);

      digitalWrite(x2, LOW);

      digitalWrite(x3, LOW);

      digitalWrite(x4, LOW);

    }

    else if (t == "auto off") {

      digitalWrite(x0, LOW);

    }

      if(t == "man on") {

        digitalWrite(x1, HIGH);

        digitalWrite(x0, LOW);

        digitalWrite(x2, LOW);

      }

      else if (t == "man off") {

        digitalWrite(x1, LOW);

      }

      if (t == "up on"){

        digitalWrite(x3, HIGH);

        digitalWrite(x1,HIGH);

        digitalWrite(x0, LOW);

        digitalWrite(x2, LOW);

      }

      else if(t == "up off"){

        digitalWrite(x3, LOW);

        digitalWrite(x1, LOW);

      }

      if (t == "down on"){

        digitalWrite(x4, HIGH);

        digitalWrite(x1, HIGH);

        digitalWrite(x0, LOW);

        digitalWrite(x2, LOW);

      }

      else if(t == "down off"){

        digitalWrite(x4, LOW);

        digitalWrite(x1, LOW);

      }

  }

}

 

If anyone has any segestions on how to make my code i have already better or more simple let me know as well.

 

the app is through MIT app inventor 2 if anyone can help on that end it would be much appreciated. heres a screen shot of what it looks like for visual use...

 

 

image

  • Sign in to reply
  • Cancel

Top Replies

  • gadget.iom
    gadget.iom over 10 years ago in reply to neilk +3
    Cool. Found a few deleted comments appearing in my inbox feed. So many in fact that I ordered a couple of rolls of this:
  • Former Member
    Former Member over 10 years ago in reply to neilk +2
    The arduino code responds based off of the text that is sent from the app. Here is the block code i have so far for the basic funtions of the app. All i need to do now is be able to recieve some sort of…
  • gadget.iom
    gadget.iom over 10 years ago +1 suggested
    Is there a digital out (Y) terminal on the PLC that is/could be for an error signal? If so, you could use a digitalread statement to get that status, and a serial.print to send that to your Bluetooth module…
Parents
  • neilk
    0 neilk over 10 years ago

    wsallee07 Hi Wesley. Is the data you are reading in your Arduino sketch coming from the Android App?

     

    Can you post the AppInventor code blocks for the App?

     

    That would be helpful image

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to neilk

    The arduino code responds based off of the text that is sent from the app.

    Here is the block code i have so far for the basic funtions of the app. All i need to do now is be able to recieve some sort of byte that can be traslated into text on the app  for errors/comfirmation that something is running.

    image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to Former Member

    Looks good. Is there something like a GetText function block?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to gadget.iom

    Was it something I said?

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 10 years ago in reply to Former Member

    wsallee07 Hi Wesley

     

    You probably need to include a clock in your App design

     

    and then you can use something like this code block to check for data from the Arduino every time the clock fires:

    image

    Also, I wonder if you replaced the text strings your App sends out, with single characters, then you could simplify the Arduino sketch by replacing the Ifs and If..elses with a switch...case statement?

     

    Hope this helps

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to neilk

    Neil Kenyon wrote:

     

    Also, I wonder if you replaced the text strings your App sends out, with single characters, then you could simplify the Arduino sketch by replacing the Ifs and If..elses with a switch...case statement?

     

    I was thinking the same approach would be better as well.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 10 years ago in reply to gadget.iom

    gadget.iom Paul - that was me; I messed it up and deleted it.

     

    Should see a replacement now

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • neilk
    0 neilk over 10 years ago in reply to gadget.iom

    gadget.iom Paul - that was me; I messed it up and deleted it.

     

    Should see a replacement now

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to neilk

    Cool.

    Found a few deleted comments appearing in my inbox feed. So many in fact that I ordered a couple of rolls of this:

    image

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 10 years ago in reply to gadget.iom

    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to neilk

    The text and if statements make it easier to program sense i need some things to stay off while others are on, or to turn off when something else is turned on. i will try the clock to see if i can get feed back on the app.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube