Pages: [1]   Go Down
Author Topic: [documentation] BUS I2C  (Read 2632 times)
0 Members and 1 Guest are viewing this topic.
Biganos
Offline Offline
Sr. Member
****
Karma: 2
Posts: 362
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour

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

bonne lecture.
chabot380
Logged

ORDINAUSORE 2Ghz AMD64 QUI S'ALLUME EN 48 SECONDES AVEC UBUNTU 12.04
ARDUINO UNO / Shield Ethernet / RTC DS1307
Programmation Python et j'apprends le C
Technicien Télé Vidéo à la retraite.

France
Offline Offline
Newbie
*
Karma: 0
Posts: 23
I love Geek, Arduino, Reprap, RaspberryPi, 3D Printers, ... Visit my blog about Arduino: http://www.zem.fr
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

merci pour le partage
Logged


Oise (FR)
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonsoir chabot380,

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


A+
Logged

Arduino 0023 et Python 3.2.3

France
Offline Offline
Faraday Member
**
Karma: 39
Posts: 3609
There is an Arduino for that
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Un petit programme qui scanne le bus à la recherche des éléments connectés.
Code:
// 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()
{

}
« Last Edit: January 28, 2013, 09:48:05 am by fdufnews » Logged

Offline Offline
God Member
*****
Karma: 12
Posts: 917
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Un petit programme qui scanne le bus à a recherche des éléments connectés.
Code:
// 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 smiley-wink
Logged

France
Offline Offline
Newbie
*
Karma: 0
Posts: 23
I love Geek, Arduino, Reprap, RaspberryPi, 3D Printers, ... Visit my blog about Arduino: http://www.zem.fr
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

merci pour le code
Logged


Pages: [1]   Go Up
Jump to: