Skip to content

Instantly share code, notes, and snippets.

@hlog2e
Last active November 20, 2023 03:02
Show Gist options
  • Save hlog2e/944771c907fcc5333b7c4ed64495b18a to your computer and use it in GitHub Desktop.
Save hlog2e/944771c907fcc5333b7c4ed64495b18a to your computer and use it in GitHub Desktop.
hmc5883 + ble 모듈
#include <Wire.h>
#include <MechaQMC5883.h>
#include <SoftwareSerial.h>
int BT_RX = 2;
int BT_TX = 3;
SoftwareSerial HM10(BT_RX, BT_TX);
MechaQMC5883 qmc;
void setup() {
Wire.begin();
Serial.begin(9600);
qmc.init();
HM10.begin(9600);
//qmc.setMode(Mode_Continuous,ODR_200Hz,RNG_2G,OSR_256);
}
void loop() {
int x,y,z;
qmc.read(&x,&y,&z);
HM10.print(x);
HM10.print(',');
HM10.print(y);
HM10.print(',');
HM10.println(z);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment