Comments (2)
- Configure the sensor (as basis you can use e.g. the "Cartesian" example)
- In the loop: Readout the sensor
- Map magnetic field values to PWM output (convert magnetic field values to 0-255 integer values for pwm output)
- Write PWM to the pins
I've not tested it, but it should work somehow like this:
#include <Tle493d.h>
#define MAX_MAG_FIELD 50
#define PWM_X_PIN 1
#define PWM_Y_PIN 2
#define PWM_Z_PIN 3
Tle493d Tle493dMagnetic3DSensor = Tle493d();
void setup() {
Serial.begin(9600);
while (!Serial);
//If using the MS2Go-Kit: Enable following lines to switch on the sensor
// ***
pinMode(LED2, OUTPUT);
digitalWrite(LED2, HIGH);
delay(50);
// ***
Tle493dMagnetic3DSensor.begin();
Tle493dMagnetic3DSensor.enableTemp();
}
void loop() {
double x,y,z;
//Read magnetic values into variables
Tle493dMagnetic3DSensor.updateData();
x=abs(Tle493dMagnetic3DSensor.getX());
y=abs(Tle493dMagnetic3DSensor.getY());
z=abs(Tle493dMagnetic3DSensor.getZ());
//map magnetic field to pwm value
int pwm_x = map(x,0,MAX_MAG_FIELD,0,255);
int pwm_y = map(y,0,MAX_MAG_FIELD,0,255);
int pwm_z = map(z,0,MAX_MAG_FIELD,0,255);
//write pwm value to outputs
analogWrite(PWM_X_PIN, pwm_x);
analogWrite(PWM_Y_PIN, pwm_y);
analogWrite(PWM_Z_PIN, pwm_z);
delay(5);
}
from tle493d-3dmagnetic-sensor.
Thank You so much my friend.
from tle493d-3dmagnetic-sensor.
Related Issues (20)
- 4pcs. of TLE493D-W2B6 (A0 ...A3) + XMC2Go
- TLE493D-A2B6 cannot run properly in arduino DUE and Teensy boards. HOT 4
- Add License HOT 1
- error: expected identifier before numeric constant HOT 1
- TLE493d-a2b6 -> Arduino HOT 6
- Operating with multiple senors; Type TLE493D-W2B6 HOT 11
- Missing/Wrong Keyword HOT 1
- Bug: TLE93_p2b6_A1 not working HOT 1
- Improving sampling rate in Arduino IDE with multiple sensors HOT 14
- How to set short range mode? HOT 1
- Bus error HOT 11
- MS2Go doesnt return correct values HOT 1
- TLE493D code setting address to the default A0 after compiling HOT 1
- MS2GO keeps giving a wrong XYZ-values (-266.24) from serial monitor HOT 5
- -266.24 HOT 6
- I2C communication with sensor does not work HOT 3
- Mega 2560 with -266.24 HOT 6
- -266.24 just keeps appear in my serial monitor (TLE493D-W2B6A2) HOT 4
- Reset sequence with Arduino Wire library. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tle493d-3dmagnetic-sensor.