Show Posts
Pages: [1] 2 3 ... 13
1  Community / Products and Services / ArduinoCommander not working on: September 11, 2014, 12:39:03 pm
Hi,

ArduinoCommander seems to not connect to Arduino Leonardo.

This is what I've done chronologically:
1. installed ArduinoCommander on my tablet which has android 4.3.2.
2. uploaded the standard firmata sketch onto the Leonardo
3. connected the Leonardo via microUSB to the tablet.
4. set the correct baud rate
5. try to connect

The app either hangs or it says connection failed. What's the problem with it? It got the same results with multiple android devices.
2  Using Arduino / Interfacing w/ Software on the Computer / Firmata porting capabilities on: August 12, 2014, 06:15:56 am
Hi,

Up until now, I have been interacting with an arduino by using the firmata library for processing.

Due to my poor programming skills in Java, I'm forced to go to something much more friendly to me: C++.

The question is: where can I get a library developed in C++ to work with on visual studio? The end objective is to control 8 servos.
I hope there's something already implemented, because writing on myself a new library for firmata protocol would be insane.
3  Using Arduino / Programming Questions / Android Smartphone to laptop on: July 22, 2014, 04:56:49 pm
Hi,

I have an android smartphone and a laptop and I want to establish a bidirectional bluetooth link between them.

What I want is for my laptop to request taking pictures from the smartphone camera. After that, the command would tell the smartphone to send to the laptop the recently taken picture for further processing.

All the instructions shall be described inside a C++ program (maybe a CLR console application maybe inside Visual Studio).
My final intention with the pictures is to make some pattern recognition.

The question is: How can I achieve that without interfering with the smartphone?

With other words I'm in a room with a laptop, and in the other room is the smartphone. How can take pictures from the smartphone's camera via bluetooth, process them in my laptop, all without but a single command sent from a C++ program?
4  Using Arduino / Programming Questions / Re: [SOLVED] Shuffle a char array? on: July 22, 2014, 02:55:49 pm
Aha.

PROGMEM function (or fix) is quite counter intuitive, but I understand.

But I do not understand why to get rid of Strings? I mean, with strings you have lower chances of making a mistake. It's more easier to take care of memory. Or is it because Arduino doesn't have much RAM memory?
5  Using Arduino / Installation & Troubleshooting / Re: Arduino Leonardo USB Issue on: July 22, 2014, 12:58:23 pm
I have tried reburning the bootloader through ArduinoISP, with no success. When I hit the burn button, after a few seconds it displayed it's error at reprogramming. As a programmer, I have used a Duemilanove.
6  Using Arduino / Programming Questions / Re: [SOLVED] Shuffle a char array? on: July 22, 2014, 02:47:35 am
So you tell I have to do this?

Code:
Serial.print(pgm_read_byte(4*sizeof(String)+option*24+i));
7  Using Arduino / Installation & Troubleshooting / Re: Arduino Leonardo USB Issue on: July 21, 2014, 12:37:20 pm
Still the same output.
8  Using Arduino / Installation & Troubleshooting / Arduino Leonardo USB Issue on: July 21, 2014, 11:46:21 am
I have an Arduino Leonardo.

I was working today with it when at some point I think it malfunctioned.

This is the scenario:

1. I connect the board through USB to my PC.
2. Power LED turn on.
3. L LED blinks while at the same time I'm notified on my PC that something connected at a port. (I hear that specific WIN7 audio when something connects)
4. In my Device Manager a COM14 appears indicating an Arduino Leonardo.
5. L LED turns off after 5-6 seconds when at the same time I'm again notified on my PC that something disconnected.
6. As a consequence, in Device Manager, any port suggesting Arduino is not to be seen.

I can guarantee my USB cable is fine, because I've tested with a Nexus.

Is my board burned? Do I have to buy a new one? The board is quite new,it hasn't been used for more than a couple of times.

Thanks
9  Using Arduino / Programming Questions / Re: [SOLVED] Shuffle a char array? on: July 21, 2014, 11:30:58 am
I think implementing a backtracking algorithm is not necessary.

In this situation there are only 24 permutations, therefore only 96 bytes needed to be occupied. I put them not in RAM, but in the Flash. It's more efficient this way.

I don't have to reset myself the EEPROM value. It automatically resets itself, right? Ones it reaches it's maximum high value, then it goes back to 0. My only job is to increment at every boot up the value.

Code:
#include <avr/pgmspace.h>
#include <EEPROM.h>

uint8_t address = 0;
uint8_t option;
PROGMEM const String states[4] = {"Null","Win","Lose","Accel"};
PROGMEM const uint8_t SEQUENCE[24][4] = {{0,1,2,3},{0,1,3,2},{0,2,1,3},{0,2,3,1},{0,3,1,2},{0,3,2,1},
                                         {1,0,2,3},{1,0,3,2},{1,2,0,3},{1,2,3,0},{1,3,0,2},{1,3,2,0},
                                         {2,0,1,3},{2,0,3,1},{2,1,0,3},{2,1,3,0},{2,3,0,1},{2,3,1,0},
                                         {3,0,1,2},{3,0,2,1},{3,1,0,2},{3,1,2,0},{3,2,0,1},{3,2,1,0}};
