Switching power with the Arduino over a I2C connected PCF8574: Unterschied zwischen den Versionen

Aus DL8RDS Wiki
Wechseln zu: Navigation, Suche
(New page: lll)
 
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
lll
+
== Goal ==
 +
 
 +
This little project wants do demonstrate how it is possible to switch a great number of lines with one single Arduino controller. It uses the PCF8574P chip. It is actually a reimplementation of this project:
 +
 
 +
* http://circuitsforbeginners.blogspot.com/2009/11/project-rolling-dice-expanding-arduino.html
 +
 
 +
== References ==
 +
 
 +
* http://www.arduino.cc/en/Reference/Wire The WIRING "Wire" library
 +
* http://www.neufeld.newton.ks.us/electronics/?p=241 A project in which the workings of the I2C protocol are well described
 +
* www.nxp.com/documents/data_sheet/PCF8574.pdf The Datasheet for the PCF8574
 +
 
 +
== The Scheme ==
 +
 
 +
[[Image:pcf8574_i2c.jpg|400px]]
 +
 
 +
== The Code ==
 +
 
 +
#define CARD_ADR (0x4 << 3 | 0x0) // address 0100000
 +
 +
#include <Wire.h>
 +
 +
void setup()
 +
{
 +
  Wire.begin(); // join i2c bus (address optional for master)
 +
}
 +
 +
void loop()
 +
{
 +
  /* switch on P0 */
 +
  Wire.beginTransmission(CARD_ADR);
 +
  Wire.send(B00000001);
 +
  Wire.endTransmission();
 +
  delay(1000);
 +
 
 +
  /* switch off all pins */
 +
  Wire.beginTransmission(CARD_ADR);
 +
  Wire.send(B00000000);
 +
  Wire.endTransmission();
 +
  delay(1000); 
 +
 +
  /* switch on P1 */
 +
  Wire.beginTransmission(CARD_ADR);
 +
  Wire.send(B00000010);
 +
  Wire.endTransmission();
 +
  delay(1000);
 +
 
 +
  /* switch off all pins */
 +
  Wire.beginTransmission(CARD_ADR);
 +
  Wire.send(B00000000);
 +
  Wire.endTransmission();
 +
  delay(1000); 
 +
 
 +
}
 +
 
 +
 
 +
== The Movie ==
 +
 
 +
You can watch the movie which explains this subproject on my Youtube channel.

Aktuelle Version vom 16. Juli 2010, 22:46 Uhr

1 Goal

This little project wants do demonstrate how it is possible to switch a great number of lines with one single Arduino controller. It uses the PCF8574P chip. It is actually a reimplementation of this project:

2 References

3 The Scheme

Pcf8574 i2c.jpg

4 The Code

#define CARD_ADR (0x4 << 3 | 0x0) // address 0100000

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

void loop()
{
  /* switch on P0 */
  Wire.beginTransmission(CARD_ADR);
  Wire.send(B00000001);
  Wire.endTransmission();
  delay(1000);
 
  /* switch off all pins */
  Wire.beginTransmission(CARD_ADR);
  Wire.send(B00000000);
  Wire.endTransmission();
  delay(1000);   

  /* switch on P1 */
  Wire.beginTransmission(CARD_ADR);
  Wire.send(B00000010);
  Wire.endTransmission();
  delay(1000);
 
  /* switch off all pins */
  Wire.beginTransmission(CARD_ADR);
  Wire.send(B00000000);
  Wire.endTransmission();
  delay(1000);   
 
}


5 The Movie

You can watch the movie which explains this subproject on my Youtube channel.