Arduino Forum

International => Français => Tutoriels et cours => Topic started by: chabot380 on Dec 26, 2012, 08:13 am

Title: [documentation] BUS I2C
Post by: chabot380 on Dec 26, 2012, 08:13 am
Bonjour

De la doc sur le bus I2C ici : http://www.aurel32.net/elec/i2c.php

bonne lecture.
chabot380
Title: Re: [documentation] BUS I2C
Post by: jhdscript on Jan 04, 2013, 10:53 am
merci pour le partage
Title: Re: [documentation] BUS I2C
Post by: nolimit60 on Jan 12, 2013, 06:03 pm
Bonsoir chabot380,

J'ai trouvé dernièrement ce lien PDF:
http://artic.ac-besancon.fr/genie_electronique/telech/sonde/i2c.pdf


A+
Title: Re: [documentation] BUS I2C
Post by: fdufnews on Jan 12, 2013, 07:15 pm
Un petit programme qui scanne le bus à la recherche des éléments connectés.
Code: [Select]
// Wire Scanner
//
//
// Demonstrates the use of the Wire library
// Ping all valid adresses on the I²C bus
// and get the answer to see if there is a slave
// Print an 8 x 16 array with the results

// Created by fdufnews 2012 december 14th

// This example code is in the public domain.


#include <Wire.h>

void setup()
{
 Wire.begin();         // join i2c bus (address optional for master)
 Serial.begin(9600);   // start serial for output
 Serial.println();     // Print a banner
 Serial.println();
 Serial.println("I2C slave scanner");
 Serial.println("   reserved adress");
 Serial.println(".  no slave detected");
 Serial.println("X  slave detected");
 Serial.println();
 Serial.println();
 int result;
 Serial.println("   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F");
 // Scan only valid addresses (8 to 0x7B)
 // 0-7 and 7C-7F are reserved ones
 unsigned char devices=0;                  // holds how many devices found
 for (unsigned char ad=0; ad<0x7C;ad++){
   if(ad%16==0){                           // If at start of a row
     Serial.print(ad>>4,HEX);              // Display high order bit address
     Serial.print(" ");
   }
   if (ad>7){                              // skip address from 0 to 7
     Wire.beginTransmission(ad);           // start transmission
     result = Wire.endTransmission();      // end transmission and store answer
     if (!result) devices++;               // add a device to the count if ACK
     Serial.print(" ");
     Serial.print(result==0?"X ":". ");    // If ACK there is a guy at this address
   }
   else{
     Serial.print("   ");                  // Sorry nobody here
   }
   if(ad%16==15) Serial.println();         // end of the row add a new line
 }
 Serial.println();
 Serial.println();
 Serial.println();
 Serial.print(devices, DEC);
 Serial.print(" device");
 Serial.print(devices>1?"s":"");
 Serial.println(" found on the bus");
}

void loop()
{

}
Title: Re: [documentation] BUS I2C
Post by: john_lenfr on Jan 28, 2013, 02:24 pm

Un petit programme qui scanne le bus à a recherche des éléments connectés.
Code: [Select]
// Wire Scanner
//
//
// Demonstrates the use of the Wire library
// Ping all valid adresses on the I²C bus
// and get the answer to see if there is a slave
// Print an 8 x 16 array with the results

// Created by fdufnews 2012 december 14th

// This example code is in the public domain.


#include <Wire.h>

void setup()
{
  Wire.begin();         // join i2c bus (address optional for master)
  Serial.begin(9600);   // start serial for output
  Serial.println();     // Print a banner
  Serial.println();
  Serial.println("I2C slave scanner");
  Serial.println("   reserved adress");
  Serial.println(".  no slave detected");
  Serial.println("X  slave detected");
  Serial.println();
  Serial.println();
  int result;
  Serial.println("   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F");
  // Scan only valid addresses (8 to 0x7B)
  // 0-7 and 7C-7F are reserved ones
  unsigned char devices=0;                  // holds how many devices found
  for (unsigned char ad=0; ad<0x7C;ad++){
    if(ad%16==0){                           // If at start of a row
      Serial.print(ad>>4,HEX);              // Display high order bit address
      Serial.print(" ");
    }
    if (ad>7){                              // skip address from 0 to 7
      Wire.beginTransmission(ad);           // start transmission
      result = Wire.endTransmission();      // end transmission and store answer
      if (!result) devices++;               // add a device to the count if ACK
      Serial.print(" ");
      Serial.print(result==0?"X ":". ");    // If ACK there is a guy at this address
    }
    else{
      Serial.print("   ");                  // Sorry nobody here
    }
    if(ad%16==15) Serial.println();         // end of the row add a new line
  }
  Serial.println();
  Serial.println();
  Serial.println();
  Serial.print(devices, DEC);
  Serial.print(" device");
  Serial.print(devices>1?"s":"");
  Serial.println(" found on the bus");
}

void loop()
{

}



Nikel ce pti code, merci beaucoup ;)
Title: Re: [documentation] BUS I2C
Post by: jhdscript on Jan 31, 2013, 09:56 am
merci pour le code