6 years ago
Hello !
I want to interface a small gyroscope in I2C. I use a LSM303 (from polulu) with the library. I connect 3.3.V, SDA SCL and GND.
But, my program block to the "SD Init OK" screen and does nothing.
My code is very simple.
I made something wrong ?
Thanks :)
#include <Gamebuino-Meta.h> #include <LSM303.h> LSM303 compass; LSM303::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768}; void setup() { // put your setup code here, to run once: gb.begin(); compass.init(); compass.enableDefault(); } void loop() { // put your main code here, to run repeatedly: while(!gb.update()); gb.display.clear(); compass.read(); running_min.x = min(running_min.x, compass.m.x); running_min.y = min(running_min.y, compass.m.y); running_min.z = min(running_min.z, compass.m.z); running_max.x = max(running_max.x, compass.m.x); running_max.y = max(running_max.y, compass.m.y); running_max.z = max(running_max.z, compass.m.z); gb.display.println(running_min.x); gb.display.println(running_min.y); gb.display.println(running_min.z); gb.display.println(running_max.x); gb.display.println(running_max.y); gb.display.println(running_max.z); }
NEW 6 years ago
I dont know if sda and scl pins are already pulled up with a pullup resistor. (4.7k Ohm each) if not, this could be the reason.
With my Classics i used an i2c scanner sketch to prove the connections to the slaves.