Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] how to get indivigual bit value from 8 bit port

Status
Not open for further replies.

raman00084

Full Member level 6
Joined
Nov 29, 2010
Messages
362
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,006
i am using i2c port expander ic pcf8574 it is an 8 bit ic. i will write all the pins to high now the data value = 255
if i make first bit low that is 11111101 the decimal value is 253 so data value = 253
if i make first bit and second bit low 11111100 so data value =252

i need help in converting my data value to individual bit value and it must be stored in 8 different variables
example data value = 252 binary value = 11111100
1- var1
1-var2
1-var3
1-var4
1-var5
1-var6
0-var7
0-var8
please help thank you
 

What compiler (language) are you using? MikroC?
 

you can shift and mask, e.g.
Code:
int value = 252 ;
int var1=(value>>7)&1;
int var2=(value>>6)&1;
int var3=(value>>5)&1;
etc
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top