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 Problem with Bluetooth Processing --> Arduino
  • 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
  • Replies 1 reply
  • Subscribers 390 subscribers
  • Views 229 views
  • Users 0 members are here
Related

Problem with Bluetooth Processing --> Arduino

roineust
roineust over 9 years ago

Hello,

i have here a Windows 10 OS PC running Processing IDE and an Arduino Pro-mini with a sketch uploaded from the Arduino IDE.

On both the Processing and Arduino i'm running 2 small basic sketches, in purpose to test the BT communication between the Arduino and the PC - the sketches are shown below.

When the Processing code is run (the 'play' button), the Linvor BT dongle red led stops blinking and show it is attached to the PC BT, yet - the motor which is attached to the relay, which is attached to the Arduino, does not start working when pressing the ON button on the Processing sketch window. Motor and relay are working well for sure - i know that, since i put a test function run form setup. i'v tried the same also with HC-06 and HC-05 BT dongles - they all seem to work well and the red led on them stops blinking and shows as if a BT connection is established.

 

Could the problem be caused by the Windos 10 firewall or anti-virus blocking BT communication? Could it be something else?

 

Thanks!

 

 

Arduino sketch:

 

#define motorRelay A4

char val; // variable to receive data from the serial port

//int ledpin = 8; // LED connected to pin 48 (on-board LED)

void setup() {

   

  //pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT

  Serial.begin(9600);       // start serial communication at 9600bps

  pinMode(motorRelay,OUTPUT);

  test_motor_before_loop();

}

 

void test_motor_before_loop(){

 

  digitalWrite(motorRelay,HIGH);

  delay(200);

  digitalWrite(motorRelay,LOW);

  delay(200);

  digitalWrite(motorRelay,HIGH);

  delay(200);

  digitalWrite(motorRelay,LOW);

  delay(200);

  digitalWrite(motorRelay,HIGH);

  delay(200);

 

}

 

void loop() {

  if( Serial.available() )       // if data is available to read

  {

    val = Serial.read();         // read it and store it in 'val'

  }

  if( val == 'H' )               // if 'H' was received

  {

    digitalWrite(motorRelay, LOW);  // turn ON the LED

       

  } else if( val == 'L' ) {

    digitalWrite(motorRelay, HIGH);   // otherwise turn it OFF

  }

  delay(100);                    // wait 100ms for next reading

}

 

 

Processing sketch:

 

// From Arduino Playground tutorial: http://www.arduino.cc/playground/Learning/Tutorial01

 

//import class to set up serial connection with wiring board

import processing.serial.*;

Serial port;

//button setup

color currentcolor;

RectButton rect1, rect2;

boolean locked = false;

void setup() {

  //set up window

  size(200, 200);

  color baseColor = color(102, 102, 102);

  currentcolor = baseColor;

  // List all the available serial ports in the output pane.

  // You will need to choose the port that the Wiring board is

  // connected to from this list. The first port in the list is

  // port #0 and the third port in the list is port #2.

  println(Serial.list());

  // Open the port that the Wiring board is connected to (in this case 1

  // which is the second open port in the array)

  // Make sure to open the port at the same speed Wiring is at 115200bps (default for BlueSMiRF modem)

  port = new Serial(this, Serial.list()[2], 9600);  //use the serial device that blueman has setup

  // Define and create rectangle button #1

  int x = 30;

  int y = 100;

  int size = 50;

  color buttoncolor = color(153, 102, 102);

  color highlight = color(102, 51, 51);

  rect1 = new RectButton(x, y, size, buttoncolor, highlight);

  // Define and create rectangle button #2

  x = 90;

  y = 100;

  size = 50;

  buttoncolor = color(153, 153, 153);

  highlight = color(102, 102, 102);

  rect2 = new RectButton(x, y, size, buttoncolor, highlight);

}

void draw() {

  background(currentcolor);

  stroke(255);

  update(mouseX, mouseY);

  rect1.display();

  rect2.display();

}

void update(int x, int y) {

  if(locked == false) {

    rect1.update();

    rect2.update();

  }

  else {

    locked = false;

  }

  //Turn LED on and off if buttons pressed where

  //H = on (high) and L = off (low)

  if(mousePressed) {

    if(rect1.pressed()) {            //ON button

      currentcolor = rect1.basecolor;

      port.write('H');

    }

    else if(rect2.pressed()) {    //OFF button

      currentcolor = rect2.basecolor;

      port.write('L');

    }

  }

}

class Button {

  int x, y;

  int size;

  color basecolor, highlightcolor;

  color currentcolor;

  boolean over = false;

  boolean pressed = false;

  void update()

  {

    if(over()) {

      currentcolor = highlightcolor;

    }

    else {

      currentcolor = basecolor;

    }

  }

  boolean pressed()

  {

    if(over) {

      locked = true;

      return true;

    }

    else {

      locked = false;

      return false;

    }

  }

  boolean over()

  {

    return true;

  }

  void display()

  {

  }

}

class RectButton extends Button {

  RectButton(int ix, int iy, int isize, color icolor, color ihighlight)

  {

    x = ix;

    y = iy;

    size = isize;

    basecolor = icolor;

    highlightcolor = ihighlight;

    currentcolor = basecolor;

  }

  boolean over()

  {

    if( overRect(x, y, size, size) ) {

      over = true;

      return true;

    }

    else {

      over = false;

      return false;

    }

  }

  void display()

  {

    stroke(255);

    fill(currentcolor);

    rect(x, y, size, size);

  }

}

boolean overRect(int x, int y, int width, int height) {

  if (mouseX >= x && mouseX <= x+width &&

    mouseY >= y && mouseY <= y+height) {

    return true;

  }

  else {

    return false;

  }

}

  • Sign in to reply
  • Cancel

Top Replies

  • neilk
    neilk over 9 years ago +1
    Hi roineust I'm not familiar with processing, but I do have some experience with Arduino & Bluetooth, particularly HC-06. Can I suggest that perhaps you need to check and see if your Arduino sketch is…
Parents
  • neilk
    neilk over 9 years ago

    Hi roineust

     

    I'm not familiar with processing, but I do have some experience with Arduino & Bluetooth, particularly HC-06.

     

    Can I suggest that perhaps you need to check and see if your Arduino sketch is receiving anything at all via Bluetooth. Some simple serial monitor outputs can tell you that.

     

    Secondly I would also suggest that your processing sketch looks quite complex (to me, anyway!), so why not use a terminal emulator on the PC (I use teraterm, free to download) and see if you can send characters from the PC, via Bluetooth, and receive them on the Arduino.

     

    Hope this helps

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • neilk
    neilk over 9 years ago

    Hi roineust

     

    I'm not familiar with processing, but I do have some experience with Arduino & Bluetooth, particularly HC-06.

     

    Can I suggest that perhaps you need to check and see if your Arduino sketch is receiving anything at all via Bluetooth. Some simple serial monitor outputs can tell you that.

     

    Secondly I would also suggest that your processing sketch looks quite complex (to me, anyway!), so why not use a terminal emulator on the PC (I use teraterm, free to download) and see if you can send characters from the PC, via Bluetooth, and receive them on the Arduino.

     

    Hope this helps

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
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