- Wed Dec 10, 2014 5:40 am
#177555
Hello Everyone,
Im doing a new kind of project where i use a adafruit 3v trinket to read out a MMA8452 accelerometer. I've made the code and it works on a normal Arduino but not on the trinket because of the Wire library.
Do you guys have any idea how i could fix it?
I've tried this code but I've got many errors
Tom
Im doing a new kind of project where i use a adafruit 3v trinket to read out a MMA8452 accelerometer. I've made the code and it works on a normal Arduino but not on the trinket because of the Wire library.
Do you guys have any idea how i could fix it?
I've tried this code but I've got many errors
Code: Select all
Thanks #include <TinyWireM.h>
#include <SFE_MMA8452Q.h> // Includes the SFE_MMA8452Q library
#include <VirtualWire.h>
char *controller;
MMA8452Q accel;
void setup()
{
TinyWireM.begin();
accel.init(SCALE_8G, ODR_1);
vw_set_ptt_inverted(true);
vw_set_tx_pin(3);
vw_setup(5000);
}
// The loop function will simply check for new data from the
// accelerometer and print it out if it's available.
void loop()
{
// Use the accel.available() function to wait for new data
// from the accelerometer.
if (accel.available())
{
// First, use accel.read() to read the new variables:
accel.read();
sprintf(controller, "%d %d %d", accel.cx, accel.cy, accel.cz);
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx();
}
}
Tom