Connection bluetooth entre arduino mega adk et android

Bonjour à tous,

Dans le cadre d'un projet pour l'école, je dois envoyer des informations d'un arduino vers un téléphone android via bluetooth. Je dispose d'une carte arduino mega Adk et d'un module bluetooth ARF32 de chez Adeunis.

J'essaye tout d'abord d'envoyer un simple "1" à mon téléphone, est-ce la bonne procédure?

#include <SoftwareSerial.h>

int contacteurPin = 40;
int isSent;
SoftwareSerial mySerial(19, 18); 

void setup() {

  pinMode(contacteurPin, INPUT);    
  mySerial.begin(9600);               
  isSent = 0;
}

void loop() {

  if( contacteurPin == HIGH)        
  {
    if(isSent == 0)
    {
      byte msg[8]={02,52,00,01,00,53,01,03};  //8 byte 
      mySerial.write(msg,8);     
      isSent = 1;
    }
    if( contacteurPin == LOW)      
    {
      isSent = 0;
    }
  }
}

Si vous avez des conseils, des tutos bien faits, je suis preneur.

Merci d'avance

Bonjour
Deux choses:

  1. quand tu fais if( contacteurPin == HIGH)  tu teste si "40"==HIGH. Tu dois faireif( DigitalRead(contacteurPin) == HIGH) 

  2. modifi comme ceci avec le ELSE

void loop() {

  if(DigitalRead( contacteurPin) == HIGH)        
  {
    if(isSent == 0)
    {
      byte msg[8]={02,52,00,01,00,53,01,03};  //8 byte 
      mySerial.write(msg,8);     
      isSent = 1;
    }
  }
  else
  {
    isSent = 0;
  }
}

sinon tu n'entreras jamais dans

    if( DigitalRead(contacteurPin) == LOW)      
    {
      isSent = 0;
    }

puisque deja dans le test où c'est HIGH.
a+

Ok, merci pour ta réponse, je vais changer tout ça.