Loading...
  Show Posts
Pages: [1]
1  International / Français / Re: Partie optionnelle dans un projet ! on: March 25, 2013, 04:11:40 pm
Ce code pourra vous éclaircir plus peu être :
Code:
#include <Keypad.h>

#define SHIFT 5
#define LATCH 6
#define DATA 7

#define SHIFT_2 10
#define LATCH_2 11
#define DATA_2 12

/*------------------------------------------------------------------------------------------*/
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {3, 2, A5, A4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A3,A2, A1, A0}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

/*------------------------------------------------------------------------------------------*/
const byte chars[10] = {
    B00111111,//0
    B00000110,//1
    B01011011,//2
    B01001111,//3
    B01100110, //4
    B01101101, //5
    B01111101,//6
    B00000111,//7
    B01111111,//8
    B01101111 //9
    };


int i2 = 0 ;
int s1 = 0 ;
char s11 = 'T';
int s2 = 0 ;
char s22 = 'T' ;
/*------------------------------------------------------------------------------------------*/
void setup(){
  Serial.begin(9600);
  // On déclare les pins vers le 74HC595 en sortie
    pinMode(SHIFT, OUTPUT);
    pinMode(LATCH, OUTPUT);
    pinMode(DATA, OUTPUT);
    pinMode(SHIFT_2, OUTPUT);
    pinMode(LATCH_2, OUTPUT);
    pinMode(DATA_2, OUTPUT);
   
   
}

void loop(){
  char mode = keypad.getKey();
  while(mode!=NO_KEY){
 
 
  while(mode == 'A')
{
       
        s11 = keypad.getKey() ;
        int s1 = s11 - '0';   
        while(s11!=NO_KEY){
       
        s22 = keypad.getKey() ;
        int s2 = s22 - '0';
        if(s2>5){s2=0;}   
        while(s22!=NO_KEY){
         
         
        for ( int i = s1 ; i<10 ; i++ ){
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, SHIFT, MSBFIRST,chars[i]);
        digitalWrite(LATCH, HIGH);
       
        digitalWrite(LATCH_2, LOW);
        shiftOut(DATA_2, SHIFT_2, MSBFIRST,chars[s2]);
        digitalWrite(LATCH_2, HIGH);
        delay(1000);
       
        if(i==9)
        {s2++;}
        if(s2==6)
        {s2=0;}       
        s1=0;
       
        if(keypad.getKey()=='*')   // si * préssé il arete le mode A et retourne dés le début
        {
        i=11;
        s22=NO_KEY;
        s11=NO_KEY;
        mode=NO_KEY;}
        }
       
       
        }}}
       

/*-------------------------------------------------------------------------------------------*/

while(mode == 'B')    // mode chronométre
{
       
        for(int i=0 ; i<10 ; i++ ){
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, SHIFT, MSBFIRST, chars[i]);
        digitalWrite(LATCH, HIGH);
       
        digitalWrite(LATCH_2, LOW);
        shiftOut(DATA_2, SHIFT_2, MSBFIRST, chars[i2]);
        digitalWrite(LATCH_2, HIGH);
       
        if(i==9)
        {i2++;}
        if(i2==6)
        {i2=0;}
        delay(16);
        }
       
        if(keypad.getKey()=='*'){mode = NO_KEY;}
} // ici s'ajoutera le 3eme mode
if((mode != 'A')&&(mode!= 'B')) {mode=NO_KEY;} 
}
}


L'autre mode sera basé sur le temps de l'ordinateur càd quand je branche le pc et que j'appuis sur la touche du mode 3 l'arduino va prendre le temps du pc .
2  International / Français / Partie optionnelle dans un projet ! on: March 24, 2013, 08:00:09 am
Salut , j'aimerai pas trop entré dans les détail car je suis pressé et mon projet est un peu long a expliqué , en résumé je compte réaliser une horloge a base d'afficheur BCD , il y'a un clavier ou je peu choisir le mode avec laquel elle va fonctionner : mode A : j'entre le temps (par exemple 23:45:06 heure-minute-seconde ) , un autre mode chronomètre , un mode ou l'horloge prend le temp depuis l'horloge de l'ordinateur . J'ai presque terminé d’écrire le code avec les 2 premier mode , il me reste le dérnier mode , j'ai chérché un peu sur les fonctions de temps mais j'ai trouvé beaucoup de fonction et je sais pas laquel utilisé donc je fait apel a vous pour me dire directement comment faire et si possible me donner un exemple précis qui convien a mon cas .
3  International / Français / Améliorer mon programme on: March 21, 2013, 05:35:16 pm
Salut , je compte réaliser une horloge composé de 6 afficheurs BCD , commandé par arduino uno ( 2 si il le faut car bcp de sortie ) , j'utilise également le registre 74C595 pour limité le nombre de sortie , et aussi un petit clavier pour entrer le temps .
Sincèrement ce projet n'est pas très utile mais mon ami passe son bac et a fait option projet et il a choisi montre BCD donc je l'aide comme je peux , je compte faire 3 mode ( 4 si possible )
le code :
Code:
#include <Keypad.h>

