Free 186 More Best Homemade Tools eBook:  
Get tool plans

User Tag List

Results 1 to 4 of 4

Thread: Arduino Byte Juggling

  1. #1
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    1,321
    Thanks
    775
    Thanked 2,838 Times in 670 Posts

    rgsparber's Tools

    Arduino Byte Juggling

    A very small population will have any interest in this topic. But if you are struggling with reads and writes of all data types to EEPROM, read on…

    http://rick.sparber.org/ABJ.pdf

    Your comments are welcome. All of us are smarter than any one of us.

    Thanks,
    Rick

    186 More Best Homemade Tools eBook
    Rick

  2. The Following 4 Users Say Thank You to rgsparber For This Useful Post:

    Jon (Jun 1, 2018), Seedtick (Jun 1, 2018), volodar (Jun 17, 2018), Workshopshed (Jun 2, 2018)

  3. #2
    Supporting Member Workshopshed's Avatar
    Join Date
    Mar 2013
    Location
    Suffolk, UK
    Posts
    210
    Thanks
    129
    Thanked 148 Times in 90 Posts

    Workshopshed's Tools
    Hi Rick, I had to do this kind of thing just the other day to send an integer over I2C.

    To multiply by 2 you can shift the number one to the left so to multiply by 256 which is 2^8 you can do.

    int b = a << 8;

    A technique I used back when I was coding for my ZxSpectrum in the 1980s as it did not actually have a multiply operator.

    2,000+ Tool Plans
    Andy from Workshopshed
    "Making and repairing things in a shed at the bottom of the garden"
    workshopshed.com

  4. The Following User Says Thank You to Workshopshed For This Useful Post:

    volodar (Jun 17, 2018)

  5. #3
    Content Editor
    Supporting Member
    DIYer's Avatar
    Join Date
    Aug 2013
    Posts
    3,055
    Thanks
    791
    Thanked 1,880 Times in 1,677 Posts
    Thanks Rick! We've added your Arduino Bit Shifting Method to our Miscellaneous category, as well as to your builder page: Rick's Homemade Tools. Your receipt:


  6. #4
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    1,321
    Thanks
    775
    Thanked 2,838 Times in 670 Posts

    rgsparber's Tools
    Yes, <<8 should do a multiply by 256. Be carful on shifting right:

    long x = 0xFFEEDDCC;

    x= (x>>8) & 0xFF;

    Should produce 0x000000DD. Without the mask it would be 0xFFFFEEDD. It all depends on what you want.



    2,000+ Tool Plans
    Last edited by rgsparber; Jun 2, 2018 at 11:39 AM.
    Rick

  7. The Following User Says Thank You to rgsparber For This Useful Post:

    volodar (Jun 17, 2018)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •