Skip to content

Using the Accelerometer independently of MicroBit uBit; #470

@JamesBrooksEUREKA

Description

@JamesBrooksEUREKA

Hi All,
this is a problem I was having earlier in the year but put it to one side for a while. It still persists though and I would be really grateful if there is a solution as without this capability my microbit project isn't viable.

I am wanting to use the accelerometer independently of Micro uBit.

I have no problems using the display independently. Like this.

`#include "MicroBit.h"

MicroBitDisplay display;

int main()
{
while(1)
display.scroll(":)");
}`

However if I try and use the accelerometer in the same way, like this.

`#include "MicroBit.h"

MicroBitI2C i2c = MicroBitI2C(I2C_SDA0, I2C_SCL0);
MicroBitAccelerometer accelerometer = MicroBitAccelerometer(i2c);
MicroBitDisplay display;

int main()
{
while(1)
display.scroll(accelerometer.getX());
}`

I spent a good few days messing around with it to see if I was doing something wrong and eventually contacted Mark Williams. Who confirmed that it did indeed thrown an error, don't think he was too sure why and directed me here. This was in June of this year.

If anybody has a solution to this, and hopefully a working example. That doesn't use the full MicroBit uBit. I would be eternally grateful as it is a project for work.

Kind Regards

James

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions