Show Posts
Pages: 1 2 3 [4] 5 6 ... 10
46  Using Arduino / Programming Questions / Re: Arduino/BlueSmirf Bluetooth Connection issues on: June 26, 2012, 08:26:00 am
Well I don't really plan on the mega being used on this project much longer.  I was either gonna use a dum. Or a pro mini.  But I hadn't thought about the fact that certain pins might not work for software serial on the mega.  So when I get home I'll have to try other pins or the other available uarts.  But I'm still not convinced that's the problem.  Because when I connect the bluesmirf to the pins 0,1 which are for the default "serial" connection I still get nothing.  So I still think its a bluesmirf hardware issue.  Unless I'm wrong on that too.
47  Using Arduino / Programming Questions / Re: Arduino/BlueSmirf Bluetooth Connection issues on: June 25, 2012, 12:32:34 pm
yes, arduino and putty are set to proper bauds.
bluetooth is auto-negotiation so there is no setup needed physically on the bluetooth, im pretty sure about that.
48  Using Arduino / Programming Questions / Arduino/BlueSmirf Bluetooth Connection issues on: June 24, 2012, 11:23:29 am
Hey guys,
not sure if this is the right place for this question, but it involves an example code so maybe it is.
for a project of mine, of i have an older arduino mega 1280 connected to a blue smirf gold from sparkfun: http://www.sparkfun.com/products/158
however, with the example code provided with arduino 1.0, i can't get anything to show up in the bluetooth serial port(using putty for the bluetooth port)
does anybody have an idea as to why the bluetooth would be seemingly not working? I have the hardware connections exactly as they say in the sample code:
RX(bluesmirf)-->TX(pin 3)(arduino)
TX(bluesmirf)-->RX(pin 2)(arduino)
VCC(bluesmirf)-->3.3v arduino mega
ground-->ground

