Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 16, 2014, 04:06:15 am
This looks really interesting and the memory saving is most impressive.

Having a play with it now.

Thanks AWOL!

2  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 11:52:15 pm
Cool code zoomcat.
I find that it's always good to take it down to as simple as possible so that the user can understand it and get on and do something that works before they lose interest. They can always change it later if they need to.

In this case LordN1kon states that his objective is:
Quote
My target is to get a string with serial communication an use it as a simple string.
So he needs an array of chars, that'll be a String then smiley
Your nice'n easy code demonstrates how to receive each char as it comes through the serial port and from there it should be easy to build up a string which can then be used as he needs.

I think a String is an expensive proposition as far as memory goes though so it will be interesting to see AWOL's technique.
3  Using Arduino / Programming Questions / Re: Serial.read() does not behave as I expect on: January 14, 2014, 01:33:26 pm
We were actually just talking about this in this thread:

http://forum.arduino.cc/index.php?topic=210668.new;topicseen#new

Although this may not be the best way to do things it should work and maybe get you moving along.

4  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 01:17:01 pm
Cool, my reference to setting the baud rate (to 9600) was for the terminal emulator program, there is a 'port' tab where you choose the port (which can incidentally be a bluetooth virtual serial port) and in my experience if you have the PC's port set to one baudrate and the Arduino's serial port set to another you get:

gobbledeygook

smiley

5  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 12:37:27 pm
If by 'clearer' you mean 'moronic' then yes.

You come with lots of snarky comments about how the code should be written 'properly' yet you don't actually provide any code.

How about you write a better one then we can all bask in your superior greatness.

6  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 12:29:17 pm
I don't really understand what you mean by that.

7  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 12:20:13 pm
If you mean that a terminal emulator sends one character at a time while you write then you are correct, this will just receive one character at a time, you could build up a string and do conditional testing on it but this code is designed to receive a complete string of text all at once.

I have a terminal emulation program for the PC that can send a complete string of text, you need to click on the 'Send' tab and then write something in one of the boxes then click on the Send ASCII button to send that string of text all at once.

http://BTInterface.com/RealTerm.zip

You'll need to set the correct Baud rate (9600) and port.

Hope this helps

ian

8  Using Arduino / Programming Questions / Re: Noob question about serial communication on: January 14, 2014, 09:41:42 am
Shouldn't be necessary with delimiters and only makes things a whole lot more complex than they need to be, here, try this:

Code:
String input = "";
   
void setup() {
 
 Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

void loop() {
 
  while(Serial.available() > 0){ // While there is more to be read, keep reading
    input += (char)Serial.read();
    delay(1); // This is needed to prevent ... weirdness :)
  }
 
 // TADA! Now, if there was a burst of characters on the port they are all
 // contained in your input string so you can now use that string in your code :)
 
 // Your code can go here
   
  if(input != ""){
  Serial.println(input);
   input == "";
  }
 
}

Now in that code where I have put the comment // Your code can go here 
you can put some conditional statements to do stuff with your string before the last part of your code sets the input string back to "" (deletes it) so an example of doing stuff might be...

Code:
// Your code can go here
  if(input == "hello") {
    Serial.println("Hey, you said hello! so I'm saying hello back :)");
  }
 
9  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Serial Monitor line length limit? on: September 02, 2013, 11:52:36 am
Hi, yes thanks for your input.

I have a Bluetooth module with RX/TX on pins 10 & 11 using the SoftwareSerial.h library.

This enables two-way comms with no problems, i found for example that when I connected the Bluetooth module to pins 0 and 1 although I got it working I'd have to take the module off each time I wanted to upload a sketch so for my application the SoftwareSerial library is the way to go so my routine:
Code:
   if (Serial.available()) softSerial.write(Serial.read()); // send from Arduino to Bluetooth
   while(softSerial.available() > 0) { // While there is more to be read, keep reading.
     command += (char)softSerial.read();
     delay(1);
   }
is the same as yours, I find at the moment that a delay of 1 does the job nicely.

I don't want to have to use delimiters but appreciate the advice.

Thanks!
10  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Serial Monitor line length limit? on: September 02, 2013, 11:15:10 am
Ah, I think I realise why that delay was in there, without the delay the line seems to break in the Serial Monitor such that a line that should read:

sfx10;say Welcome to my super device;1;1t My Super Device;b2h;b3h;b4h;b1 Press Me

will break and read:

sfx10;s
ay Welcome to my super device;1;1t My Super Device;b2h;b3h;b4h;b1 Press Me

Is there a better way to prevent that from happening in my Arduino code?

I don't want to use 'prefix' mode if I can get away without it.

delay(1);

seems to fix it so far smiley
11  Using Arduino / Networking, Protocols, and Devices / Arduino Serial Monitor line length limit? on: September 01, 2013, 03:47:07 pm
Is there a problem with the Arduino Serial Monitor?

I have the IDE version 1.0.5 and when I send a line of text to the serial monitor from a bluetooth device the line of text ends at character 70 and then displays a random character.

Works fine on a terminal emulator program on my PC.

Unless it's my Arduino code?

Here is the code I'm using:

Code:
#include <SoftwareSerial.h>
// using the SoftwareSerial library allows the developer to choose
// which pins to put the bluetooth module on. Unfortunately some
// bluetooth 'shields' are hardwired to use Pins 0 and 1 which makes
// two-way communication with the Serial Monitor impossible :(
// use a cheap 'Linvor' 4 pin bluetooth module instead
// please see the Arduino section in the forum at www.BTInterface.com
// Set the Arduino Serial Monitor to 9600 Baud and no line ending.

// Receive pin (RX), Transmit pin (TX) of the Bluetooth module
SoftwareSerial softSerial(10, 11);  
String command = ""; // Stores response of bluetooth device
int baudrate = 9600;

void setup()  
{
  Serial.begin(baudrate);
  softSerial.begin(baudrate);
  Serial.println("SimpleTerm Ready!");
}

void loop()
{
  // SoftSerial is to and from the Bluetooth device  
  // Serial is to and from the PC (Arduino Serial Monitor).
 
   if (Serial.available()) softSerial.write(Serial.read()); // send from Arduino to Bluetooth
   while(softSerial.available() > 0) { // While there is more to be read, keep reading.
     command += (char)softSerial.read();
     delay(10);  
   }
  
// Your code can go here  
  
  // copy what's in command to the serial monitor.
   if(command != "") Serial.println(command); // send from Bluetooth to Serial Monitor
      
   command = ""; //empty the command string ready for the next use.
}// END loop()
12  Community / Exhibition / Gallery / Re: did I do well? on: August 14, 2013, 08:01:18 pm
extremely difficult commands from the Arduino are sent such as:

Send ("say no stupid, that was a black one");

or another extremely difficult command to send might be:

Send ("sms 07951555555 this is a text message");

13  Community / Exhibition / Gallery / Re: did I do well? on: August 14, 2013, 07:50:56 pm
Seriously when it gets this good then one starts to wonder what is actually possible, hence this vid:

http://www.youtube.com/watch?feature=player_embedded&v=kd5OBvn5aUA

14  Community / Exhibition / Gallery / Re: did I do well? on: August 14, 2013, 07:43:22 pm
The idea about BTInterface was modeled around the Arduino.

A wireless interface to provide buttons etc. to use it. (coz it don't have none).

It kind of took off, I provided speech and sound effects and stuff and the ability to customize the screen etc.

One simple little Bluetooth module is all that is required smiley

15  Community / Exhibition / Gallery / Re: did I do well? on: August 14, 2013, 07:37:05 pm
good for you
Pages: [1] 2 3