ELECTRONICS - [I²C board] - [page 4/5]
I worked out a complete light computer as a demonstration application. 2 I2C boards are needed for this project: 1 board with 8 LEDs and 1 board with 8 switches.
The boards are connected to each other (SCL/SDA/GND). The board with the switches is defined as the slave, the board with the LEDs is the master.
The generated effects are shown on the LED board. The selected effect depends on the position of the switches on the switch board:
At any time only one effect can be activated: If you try to set multiple light effects the LED1 of the LED board will start flashing to indicate an error. The same indication will be given when none of the light effects has been activated.
The I2C address of the LED board must be set to '01110010' (0x72). This means switch 4 of the DIP switch must be set to ON.
The I2C address of the switch board must be set to '01110000' (0x70). All DIP switches must be set to OFF.
The image below shows how to connect the boards. The I/O switch board has to be connected to the 8051 with a flat cable. The LED board must be connected to the I/O switch board via the screw terminal connectors.
The software is written in Assembler. It runs an endless loop. During each loop the state of the switches is read. The state of the effect selecting switches is compared to the previous state. When a state change was detected a RESET is applied.
The effects are stored into 4 independent memory tables: the used table depends on the chosen light effect. A special bit pattern indicates the end of the table, forcing a jump to the beginning of the table.
Copyright ©1998-2022 Vanderhaegen Bart - last modified: August 24, 2013