#define SHIFT 5
#define LATCH 6
#define DATA 7

#define SHIFT_2 8
#define LATCH_2 9
#define DATA_2 10

/*------------------------------------------------------------------------------------------*/
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'#','0','*','D'}
};
byte rowPins[ROWS] = {3, 2, A5, A4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A3,A2, A1, A0}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

/*------------------------------------------------------------------------------------------*/
const byte chars[10] = {
    B00111111,//0
    B00000110,//1
    B01011011,//2
    B01001111,//3
    B01100110, //4
    B01101101, //5
    B01111101,//6
    B00000111,//7
    B01111111,//8
    B01101111 //9
    };

int aa = 0 ;
int i2 = 1 ;

/*------------------------------------------------------------------------------------------*/
void setup(){
  Serial.begin(9600);
  // On déclare les pins vers le 74HC595 en sortie
    pinMode(SHIFT, OUTPUT);
    pinMode(LATCH, OUTPUT);
    pinMode(DATA, OUTPUT);
    
    
}

void loop(){
  char mode = keypad.getKey();
  while(mode!=NO_KEY){
  char a = keypad.getKey();
  while(a!=NO_KEY){
  
  switch ( mode ) {
    
/*------------------------------------------------------------------------------------------*/      

case 'A' :
{
        int aa = a - '0' ;  // on convertie aa en int
        for ( int i = aa ; i<10 ; i++ ){
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, SHIFT, MSBFIRST,chars[i]);
        digitalWrite(LATCH, HIGH);                                
        delay(1000);
        
        
        if (i == 9 )
        {
        if(i2>5){i2=0;}
        delay(1000);
        digitalWrite(LATCH_2, LOW);
        shiftOut(DATA_2, SHIFT_2, MSBFIRST, chars[i2]);
        digitalWrite(LATCH_2, HIGH);
        i2++;
        }
        }
        a = '0' ;  // on le fait pour qu'aprés le 9 on a 0 et pas revenir a l'état précédent
        
        break ;
    }


/*-------------------------------------------------------------------------------------------*/

case 'B' :
{
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, SHIFT, MSBFIRST, B10001101);
        digitalWrite(LATCH, HIGH);
        delay(1000) ;
        break ;
}
   default :{
   break ;
}
}
}
}
}
1. Aider moi a ameliorer ce programme s'il vous plait .
4  International / Français / Re: no matching function for call to 'Keypad" on: March 19, 2013, 11:32:36 am
J'ai téléchargé 0.23 , ça marche , la compilation est complète sans erreur mais le problème c'est que si je veux utiliser arduino leonardo et un clavier , je pourrai pas a programmer :s
Merci de m'aider
5  International / Français / Re: no matching function for call to 'Keypad" on: March 19, 2013, 09:37:51 am
J'ai ca aussi :
In file included from sketch_mar19a.cpp:1:
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:50: error: 'byte' does not name a type
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:51: error: 'byte' does not name a type
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:78: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:78: error: expected ';' before '*' token
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:79: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\StribudA\Desktop\arduino-1.0.1\libraries\Keypad/Keypad.h:79: error: expected ';' before '*' token
6  International / Français / Re: no matching function for call to 'Keypad" on: March 19, 2013, 09:31:08 am
J'ai déja instalé keypad 1.0 !
Aider moi
7  International / Français / no matching function for call to 'Keypad" on: March 19, 2013, 08:19:04 am
salut , je vien d'acheter un clavier et une arduino , je compte les brancher ensemble , j'ai consulté le site arduino pour voir comment ecrire le programme , mais quand je vérifie avec l'application arduino il m'affiche : no matching function for call to 'Keypad::Keypad(char*, byte [4], byte [3], const byte&, const byte&)'
Le code est celui d'arduino c'est celui la :
Code:
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // c'est ici qu'il y'a la faute

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

void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
}
PS : j'ai utilisé arduino 1.0 et 1.0.3
Aider moi s'il vous plait smiley
8  International / Français / Re: Projet horloge simple on: March 18, 2013, 06:34:51 pm
J'ai modifié le programme en ajoutant la partie qui concerne le clavier , jeter un coup d'oeuille pour me dire si il y'a une faute quelque part s'il vous plait , j'ai découvert aussi le shiftOut qui est trés éfficace , j'ai lut des tutoriel sur lui et je compte demain aller acheter l'arduino + le clavier + le registre 74 (shiftOut) + les afficheur BCD .
Merci de me répondre d'ici demain matin et me donner votre avis sur l'avancement smiley
The code :
Code:
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {45, 44, 43, 42}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {48, 47, 46}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );




int s1 , s2 , m1 , m2 , h1 , h2 ;
byte afficheur_seconde_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_seconde_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 }},
afficheur_minute_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_minute_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 }},
afficheur_heure_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_heure_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 }};

void setup()
        {
        pinMode(0, OUTPUT);
        pinMode(1, OUTPUT);
        pinMode(2, OUTPUT);
        pinMode(3, OUTPUT);
        pinMode(4, OUTPUT);
        pinMode(5, OUTPUT);
        pinMode(6, OUTPUT);
        pinMode(7, OUTPUT);
        pinMode(8, OUTPUT);
        pinMode(9, OUTPUT);
        pinMode(10, OUTPUT);
        pinMode(11, OUTPUT);
        pinMode(12, OUTPUT);
        pinMode(13, OUTPUT);
        pinMode(14, OUTPUT);
        pinMode(15, OUTPUT);
        pinMode(16, OUTPUT);
        pinMode(17, OUTPUT);
        pinMode(18, OUTPUT);
        pinMode(19, OUTPUT);
        pinMode(20, OUTPUT);
        pinMode(21, OUTPUT);
        pinMode(22, OUTPUT);
        pinMode(23, OUTPUT);
        pinMode(24, OUTPUT);
        pinMode(25, OUTPUT);
        pinMode(26, OUTPUT);
        pinMode(27, OUTPUT);
        pinMode(28, OUTPUT);
        pinMode(29, OUTPUT);
        pinMode(30, OUTPUT);
        pinMode(31, OUTPUT);
        pinMode(32, OUTPUT);
        pinMode(33, OUTPUT);
        pinMode(34, OUTPUT);
        pinMode(35, OUTPUT);
        pinMode(36, OUTPUT);
        pinMode(37, OUTPUT);
        pinMode(38, OUTPUT);
        pinMode(39, OUTPUT);
        pinMode(40, OUTPUT);
      char ss1 = keypad.getKey();
      char ss2 = keypad.getKey();
      char mm1 = keypad.getKey();
      char mm2 = keypad.getKey();
      char hh1 = keypad.getKey();
      char hh2 = keypad.getKey();
      int s1 = ss1 - '0';
      int s2 = ss2 - '0';
      int m1 = mm1 - '0';
      int m2 = mm2 - '0';
      int h1 = hh1 - '0';
      int h2 = hh2 - '0';
      correction();
      }
 
       

void loop()
{
 
for (int pin=0 ; pin<7 ; pin++){
digitalWrite(pin     , afficheur_seconde_1[s1][pin]);
digitalWrite((pin+7) , afficheur_seconde_2[s2][pin]);
digitalWrite((pin+14), afficheur_minute_1[m1][pin]);
digitalWrite((pin+21), afficheur_minute_2[m2][pin]);
digitalWrite((pin+28), afficheur_heure_1[h1][pin]);
digitalWrite((pin+35), afficheur_heure_2[h2][pin]);
}

s1++;
if(s1>9)
{s1 = 0 ;
s2++ ;}
if(s2>5)
{s2=0;
m1++;}
if(m1>9)
{m1 = 0 ;
m2++ ;}
if(m2>5)
{m2=0;
h1++;}
if(h1>9)
{h1 = 0 ;
h2++ ;}
if((h2=2)&&(h1>3))
{h2=0;
h1;}
delay(990);
}
9  International / Français / Projet horloge simple on: March 17, 2013, 12:32:35 pm
Salut , je compte réaliser un projet qui consiste en une horloge commandé par arduino mega ( car j'ai besoin de bcp de sortie ) et sous forme de 6 afficheurs 7 segments ( 2 pour afficher les secondes , 2 pour afficher les minutes et 2 pour l'heure ) , je compte également ajouter un clavier numérique avec lequel l'utilisateur peu entrer l'heure , la minute et la seconde .
Mon code est simple a comprendre mais très long :

