Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions