Question: I am trying to code a 8 button swith to output to two different LEDs. The address of each is in the code below. int

I am trying to code a 8 button swith to output to two different LEDs. The address of each is in the code below.

int main(void)

{

const unsigned char sevSegTable[16] =

{

0x40, // 0

0x79, // 1

0x24, // 2

0x30, // 3

0x19, // 4

0x12, // 5

0x02, // 6

0x78, // 7

0x00, // 8

0x18, // 9

0x08, // A

0x03, // B

0x46, // C

0x21, // D

0x06, // E

0x0E // F

};

// Ex: address = I2C_8574 | I2C_0

// Ex: address = I2C_8574_A | I2C_3

unsigned char switchAddress = I2C_8574 | I2C_0;

unsigned char sevenSegLedAddress = I2C_8574 | I2C_3;

unsigned char sevenSegLedAddress2 = I2C_8574 | I2C_4;

unsigned char data;

InitI2C();

while (1)

{

data = InI2C(switchAddress);

data = sevSegTable[data & 0xF];

OutI2C(sevenSegLedAddress, data);

}

// this will never be hit (compiler will probably warn)

//return 0;

}

How would I modify the code in C to have the upper four switchs control sevenSegLedAddress = I2C_8574 | I2C_3; and the lower 4 switchs control unsigned char sevenSegLedAddress2 = I2C_8574 | I2C_4;? The code right now only has a 4 switch controlling one LED. The output of the LEDs is the hexadecimal form of the switchs if they were in binary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!