Code:
int s1 , s2 , m1 , m2 , h1 , h2 ;
byte afficheur_seconde_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_seconde_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 }},
afficheur_minute_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_minute_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 }},
afficheur_heure_1[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 },
{ 1,1,1,1,0,0,1 },
{ 0,1,1,0,0,1,1 },
{ 1,0,1,1,0,1,1 },
{ 1,0,1,1,1,1,1 },
{ 1,1,1,0,0,0,0 },
{ 1,1,1,1,1,1,1 },
{ 1,1,1,1,0,1,1 }},
afficheur_heure_2[10][7]={{0,0,0,0,0,0,1 },
{ 0,1,1,0,0,0,0 },
{ 1,1,0,1,1,0,1 }};

void setup()
        {
        pinMode(0, OUTPUT);
        pinMode(1, OUTPUT);
        pinMode(2, OUTPUT);
        pinMode(3, OUTPUT);
        pinMode(4, OUTPUT);
        pinMode(5, OUTPUT);
        pinMode(6, OUTPUT);
        pinMode(7, OUTPUT);
        pinMode(8, OUTPUT);
        pinMode(9, OUTPUT);
        pinMode(10, OUTPUT);
        pinMode(11, OUTPUT);
        pinMode(12, OUTPUT);
        pinMode(13, OUTPUT);
        pinMode(14, OUTPUT);
        pinMode(15, OUTPUT);
        pinMode(16, OUTPUT);
        pinMode(17, OUTPUT);
        pinMode(18, OUTPUT);
        pinMode(19, OUTPUT);
        pinMode(20, OUTPUT);
        pinMode(21, OUTPUT);
        pinMode(22, OUTPUT);
        pinMode(23, OUTPUT);
        pinMode(24, OUTPUT);
        pinMode(25, OUTPUT);
        pinMode(26, OUTPUT);
        pinMode(27, OUTPUT);
        pinMode(28, OUTPUT);
        pinMode(29, OUTPUT);
        pinMode(30, OUTPUT);
        pinMode(31, OUTPUT);
        pinMode(32, OUTPUT);
        pinMode(33, OUTPUT);
        pinMode(34, OUTPUT);
        pinMode(35, OUTPUT);
        pinMode(36, OUTPUT);
        pinMode(37, OUTPUT);
        pinMode(38, OUTPUT);
        pinMode(39, OUTPUT);
        pinMode(40, OUTPUT);   
       }
 

void loop()
{
for (int pin=0 ; pin<7 ; pin++){
digitalWrite(pin     , afficheur_seconde_1[s1][pin]);
digitalWrite((pin+7) , afficheur_seconde_2[s2][pin]);
digitalWrite((pin+14), afficheur_minute_1[m1][pin]);
digitalWrite((pin+21), afficheur_minute_2[m2][pin]);
digitalWrite((pin+28), afficheur_heure_1[h1][pin]);
digitalWrite((pin+35), afficheur_heure_2[h2][pin]);
}

s1++;
if(s1>9)
{s1 = 0 ;
s2++ ;}
if(s2>5)
{s2=0;
m1++;}
if(m1>9)
{m1 = 0 ;
m2++ ;}
if(m2>5)
{m2=0;
h1++;}
if(h1>9)
{h1 = 0 ;
h2++ ;}
if((h2=2)&&(h1>3))
{h2=0;
h1;}
delay(990);}

La prochaine étape est celle qui m'ai difficile , je sais pas comment utiliser digitalRead() avec les 10 entrée numérique et obtenir ainsi les valeur entrée par l'utilisateur sur l'heure , la minute et la seconde .
Je compte après ça faire 2 mode avec cette horloge , mode horloge simple et chronomètre .

Merci de m'aider et si il y'a une faute dans mon programme n'hésité pas a me le montrer.
10  Using Arduino / Programming Questions / Code of a camera ! on: March 13, 2013, 05:44:00 pm
I have a camera and i wana program it , but i don't understand very well the code so can you explain me this ?
Code:
/* Linksprite : the name of camera */

#include <NewSoftSerial.h>

byte incomingbyte;                  // what is this ?
NewSoftSerial mySerial(4,5);     //Configure pin 4 and 5 as soft serial port   , so for arduino leonardo i have to write "mySerial(0,1)" because tx>pin 0 and rx>pin 1
int a=0x0000,j=0,k=0,count=0;                    //Read Starting address     ,  what is this to ?
uint8_t MH,ML;                      // what is this ?
boolean EndFlag=0;                 // this is for test no ?
                               
void SendResetCmd();              // this is functions who is declared in <NewSoftSerial.h> ?
void SendTakePhotoCmd();        // what's their functions ?
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  Serial.begin(19200);                   // can i write "Serial.begin(9600);" ?
  mySerial.begin(38400);               
}

void loop()
{
     SendResetCmd();
     delay(4000);                               //After reset, wait 2-3 second to send take picture command
     
      SendTakePhotoCmd();

     while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();

      }   
      byte a[32];  // what does that mean ?
     
      while(!EndFlag)       // what does that mean ?
      { 
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(25);
          while(mySerial.available()>0)
          {
               incomingbyte=mySerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                           
               j++;
       count++;
               }
          }
         
          for(j=0;j<count;j++)
          {   if(a[j]<0x10)
              Serial.print("0");
              Serial.print(a[j],HEX);
              Serial.print(" ");
          }                                       //Send jpeg picture over the serial port
          Serial.println();
      }     
     while(1);
}

//Send Reset command
void SendResetCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x26, BYTE);
      mySerial.print(0x00, BYTE);
}

//Send take picture command
void SendTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x00, BYTE); 
}

//Read data
void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x32, BYTE);
      mySerial.print(0x0c, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x0a, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(MH, BYTE);
      mySerial.print(ML, BYTE);   
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x20, BYTE);
      mySerial.print(0x00, BYTE); 
      mySerial.print(0x0a, BYTE);
      a+=0x20;                            //address increases 32£¬set according to buffer size
}

void StopTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x03, BYTE);       
}

PS : i know that BYTE is not supported  so i hate to change for example mySerial.print(0x56, BYTE); to mySerial.write(0x56);
Please help me i have to finish this project quickly .
Thanks.
11  International / Français / Code d'une camera LinkSprite ! on: March 13, 2013, 07:22:47 am
Salut , je cherche a comprendre ce programme mais comme je suis un peu débutant en informatique (je connais la base en c , pascal et j'ai 20 en informatique smiley-grin ) donc j'ai besoin de votre aide !
Ce programme est déstiné pour une camera que je compte relier avec mon arduino , voici le code :
Code:
/* Linksprite */

#include <NewSoftSerial.h>

byte incomingbyte;
NewSoftSerial mySerial(4,5);                     //Configure pin 4 and 5 as soft serial port
int a=0x0000,j=0,k=0,count=0;                    //Read Starting address      
uint8_t MH,ML;
boolean EndFlag=0;
                              
void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  Serial.begin(19200);
  mySerial.begin(38400);
}

void loop()
{
     SendResetCmd();
     delay(4000);                               //After reset, wait 2-3 second to send take picture command
      
      SendTakePhotoCmd();

     while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();

      }  
      byte a[32];
      
      while(!EndFlag)
      {  
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(25);
          while(mySerial.available()>0)
          {
               incomingbyte=mySerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                          
               j++;
      count++;
               }
          }
        
          for(j=0;j<count;j++)
          {   if(a[j]<0x10)
              Serial.print("0");
              Serial.print(a[j],HEX);
              Serial.print(" ");
          }                                       //Send jpeg picture over the serial port
          Serial.println();
      }      
     while(1);
}

//Send Reset command
void SendResetCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x26, BYTE);
      mySerial.print(0x00, BYTE);
}

//Send take picture command
void SendTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x00, BYTE);  
}

//Read data
void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x32, BYTE);
      mySerial.print(0x0c, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x0a, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(MH, BYTE);
      mySerial.print(ML, BYTE);  
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x20, BYTE);
      mySerial.print(0x00, BYTE);  
      mySerial.print(0x0a, BYTE);
      a+=0x20;                            //address increases 32£¬set according to buffer size
}

void StopTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x03, BYTE);        
}
12  International / Français / Arduino Mega + Servo moteur on: February 18, 2013, 04:50:41 am
Bonjour , j'ai un problème assez bizarre , j'utilise arduino mega pour controler un servo moteur , j'ai utilisé l'exemple "SWEEP" présent dans l'application arduino , je branche le +5V ainsi que le GND et finalement quand je branche le fil jaune pour la commande dans le pin 9 , il tourne un peu et l'ordinateur fait un son comme si je vien de brancher l'arduino a l'ordinateur puis il tourne aléatoirement et tout ça se répète !

J'aimerai connaitre le problème s'il vous plait car c'est très urgent , j'ai une compétition samedi smiley
Pages: [1]