Free 173 Best Homemade Tools eBook:  
Get 500+ homemade tool plans, tool build guides, ebooks, and much more.

User Tag List

Results 1 to 4 of 4

Thread: Arduino Byte Juggling

  1. #1
    rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    832
    Thanks
    411
    Thanked 1,733 Times in 449 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    45 Best Harbor Freight Tool Modifications

    Rick

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

    Jon (06-01-2018), Seedtick (06-01-2018), volodar (06-17-2018), Workshopshed (06-02-2018)

  3. #2
    Supporting Member Workshopshed's Avatar
    Join Date
    Mar 2013
    Location
    North London, UK
    Posts
    204
    Thanks
    126
    Thanked 140 Times in 87 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Workshopshed's Tools
    500+ Homemade Tool Plans

    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.
    Forge Build Guide

    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 (06-17-2018)

  5. #3
    Content Editor
    Supporting Member
    DIYer's Avatar
    Join Date
    Aug 2013
    Posts
    3,090
    Thanks
    552
    Thanked 1,316 Times in 1,187 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    832
    Thanks
    411
    Thanked 1,733 Times in 449 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.


    Post your reply!
    Join 42,532 of us and get 500+ tool plans, tool eBooks, build guides, and much more.



    eBooks for Supporters
    Last edited by rgsparber; 06-02-2018 at 10:39 AM.
    Rick

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

    volodar (06-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
  •