Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Dynamic matrix on: March 22, 2011, 05:34:00 am
Can you give me an example please?
2  Using Arduino / Programming Questions / Re: Dynamic matrix on: March 22, 2011, 05:19:09 am
Last question, I hope….
I want to create 2D array, that’s wrong with this code?

Code:
int x,y;
 int* vector = (int*)malloc(sizeof (int) * x);
 for(int i=0;i<2; i++)
  {
    int*  vector[i]=(int*)malloc(sizeof (int) *y);
  }
3  Using Arduino / Programming Questions / Re: Dynamic matrix on: March 22, 2011, 04:44:34 am
Can you give me an example please?
4  Using Arduino / Programming Questions / Re: Dynamic matrix on: March 22, 2011, 04:31:06 am
How to make a dynamic matrix in the arduino IDE?
5  Using Arduino / Programming Questions / Dynamic matrix on: March 22, 2011, 04:26:47 am

I have written below code for dynamic matrix, and it has got an error compiling
C:\Users\kostas\AppData\Local\Temp\build6344196874205377199.tmp/dynamic_matrix.cpp:83: undefined reference to `operator new[](unsigned int)'
C:\Users\kostas\AppData\Local\Temp\build6344196874205377199.tmp/dynamic_matrix.cpp:86: undefined reference to `operator new[](unsigned int)'

 and I don’t understand, that is the wrong?
Code:


#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 6, 7);

int **matrix;
int m;  //col
int n;  //row

/////////////////////////DILOSI METAVLITON GIA TO PLIKTROLOGIO
int analogInputPin=0;
int totalOutputDigit=9;
int KeyForEnder='D';
int keyForClear='C';
int rowToPrint=0;
int columnToPrint=0;
int keyboardMode='mod0';
int IncomingString;
///////////////////////////DILOSI METAVLITON GIA TO PLIKTROLOGIO



void printmatrix(int **matrix, int m, int n);
void readmatrix(int **matrix, int m,int n);


void setup()
{
  Serial.begin(1200);
  lcd.begin(6,2);


}
void loop()
{
  rowToPrint=15;
  columnToPrint=1;
  lcd.print("row");
   n=getPressString(IncomingString,analogInputPin,KeyForEnder,keyForClear,rowToPrint,columnToPrint,keyboardMode);
  Serial.print("number row:");
  Serial.print(n);
  lcd.clear();
  lcd.print("collumn");
   m=getPressString(IncomingString,analogInputPin,KeyForEnder,keyForClear,rowToPrint,columnToPrint,keyboardMode);
  Serial.print("number col:");
  Serial.print(m);
  lcd.clear();
 
  matrix= new int*[n];
  for(int i=0; i<n; i++)
  {
    matrix[i]=new int[m];
  }
 
  readmatrix(matrix, m, n);
  printmatrix(matrix, m, n);

halt:
  goto halt;
}


void readmatrix(int **matrix, int m,int n)
{
  int i,j;
  int rowToPrint=15;
  int columnToPrint=1;
  for(i=0; i<=n; i++)
  {
    for(j=0; j<=m; j++)
    {
      lcd.print("stoixeio ");
      lcd.print(i);
      lcd.print(j);
      matrix[i][j]=random(200);
      Serial.print(matrix[i][j]);
    } 
  } 
}


void printmatrix(int **matrix, int m, int n)
{
  int i,j;

  for(i=0; i<=n; i++)
  {
    for(j=0; j<=m; j++)
    {
      Serial.print(matrix[i][j]);
    }
    Serial.println(" ");
  }
}


The function getPressString read the keyboard (4 row, 4 column, 16 button)


6  Using Arduino / Programming Questions / Re: Question for gps and interrupts on: March 21, 2011, 10:38:46 am
Okay, I understand now.
Thanks for the answers!
7  Using Arduino / Programming Questions / Re: Question for gps and interrupts on: March 21, 2011, 10:08:40 am
Quote
This function, whatever it does, is called AFTER a complete sentence has been read from the GPS. It is not going to grab any data, unless you plan on throwing away the sentence that was just completed.

The function getgps(gps) there is at sparkfun.

Code:
void getgps(TinyGPS &gps)
{
 
 
  float latitude, longitude;
 
  gps.f_get_position(&latitude, &longitude);
 
  Serial.print("Lat/Long: ");
  Serial.print(latitude,5);
  Serial.print(", ");
  Serial.println(longitude,5);

}

Do I have to make any ckecks before I grab the data from the gps

Code:
.
 .
 .
while(uart_gps.available())
int c = uart_gps.read();   
if(gps.encode(c))
 {
       getgps(gps);         
  }
 .
 .
 .

do I have an immediate access to the latitude and longitude of what is stored in the buffer by using only this function [gps.f_get_position(&latitude, &longitude);]  without above checks?

The initial question that I had asked you was if I can activate the interrupt so as to get immediately the data when these arrive. The gps is connected at pins 2,3 (DLINE).
8  Using Arduino / Programming Questions / Re: Question for gps and interrupts on: March 20, 2011, 11:51:18 am
I have connected the gps to the pins 2,3 (DLINE)
What should  “if ”  control, so that I can read the data from the gps just when they ready?

Code:
if(uart_gps.available())
{
  Gps_read();
}

or

Code:
int c = uart_gps.read();   
 if(gps.encode(c))
{
Gps_read();
}     


Code:
Gps_read();
{
while(uart_gps.available())     // While there is data on the RX
  {
      int c = uart_gps.read();    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
      {
        getgps(gps);         // then grab the data.
      }
  }

}



9  Using Arduino / Programming Questions / Re: Question for gps and interrupts on: March 20, 2011, 09:16:44 am
When data  from the gps comes is it saved in the serial until we read it?
With follow code do I have to read data only the moment it comes or when the half data has come?

Code:
  . 
  .
  .
if(uart_gps.available())
{
  Gps_read();
}
 .
 .
 .
   

Gps_read();
{
while(uart_gps.available())     // While there is data on the RX
  {
      int c = uart_gps.read();    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
      {
        getgps(gps);         // then grab the data.
      }
  }

}


10  Using Arduino / Programming Questions / Re: Question for gps and interrupts on: March 19, 2011, 11:24:30 am
My problem is that I want to activate the interrupt every time that receive data from the gps. The code from the sparkfun only reads the gps. However, my program performs more function and has to read the gps only when it has data. How  can I do it?
11  Using Arduino / Programming Questions / Question for gps and interrupts on: March 19, 2011, 07:49:05 am
I have bought the Arduino Uno and the gps EM406A(http://www.sparkfun.com/products/465) with this shield(http://www.sparkfun.com/products/9898). The gps has 1Hz update rate. The gps is connected with the Arduino at pins 0,1 (UART) or pins 2,3 (DLINE) (http://www.sparkfun.com/tutorials/173). Is there any way in which I will be able to activate any interruption when I receive data? Where should I connect the gps? DLINE or UART? Is it possible for you to give me a code to correspond to the function mentioned above?
Pages: [1]