I made a code that is able to make the z axis work but I need some help on
how to make it work for the x and y as well.Anyone familiar with python?
Please let me know how I can modify the code for the X and Y axis. Here's
the sample code:

import smbus
import time



def main():
  bus = smbus.SMBus(1)

        # Power-on the accelerometer, enabling only the z-axis
        bus.write_byte_data(0x18, 0x20, 0x24)

        try:
                while True:
      # get z-axis acceleration
                        tilt = bus.read_byte_data(0x18, 0x2D)

      # if it's supposed to be negative
                        if tilt > 127:
        # then convert it to the absolute value of the negative value
                                tilt = 256 + ~tilt
                                positive = False
                        else:
                                positive = True

      # format and print it
                        pos = tilt / 2
                        print str(tilt).rjust(6),
                        if positive:
                                print 65*' ' + '|' + (pos*'#').ljust(65)
                        else:
                                print (pos*'#').rjust(65) + '|' + 65*' '
                              # sleep
      time.sleep(0.1)
        except KeyboardInterrupt:
                # restore default settings
                bus.write_byte_data(0x18, 0x20, 0x07)

if __name__ == '__main__':
        main()



On Sat, Nov 16, 2013 at 1:46 AM, Zain Dar <[email protected]> wrote:

> Does anyone know how to make a code for measuring the digital
> accelerometers in i2c for the BBB? I've been looking for examples on making
> the X, Y, and Z axis work but I haven't had much luck and I'm running out
> of time since I need to check my progress on Mon. Any kind of hint will do
> fine, but it needs to involve measuring the waveforms for them too. Much
> appreciated.
>
>
> On Wed, Nov 13, 2013 at 5:21 AM, Mike Bremford <[email protected]> wrote:
>
>> I wouldn't receommend asking me anything to do with analog or python :-)
>> But the Linux I2C interface is easy, and Adafruit seems to be a good place
>> to start:
>> http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/overview
>>
>>
>> On 13 November 2013 02:47, Zain Dar <[email protected]> wrote:
>>
>>> Well, I have 4 analog accelerometers (Sparkfun MMA7361L) and 2 digital
>>> (Sparkfun ADXL345).
>>>
>>>
>>> On Tue, Nov 12, 2013 at 9:18 PM, Tom King <[email protected]> wrote:
>>>
>>>> some with python, only strain guages ....which accelerometers are you
>>>> thinking about?
>>>>
>>>>
>>>> On Tue, Nov 12, 2013 at 3:50 PM, Zain Dar <[email protected]> wrote:
>>>>
>>>>> Hi Tom! thanks for the interest in my project! Do you have any
>>>>> experience with python and accelerometers?
>>>>>
>>>>>
>>>>> On Tue, Nov 12, 2013 at 6:47 PM, Tom King <[email protected]> wrote:
>>>>>
>>>>>> I'm a candidate for your Knee Brace...so I am interested
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 4, 2013 at 8:52 PM, Zain Dar <[email protected]> wrote:
>>>>>>
>>>>>>> Hello, I'm working on a college project and my task is to develop a
>>>>>>> software code for a knee brace, that has 6 accelerometers planted on the
>>>>>>> frame (4 Analog Accelerometers and 2 Digital Accelerometers). The Analog
>>>>>>> accelerometers have 3 axis of dimensions, X, Y, & Z, whereas the Digital
>>>>>>> accelerometers have two interrupts (INT0 and INT1), an SDA, an SCL, a 
>>>>>>> 3.3V
>>>>>>> ref and a GND. I need to program the BBB to turn on the designated pins 
>>>>>>> on
>>>>>>> the expansion slots for the ref voltage (P8 & P9 respectively), and for 
>>>>>>> the
>>>>>>> reading of the accelerometers on the computer screen. After that I need 
>>>>>>> to
>>>>>>> store the data from the accelerometers to an SD card. The main issue for
>>>>>>> this is that I'm not very good at programming, especially for the BBB 
>>>>>>> since
>>>>>>> I haven't worked on it before, so is there any examples or tutorials on 
>>>>>>> how
>>>>>>> I can make the software code from scratch or by putting different kinds 
>>>>>>> of
>>>>>>> code together to make it work? Or is there any one who knows how to 
>>>>>>> turn on
>>>>>>> any pin on the BBB and read the accelerometers from the expansion 
>>>>>>> slots? I
>>>>>>> appreciate anyone who helps me out on this as it is a challenging step 
>>>>>>> for
>>>>>>> me in. Any advice is appreciated,
>>>>>>>
>>>>>>> Thank you!
>>>>>>>
>>>>>>> --
>>>>>>> For more options, visit http://beagleboard.org/discuss
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "BeagleBoard" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> For more options, visit http://beagleboard.org/discuss
>>>>>> ---
>>>>>> You received this message because you are subscribed to a topic in
>>>>>> the Google Groups "BeagleBoard" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe
>>>>>> .
>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>> [email protected].
>>>>>>
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>>  --
>>>>> For more options, visit http://beagleboard.org/discuss
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "BeagleBoard" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>
>>>>  --
>>>> For more options, visit http://beagleboard.org/discuss
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "BeagleBoard" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>  --
>>> For more options, visit http://beagleboard.org/discuss
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "BeagleBoard" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>> For more options, visit http://beagleboard.org/discuss
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "BeagleBoard" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to