This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
chumbyhackerboard:i2c [2010/08/28 22:11] ladyada |
chumbyhackerboard:i2c [2010/09/02 20:29] binkl Change address 58 to 29 so that the wiki text matches the i2cfail.gif |
||
---|---|---|---|
Line 20: | Line 20: | ||
{{:chumbyhackerboard:mma7455addr.gif|}} | {{:chumbyhackerboard:mma7455addr.gif|}} | ||
- | **$1D** means hexadecimal 0x1D which is the same as decimal 29. Great! Lets read byte #0 from the accelerometer by typing in **./i2c r 58 0** | + | **$1D** means hexadecimal 0x1D which is the same as decimal 29. Great! Lets read byte #0 from the accelerometer by typing in **./i2c r 29 0** |
{{:chumbyhackerboard:i2cfail.gif|}} | {{:chumbyhackerboard:i2cfail.gif|}} | ||
Line 95: | Line 95: | ||
You can grab all of the code below | You can grab all of the code below | ||
+ | |||
+ | Stick the code in a new file called **mma7455.c** by copying and pasting as before. Then compile by running **gcc -o mma7455 mma7455.c** and run with **./mma7455**. Now shake it! | ||
+ | |||
+ | {{:chumbyhackerboard:shaken.gif|}} | ||
+ | |||
+ | There you go! Now you can talk to the accelerometer to get motion data, and this code is easily adaptable for any i2c chip you may want to use. Enjoy! | ||