Hi, I'm working on two accelerometers, both of them are digital (ADXL345 by sparkfun) and I'm having trouble programming them to display the X, Y and Z axis. I'm trying the code in python first because its alot easier to work with and much faster to learn than C++ but I haven't had much luck in finding tutorials that make sense. Derek Molloys tutorial of the same topic is good but it comes with some problems that I'm unable to solve. He requires to install a number of other packages that are temporarily unavailable online for downloading into my BBB so I have to result to alternate ideas and code examples. Can someone please kindly direct me to a sample code that I can try out?Thanks
--
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 beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
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/YctTkwyFc8g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
import smbusimport timedef main():bus = smbus.SMBus(1)# Power-on the accelerometer, enabling only the z-axisbus.write_byte_data(0x18, 0x20, 0x24)try:while True:# get z-axis accelerationtilt = bus.read_byte_data(0x18, 0x2D)# if it's supposed to be negativeif tilt > 127:# then convert it to the absolute value of the negative valuetilt = 256 + ~tiltpositive = Falseelse:positive = True# format and print itpos = tilt / 2print str(tilt).rjust(6),if positive:print 65*' ' + '|' + (pos*'#').ljust(65)else:print (pos*'#').rjust(65) + '|' + 65*' '# sleeptime.sleep(0.1)except KeyboardInterrupt:# restore default settingsbus.write_byte_data(0x18, 0x20, 0x07)if __name__ == '__main__':main()I only need an idea for the X and Y axis. Thanks to anyone who can help.