Show Posts
Pages: 1 ... 65 66 [67] 68 69 ... 228
991  Using Arduino / Programming Questions / Re: Parsing an ascii string to unsigned16 and unsigned8 on: January 19, 2014, 06:17:58 pm
You can use the strtok() function to gather the incoming data. Being that you know how much data you will be receiving, you can take the first two (F6 01) and combine them into a WORD.

An example using the Serial monitor.
Code:
char data[30] = {0}, output[10];
int A, A_1;
int B,C,D,d=0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available() > 0){
    char c = Serial.read();  // 200, 55, 1, 2, 3
    data[d] = c;
    d++;
    if(c == '\n' || c == ' '){
      A = atoi(strtok(data, ",")); // 200
      A_1 = atoi(strtok(NULL, ",")); //55
      B = atoi(strtok(NULL,",")); // 1
      C = atoi(strtok(NULL,",")); // 2
      D = atoi(strtok(NULL," ")); // 3
   
      sprintf(output, "%d,%d,%d,%d", (A + A_1),B,C,D);
      Serial.print(output); //255,1,2,3
     d = 0;
    }
  }
}

 
   
 
Note: when you send the data, make sure you break up the first part. 512(16bit) = 256(8 bit) + 256(8 bit)
992  Using Arduino / Project Guidance / Re: My 1st project: TIE Crawler from the Star Wars Expanded Universe on: January 19, 2014, 04:49:38 pm
Ok, your idea is definitely possible. For your controller, do you want to recycle a gaming controller like a PS2/3 or Xbox, or do you want to make it from scratch? Either way, it will be easy but, if you decide go with a PS3 or Xbox controller, then you will need a USB host shield and a Bluetooth dongle. 

If you make it from scratch then you can use either an Arduino Nano, Micro, or Mini, and your two pads and buttons.

Quote
user "cwhummel" suggested to add a speaker with an mp3/wav
Ok, cool. Here is a small WAV/AD4 module. LINK HERE
993  Using Arduino / Project Guidance / Re: My 1st project: TIE Crawler from the Star Wars Expanded Universe on: January 19, 2014, 04:07:38 pm
Seeing as how it is skid steering, you can use a single joystick to control it, or you can use a standard up, down, left, right buttons. Do you want to control the speed too?
994  Using Arduino / Programming Questions / Re: Problem with multiple libraries weird error? on: January 19, 2014, 03:43:26 am
In both the transmitter and the receiver code, you only have one '=' operator in your IF statement condition when it should be '=='.

if( buf[0] == 'f' )
995  Using Arduino / Programming Questions / Re: Problem with multiple libraries weird error? on: January 18, 2014, 11:29:27 pm
What errors are you getting, post everything.
996  Using Arduino / Programming Questions / Re: Problem with multiple libraries weird error? on: January 18, 2014, 11:03:42 pm
You can't use both libraries at the same time, they both use timer1. If you want to use a servo, then you will need to get this chip

I made a library that is easy to use, let me know when you get the chip and post the library.
997  Using Arduino / Programming Questions / Re: Servo moves when not prompted to on: January 18, 2014, 11:00:05 pm
How is the servo powered?
998  Using Arduino / Project Guidance / Re: Thank you all for your help! on: January 18, 2014, 06:26:02 pm
Your toy has skid steering ( like a tank)  but judging from the picture, it looks like space is very limited. Can you specify the dimentions? Your code depending how you go about controlling it, will need a motor controller to drive the motors.  The usual ones might be too big, so you may need to make your own. There are also plenty of skid steering codes on this forum, I have some myself.

But first see how you want to control it IR, bluetooth, RF or even Xbee. Then see how much space you have to work with.
999  Using Arduino / Project Guidance / Re: Thank you all for your help! on: January 18, 2014, 03:54:53 pm
Simple design with Skid steering, the code should be very simple too. From your picture, there doesn't seem to be a lot of room, where do you plan to put everything? The motor controller you may be able to salvage or just make your own, and you might want to use either an Arduino Nano, micro, or Mini.
1000  Using Arduino / Project Guidance / Re: changing from serial to bluetooth using BT on: January 18, 2014, 02:15:42 pm
It's most likely is the SSCOM3.2.
When you try to transmit, you should see on your screen a message " bluetooth connection was established", do you ever see this? From what I saw, a lot of people were having issues with that shield. Some were saying it wasn't compatible with their Arduino, another said he solved it by reversing the TX and RX in the code and for the rest, it still did not work.

I'm sure you played with the example codes to see if your IR is working, right? Start by getting one piece to work, at a time then combine them. Make sure everything works indepently first then begin to add more.
1001  Using Arduino / Project Guidance / Re: Help needed to decide power supply for bluetooth robot on: January 18, 2014, 05:09:22 am
Whichever is easier for you. Just make sure the Grounds are wired together, otherwise you will get unwanted result.
1002  Using Arduino / Project Guidance / Re: changing from serial to bluetooth using BT on: January 18, 2014, 05:08:10 am
No. You should read up on the differences between Serial and Software Serial, and how they work. You are not going to see anything from the BT module unless you say Serial.println( Bt.read() );
1003  Using Arduino / Project Guidance / Re: changing from serial to bluetooth using BT on: January 17, 2014, 03:23:31 pm
In your sketch Serial.read get chars from the Serial monitor, and Bt.read gets chars from your bluetooth.
1004  Using Arduino / Project Guidance / Re: changing from serial to bluetooth using BT on: January 17, 2014, 02:40:34 pm
Look at my edit on my previous post

I know that, I left a lot of stuff out. You can put them in, I just wanted to show you what your code will look like without pointless while loops.

Quote
does the BT shield send the whole string at one or character by character?

character by character.
1005  Using Arduino / Project Guidance / Re: changing from serial to bluetooth using BT on: January 17, 2014, 01:39:34 pm
No while loops, and no Strings.
Code:
char Buffer;

void setup()
{
  Serial.begin(9600);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
  bluetoothInitiate();
}

void loop() {
  if(Serial.available() > 0)
  {
     char SerialChar = Serial.read() ;
  }

  if(Bt.available() && SerialChar== '0') //Serial
  {
    //Serial.print("Transmitting");
    Buffer = Bt.read();//Serial
    value = value *10 +(Buffer - '0');
    Serial.println(value);
    Bt.println(value);  //Serial.println
    value = 0;

    irrecv.enableIRIn(); // Start the receiver
  }
  
  if (irrecv.decode(&results))
  {
    Bt.println("Receiving");//Serial
    Serial.println(results.value);
    Bt.println(results.value);
    irrecv.resume();      
  }
}

EDIT:
I added this because I missed it before.
Quote
void loop() {
  if(Serial.available() > 0)
  {
     char SerialChar = Serial.read() ;
  }


  if(Bt.available() && SerialChar== '0') //Serial
Pages: 1 ... 65 66 [67] 68 69 ... 228