Code:
/*
  Software serial multple serial test
 
 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 
 The circuit:
 * RX is digital pin 2 (connect to TX of other device)
 * TX is digital pin 3 (connect to RX of other device)
 
 created back in the mists of time
 modified 9 Apr 2012
 by Tom Igoe
 based on Mikal Hart's example
 
 This example code is in the public domain.
 
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()  
{
 // Open serial communications and wait for port to open:
  Serial.begin(57600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}
49  Using Arduino / Programming Questions / Re: Arduino 1.0 new Serial commands on: June 22, 2012, 04:39:27 pm
thanks for the sample code and explanation.  with your help it seems to be working well now
although i do have one question, what does the F() do in
Code:
F("raw: ")
my code is now:
Code:
void useSerial()
{
//This function is for commanding the qik only through Serial
while(Serial.available() >= 6)
{
  Serial.print(F("raw: "));
  Serial.println(Serial.available());
  boolean ready = Serial.findUntil("!","~");
  if(ready)
  {
    Serial.print(F("processed: "));
    Serial.println(Serial.available());
    if (Serial.available() >= 4)
    {
       command = Serial.read();
       Serial.print("Command is:  ");
       Serial.println(command);
       byte3 = Serial.read();
       Serial.print("Byte3 is:  ");
       Serial.println(byte3);
       byte4 = Serial.read();
       Serial.print("Byte4 is:  ");
       Serial.println(byte3);
       byte5 = Serial.read();
       Serial.print("Byte5 is:  ");
       Serial.println(byte5);
    }
  }
}
}
50  Using Arduino / Programming Questions / Re: Arduino 1.0 new Serial commands on: June 22, 2012, 04:01:37 pm
well i only want the bytes after the '!' byte.
i think the bigger issue is that when I run input something like '!0100~'  i get a response of:
'1
1
2'
since the only serial.print commands are for the printing of available bytes, i think there may be some issue with the new serial commands, such as the serial.findUntil.  i cant get it to work quite right
51  Using Arduino / Programming Questions / Arduino 1.0 new Serial commands on: June 22, 2012, 03:38:41 pm
Hey everyone,
So for a new project of mine I am trying to use the new Arduino 1.0 system.  But I seem to be having a bit of trouble with the new serial commands.  Basically what I am trying to do is send 6 bytes to the arduino and have the arduino parse out those bytes and act accordingly.  The byte is structured as such:
1) negotiator, such as '!"
2) motor/command selection '0-6'
3)motor speed, byte1
4)motor speed, byte2
5)motor speed, byte 3
6)terminator, such as '~'
The motor speed is made up of three bytes because I would like to send values '000' through '255' through the three bytes.

Does anyone have a good idea as to how i can receive the bytes, look for the negotiator, parse the next four bytes, and wrap/end everything up with the terminator??
I think I should be using the Serial.findUntil() and the Serial.parseint() commands but I can't get everything to work properly together.
I have the following code:
Code:
void useSerial()
{
//This function is for commanding the qik only through Serial
while(Serial.available() > 0)
{
  Serial.println(Serial.available());
  boolean ready = Serial.findUntil("!","~");
  if(ready)
  {
    Serial.println(Serial.available());
    if (Serial.available() == 4)
    {
      byte1 = Serial.read();
      byte2 = Serial.read();
      byte3 = Serial.read();
      byte4 = Serial.read();
      Debug();
    }
  }
}
}
and basically Serial.available seems to always be either 1 or 0, no matter how much info i send through.
Any help would be greatly appreciated.
52  Using Arduino / Project Guidance / Re: Arduino + Garmin Nuvi on: August 08, 2011, 02:13:04 pm
Uh not to great.  Is the garmin really that proprietary?  So basically there is no way to do this?
53  Using Arduino / Project Guidance / Arduino + Garmin Nuvi on: August 08, 2011, 01:37:50 pm
Hi, I would really like to interface my arduino directly to my Garmin Nuvi and read GPS data from it into my arduino.
Does anybody know if this feasible?  Maybe with a USB host shield from sparkfun?
54  Using Arduino / Programming Questions / Arduino + BMA180 Accelerometer on: July 10, 2011, 10:27:51 pm
Hi, I recently got the BMA180 breakout from sparkfun:  http://www.sparkfun.com/products/9723
but i can't seem to figure it out.  I have it hooked up like in the picture below:

So I'm pretty sure I have it hooked up right.
However, when I run the following really simple code, to just check the chip ID and set some values, I don't get proper results for the CHIP ID, it should be 3.
Code:
#include <Wire.h>

#define DEVICE 0x40
#define CHIP_ID 0x00
#define R_ACC_X_LSB      0x02
#define R_ACC_X_MSB      0x03
#define R_ACC_Y_LSB      0x04
#define R_ACC_Y_MSB      0x05
#define R_ACC_Z_LSB      0x06
#define R_ACC_Z_MSB      0x07
#define R_CTRL_REG0      0x0D
#define R_BW_TCS         0x20
#define R_CUST_DATA1     0x2C
#define R_OFFSET_LSB1    0x35

int temp, result, error;

void setup()
{
  Wire.begin();
  Serial.begin(115200);
  initializeBMA180();
}

void loop()
{
  //getXAccel();
}

void initializeBMA180()
{
  checkID();
  enableWrite();
  setFilter();
  setRange();
}

void checkID()
{
  Wire.beginTransmission(DEVICE);
  Wire.send(0x00);
  Wire.requestFrom(DEVICE, 1);
  while(Wire.available())
  {
    temp = Wire.receive();
  }
  error = Wire.endTransmission();
  Serial.print("Chip ID:  ");
  Serial.print(temp);
  Serial.print("    Result:  ");
  Serial.println(error);
}

void enableWrite()
{
  //Connect to the ctrl_reg0 register and set the ee_w bit to enable writing
    Wire.beginTransmission(DEVICE);
    Wire.send(0x0D);
    Wire.send(B0001);
    result = Wire.endTransmission();
    Serial.print("Enable Write Result:  ");
    Serial.println(result);
    delay(10);
}

void setFilter()
{
  // Connect to the bw_tcs register and set the filtering level to 10hz
    Wire.beginTransmission(DEVICE);
    Wire.send(0x20);
    Wire.send(B00001000);
    result = Wire.endTransmission();
    Serial.print("Set Filter Result:  ");
    Serial.println(result);
    delay(10);
}

void setRange()
{
    Wire.beginTransmission(DEVICE);
    Wire.send(0x35);
    Wire.send(B0100);
    result = Wire.endTransmission();
    Serial.print("Set Range Result:  ");
    Serial.println(result);
    delay(10);
}

inline int getXAccel()
{
  byte msb = getRegister(R_ACC_X_MSB);
  byte lsb = getRegister(R_ACC_X_LSB);
  Serial.println((((msb << 8) | lsb) >>2));
}

int getRegister(byte registerAddr)
{
  Wire.beginTransmission(DEVICE);
  Wire.send(registerAddr);
  Wire.endTransmission();
  Wire.requestFrom(DEVICE,1); // request numbytes bytes
  
  int n=Wire.available();
  if (n==0) {
    Serial.println("getRegister: error: 0 bytes available");
  }
  //printRegisterOperation(true,registerAddr,val);  
  return Wire.receive();
}

But, if I run that same code but with initializeBMA180() as:
Code:
void initializeBMA180()
{
  checkID();
  //enableWrite();
  //setFilter();
  //setRange();
}

I get the proper chip id.  What would be causing this?

Thanks for all and any help!!
55  Using Arduino / Project Guidance / Re: ethernet to serial conversion on: March 18, 2011, 06:08:49 am
this is what i have so far,
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] =     { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[]  =     {192, 168, 0, 20 };
byte gateway[] = {192, 168, 0, 254 };
byte subnet[]  = {255, 255, 255, 0 };

#define textBuffSize 3
char textBuff[textBuffSize];
int charsReceived = 0;
boolean connectFlag = 0;
unsigned long timeOfLastActivity;
unsigned long allowedConnectTime = 300000;
Server server(23);
Client client = 0;

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.begin(9600);
}

void loop()
{
  if (server.available() && !connectFlag) {
    connectFlag = 1;
    client = server.available();
    Serial.println("Tank Controller");
    printPrompt();
  }
  if (client.connected() && client.available()) getReceivedText();
  if(connectFlag) checkConnectionTimeout();
}

void printPrompt()
{
  timeOfLastActivity = millis();
  client.flush();
  charsReceived = 0;
}

void checkConnectionTimeout()
{
  if(millis() - timeOfLastActivity > allowedConnectTime)
  {
    client.stop();
    connectFlag = 0;
  }
}

void getReceivedText()
{
  char c;
  int charsWaiting;
  charsWaiting = client.available();
  do {
    c = client.read();
    textBuff[charsReceived] = c;
    charsReceived++;
    charsWaiting--;
  }
  while(charsReceived <= textBuffSize &&  charsWaiting > 0);
  if(c == 0x0d) {
    parseReceivedText();
    printPrompt();
  }
  if(charsReceived >= textBuffSize)
  {
    printPrompt();
  }
}

void parseReceivedText()
{
  Serial.println("He1lo");
  if( textBuff[0] != '!' ) {Serial.println("not equal");}
  if( (textBuff[1] < '"') or (textBuff[1] > '&')) {Serial.println("invalid");}

Program seems to work fine with putty, but as soon as i try it with matlab, i dont get the same results.  I am finding this very tricky to debug.
56  Using Arduino / Project Guidance / ethernet to serial conversion on: March 17, 2011, 09:42:33 pm
Hi, Im looking for a way to send ethernet commands to my arduino, have those ethernet commands converted to serial and parsed on the arduino.  my current solution is to have an ethernet shield and read the data into the arduino but i am having a really hard time reading in the data.  im asking to see if anyone knows of an easier method?  i want to be able to send something simple like telnet commands via matlab over a wireless connection to my arduino.

suggestions anyone?

Thanks in advance
57  Using Arduino / General Electronics / Re: reset arduino with 555 on: March 10, 2011, 08:08:38 pm
sorry, i couldnt find any sample code that i have, but really look at what pwillard has to say, it will help tremendously.

also, in the setup, set whatever pin you will use to trigger the monostable to 'output', and in the next line of code, write it to high, then  when you want to trigger a restart, write the output pin to low, which will then trigger the reset and restart your arduino.

keep in mind that what they have been saying about the inline capacitor overloading the pin, may certainly be true, never gave me any trouble.  all i can say, is that the posted circuit worked perfectly for me.  good luck
58  Using Arduino / General Electronics / Re: reset arduino with 555 on: March 10, 2011, 07:56:02 pm
i am trying to find some sample code that i have to put up with the explanation
59  Using Arduino / General Electronics / Re: reset arduino with 555 on: March 10, 2011, 07:54:30 pm
The nice part of my circuit is that you don't need to continuously "pat" the dog.  whenever you want to restart the circuit, you just drive the specified arduino output pin high or low depending on how it is initialized in the setup code.  basically, the trigger pin of the 555 is held low and happy, then whenever it is triggered by arduino, the 555 sends a low to the arduino reset to restart the arduino.  the 555 then keeps it low until its satisfied (determined by threshold resistor and cap values) then sends another happy high signal to the arduino reset to keep the arduino from restarting again.

FYI, the highs and lows in the above may be flipped and reversed, its been a good long while since i built and tinkered with the circuit.  just remember, no patting of the dog in this
60  Using Arduino / Interfacing w/ Software on the Computer / Re: Serial Communication C++ -->Arduino on: March 03, 2011, 05:38:15 pm
Basically none of this stuff is native to me lol.  The only reason I chose c++ is because its the only route I could find for capturing xbox controller input.  Are you aware of any other methods?  I would love to do it via matlab if thats possible.  Currently I am trying to take me working c++ xbox input code and create a matlab MEX file from it so that I can catch input with matlab, but this is very confusing.
Pages: 1 2 3 [4] 5 6 ... 10