Skip to content

Commit 4ee97d8

Browse files
authored
Merge pull request #2 from gbr1/dev
0.2.0 - aligned to mpy 0.2.0
2 parents 406070d + 1386f14 commit 4ee97d8

File tree

7 files changed

+716
-69
lines changed

7 files changed

+716
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
This file is part of the Arduino_Alvik library.
3+
4+
Copyright (c) 2024 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
10+
*/
11+
12+
#include "Arduino_Alvik.h"
13+
14+
Arduino_Alvik alvik;
15+
16+
void setup() {
17+
Serial.begin(115200);
18+
while(!Serial);
19+
20+
alvik.begin();
21+
22+
Serial.println("Alvik initializated");
23+
Serial.println("Place your robot on white and send a char");
24+
while(Serial.available()==0);
25+
while(Serial.available()>0){
26+
Serial.read();
27+
}
28+
alvik.color_calibration(WHITE);
29+
Serial.println("Place your robot on black and send a char");
30+
while(Serial.available()==0);
31+
while(Serial.available()>0){
32+
Serial.read();
33+
}
34+
alvik.color_calibration(BLACK);
35+
36+
}
37+
38+
void loop() {
39+
int16_t color[3];
40+
float rgb[3];
41+
float hsv[3];
42+
alvik.get_color_raw(color[0], color[1], color[2]);
43+
alvik.get_color(rgb[0], rgb[1], rgb[2]);
44+
alvik.get_color(hsv[0], hsv[1], hsv[2], HSV);
45+
Serial.print(color[0]);
46+
Serial.print("\t");
47+
Serial.print(color[1]);
48+
Serial.print("\t");
49+
Serial.print(color[2]);
50+
Serial.print("\t");
51+
Serial.print(rgb[0]);
52+
Serial.print("\t");
53+
Serial.print(rgb[1]);
54+
Serial.print("\t");
55+
Serial.print(rgb[2]);
56+
Serial.print("\t");
57+
Serial.print(hsv[0]);
58+
Serial.print("\t");
59+
Serial.print(hsv[1]);
60+
Serial.print("\t");
61+
Serial.print(hsv[2]);
62+
Serial.print("\t");
63+
Serial.print(alvik.get_color_label(hsv[0], hsv[1], hsv[2]));
64+
Serial.print("\n");
65+
}
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
This file is part of the Arduino_Alvik library.
3+
4+
Copyright (c) 2024 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
10+
*/
11+
12+
#include "Arduino_Alvik.h"
13+
14+
Arduino_Alvik alvik;
15+
16+
17+
float reference = 10.0;
18+
float error = 0.0;
19+
float distances[5];
20+
21+
22+
23+
void setup(){
24+
while((!Serial) && (millis()<3000));
25+
alvik.begin();
26+
}
27+
28+
void loop(){
29+
alvik.get_distance(distances[0], distances[1], distances[2], distances[3], distances[4]);
30+
Serial.println(distances[2]);
31+
error = distances[2] - reference;
32+
alvik.set_wheels_speed(error * 10.0, error * 10.0);
33+
delay(100);
34+
}
35+

0 commit comments

Comments
 (0)