Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

mastronic

Member Since 14 May 2012
Offline Last Active Jun 15 2014 07:59 PM
-----

#30108 binary number representation in c#

Posted by mastronic on 02 June 2012 - 08:08 AM

Thank you.
Binary notation, is sometimes handy while writing a code to access a register where each bit to a property.


A simply solution:

        const byte b00000000 = 0x00;
        const byte b00000001 = 0x01;
        const byte b00000010 = 0x02;
        const byte b00000011 = 0x03;
        const byte b00000100 = 0x04;
....
Attachments file for all value;


Use For exemple to circuit test (use class b)..
            i2c_gyro.Write((byte) register.CTRL_REG1, b.b00001111);                    // Turn on XYZ axes
            //  Bit 7, 6:  Output Data Rate Selection      [100Hz, 200Hz, 400Hz, 800Hz]                                                                                       
            //  Bit 5, 4:  Bandwidht selection      [12.5 To 110  fonction ODR selection]                            
            //  Bit 3:  Power Down if 0
            //  Bit 2:  Z Axis Enable
            //  Bit 1:  Y Axis Enable
            //  Bit 0:  X Axis Enable

it' équivalent to:
i2c_gyro.Write((byte) register.CTRL_REG1, (byte) 0x0F);                    // Turn on XYZ axes


Thierry

Attached Files




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.