uint8_t shuffle()
{
  uint8_t val = EEPROM.read(address);
  EEPROM.write(address,val+1);
  return val%24;
}

void setup()
{
  option = shuffle();
  Serial.begin(9600);
 
  for(uint8_t i=0; i<4; i++)
  {
    Serial.print(states[SEQUENCE[option][i]]);
    Serial.print(" ");
  }
  Serial.println();
}
void loop()
{
 
}

What I don't understand is why this code doesn't work. It's properly written. The arduino does nothing when it runs. No logic whatsoever. But maybe this situation is of the same kind as the other ones. My Arduino seems to be burned, the government decided I have to pay another 700$ taxes for my car (retroactive measure), and now this code doesn't work. Great day. Swell  smiley-yell
10  Using Arduino / Programming Questions / Re: [SOLVED] Shuffle a char array? on: July 21, 2014, 04:49:25 am
Hmm replace my
Code:
millis()%4
with
Code:
random(4)
and see what you get. I'm curious.

millis() returns milliseconds since startup.
The same code will take the same number of ms to reach the
Code:
millis()%4
every time unless tied to an external event.

If at startup the user is required to press a switch of some kind (a led and a resistor can be a switch) then you will get random time. I would use micros() bits 2 and 3 rather than millis() but that's just me.



I understand what are you telling. I've also tried using micros() but the program would hang out. I do not understand why it does this.

Another solution would have been to backtrack, and select the sequence found at a specific index incrementally. Say we backtrack with a n=4, thus having 24 possible sequences.
At boot up no=0x01 we select the first sequence our backtracking algorithm gives us.
At boot up no=0x02 we select the second sequence our backtracking algorithm gives us.
And so on for the next 22 sequences.
When it reaches the end, it resets itself.

It is at the same time both predictable and random, plus it doesn't use much processing power nor ram memory (just 3 bytes for the algorithm, excluding the states array)
11  Using Arduino / Programming Questions / Re: Shuffle a char array? on: July 20, 2014, 07:12:34 pm
Hmm replace my
Code:
millis()%4
with
Code:
random(4)
and see what you get. I'm curious.
12  Using Arduino / Programming Questions / Re: Shuffle a char array? on: July 20, 2014, 07:06:14 pm
I don't know why it's repeating the values. Mine doesn't. I have a Leonardo.

Also consider that the values stay the same for the rest of the run.

Do you get different sequences after each reset?
13  Using Arduino / Programming Questions / Re: Serial not working on: July 20, 2014, 06:53:30 pm
You were right, my friend. It worked. I would have never thought about this.

Thanks
14  Using Arduino / Programming Questions / Re: Shuffle a char array? on: July 20, 2014, 06:50:02 pm
First of all, you can't assign a string to a single character.

You can use the millis() function to give "random" numbers, than mod it by 4, since there are 4 elements. Up until now, I didn't succeed on using the micros() function (I don't know why), which would have been better, since it changes it's value faster, and thus helps on the "randomness".

Here's the code.

Code:
char states[4][6] = {"Null","Win","Lose","Accel"};

void shuffle()
{
  int new_order[4],k=0;
 
  for(int i=0; i<4; i++)
  {
    int new_position = millis()%4;
    for(int j=0; j<k; j++)
    {
      if(new_position==new_order[j])
      {
        new_position = millis()%4;
        j = -1;
      }
    }
    new_order[k] = new_position;
    k++;
  }
 
  for(int i=0; i<4; i++)
  {
    for(int j=0; j<6; j++)
    {
      char aux = states[new_order[i]][j];
      states[new_order[i]][j] = states[i][j];
      states[i][j] = aux;
    }
  }
 
  for(int i=0; i<4; i++)
  {
    Serial.print(states[i]);
    Serial.print(" ");
  }
  Serial.println();
}

At the end I put some prints for debugging.
At every new start up, there should be a different order between the 4 strings.

Good luck
15  Using Arduino / Programming Questions / Serial not working on: July 20, 2014, 06:11:12 pm
I have Arduino IDE version 1.0.5.

I have connected my Arduino Leonardo through USB to the PC.
I have connected to my Arduino a Xbee module at pins 2 and 3 with SoftwareSerial.
I also have a Xbee module connected to the PC.
Both of the XBee modules are set to API mode 2 (I don't know if this matters).

This is the code I'm running:
Code:
#include <SoftwareSerial.h>

char buffer[256];
SoftwareSerial xbee(2,3);

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

void loop()
{
  if(xbee.available())
  {
    xbee.readBytes(buffer,xbee.available());
    Serial.println(buffer);
  }
}

Both the Xbee modules notify serial messages through their LEDs. Both of them were checked to see if they are operational.

The question is simple: why doesn't the serial port (on 2 and 3 pins) work?  When I attach to xbee Serial1 port, it does work, but when I use SoftwareSerial, it doesn't.
Pages: [1] 2 3 ... 13