Skip to content

Commit a7cb70b

Browse files
committed
Collect IMU position and send to serial
1 parent 8342243 commit a7cb70b

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# Build SAMD
35+
*.bin
36+
*.elf
37+
*.hex
38+
*.map

src/BLE/BLE.ino

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
BLE experiments
3+
4+
This example:
5+
- reads the acceleration values from the LSM6DS3 sensor
6+
- sends the position data to the serial
7+
8+
The circuit:
9+
- Arduino Nano 33 IoT
10+
11+
created 7 Nov 2020
12+
by Olivier Staquet
13+
14+
This example code is in the public domain.
15+
*/
16+
17+
#include <Arduino_LSM6DS3.h>
18+
19+
void setup() {
20+
// Initialize internal LED (for visual debugging)
21+
pinMode(LED_BUILTIN, OUTPUT);
22+
digitalWrite(LED_BUILTIN, LOW);
23+
24+
// Initialize Serial connection
25+
Serial.begin(115200);
26+
// while(!Serial.available()) {
27+
// digitalWrite(LED_BUILTIN, HIGH);
28+
// delay(500);
29+
// digitalWrite(LED_BUILTIN, LOW);
30+
// delay(500);
31+
// }
32+
33+
// Initialize IMU
34+
if (!IMU.begin()) {
35+
// Failed to initialize IMU, blink the internal LED
36+
while (1) {
37+
digitalWrite(LED_BUILTIN, HIGH);
38+
delay(100);
39+
digitalWrite(LED_BUILTIN, LOW);
40+
delay(100);
41+
}
42+
}
43+
}
44+
45+
void loop() {
46+
float x, y, z;
47+
48+
// Read gyroscope values
49+
if (IMU.gyroscopeAvailable()) {
50+
IMU.readGyroscope(x, y, z);
51+
delay(900);
52+
digitalWrite(LED_BUILTIN, HIGH);
53+
delay(100);
54+
digitalWrite(LED_BUILTIN, LOW);
55+
}
56+
57+
// Show gyroscope values on serial
58+
Serial.print("Position ");
59+
Serial.print(x);
60+
Serial.print(",");
61+
Serial.print(y);
62+
Serial.print(",");
63+
Serial.println(z);
64+
}

src/BLE/sketch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"cpu": {
3+
"fqbn": "arduino:samd:nano_33_iot",
4+
"name": "Arduino NANO 33 IoT",
5+
"port": "serial:///dev/cu.usbmodem14201"
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"cpu": {
3+
"fqbn": "arduino:samd:nano_33_iot",
4+
"name": "Arduino NANO 33 IoT",
5+
"port": "serial:///dev/cu.usbmodem14201"
6+
}
7+
}

0 commit comments

Comments
 (0)