You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -379,11 +383,7 @@ Open **Arduino Lab for MicroPython** and **connect** Alvik. Then:
379
383
380
384
[mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) is a Python module needed to upload files on the Nano ESP32. The minimum suggested mpremote release is 1.22.0. Be sure to have Python installed before proceeding!
@@ -434,6 +430,8 @@ TODO: Content for this section
434
430
435
431
### Controlling the Motors
436
432
433
+
TODO - IMPROVE THIS TEXT: Movement is one of the Alvik's main feature, as such it is very important to have a lot of flexibility on how you control Alvik's motors as such there are different control methods on how to control them
434
+
437
435
#### High level, fix power x amount of time or distance
438
436
439
437
TODO: Content for this section
@@ -452,7 +450,104 @@ TODO: Content for this section
452
450
453
451
### Reading Buttons
454
452
455
-
TODO: Content for this section
453
+
The Arduino Alvik robot is equipped with several touch buttons that can be used for various input purposes. The following functions are available to read the state of each button:
454
+
455
+
1. Detect **any** button pressed.
456
+
457
+
The `get_touch_any` function returns true if any of the buttons is pressed.
458
+
459
+
**Outputs:**
460
+
-`touch_any`: true if any button is pressed, false otherwise.
461
+
462
+
2. Detect the **OK** button pressed.
463
+
464
+
The `get_touch_ok` function returns true if the OK button is pressed.
465
+
466
+
**Outputs:**
467
+
-`touch_ok`: true if OK button is pressed, false otherwise.
468
+
469
+
3. Detect the **Cancel** button pressed.
470
+
471
+
The `get_touch_cancel` function returns true if the Cancel button is pressed.
472
+
473
+
**Outputs:**
474
+
-`touch_cancel`: true if Cancel button is pressed, false otherwise.
475
+
476
+
4. Detect the **Center** button pressed.
477
+
478
+
The `get_touch_center` function returns true if the Center button is pressed.
479
+
480
+
**Outputs:**
481
+
-`touch_center`: true if Center button is pressed, false otherwise.
482
+
483
+
5. Detect the **Up** button pressed.
484
+
485
+
The `get_touch_up` function returns true if the Up button is pressed.
486
+
487
+
**Outputs:**
488
+
-`touch_up`: true if Up button is pressed, false otherwise.
489
+
490
+
6. Detect the **Left** button pressed.
491
+
492
+
The `get_touch_left` function returns true if the Left button is pressed.
493
+
494
+
**Outputs:**
495
+
-`touch_left`: true if Left button is pressed, false otherwise.
496
+
497
+
7. Detect the **Down** button pressed.
498
+
499
+
The `get_touch_down` function returns true if the Down button is pressed.
500
+
501
+
**Outputs:**
502
+
-`touch_down`: true if Down button is pressed, false otherwise.
503
+
504
+
8. Detect the **Right** button pressed.
505
+
506
+
The `get_touch_right` function returns true if the Right button is pressed.
507
+
508
+
**Outputs:**
509
+
-`touch_right`: true if Right button is pressed, false otherwise.
510
+
511
+
#### Example Usage
512
+
513
+
The following example demonstrates how to read the state of each button and print its name when pressed:
514
+
515
+
```python
516
+
from arduino_alvik import ArduinoAlvik
517
+
from time import sleep_ms
518
+
import sys
519
+
520
+
alvik = ArduinoAlvik()
521
+
alvik.begin()
522
+
523
+
whileTrue:
524
+
try:
525
+
if alvik.get_touch_any():
526
+
if alvik.get_touch_up():
527
+
print("UP")
528
+
if alvik.get_touch_down():
529
+
print("DOWN")
530
+
if alvik.get_touch_left():
531
+
print("LEFT")
532
+
if alvik.get_touch_right():
533
+
print("RIGHT")
534
+
if alvik.get_touch_ok():
535
+
print("OK")
536
+
if alvik.get_touch_cancel():
537
+
print("CANCEL")
538
+
if alvik.get_touch_center():
539
+
print("CENTER")
540
+
541
+
sleep_ms(100)
542
+
exceptKeyboardInterruptas e:
543
+
print('over')
544
+
alvik.stop()
545
+
sys.exit()
546
+
```
547
+
548
+
This example provides a simple way to read and respond to button presses on the Arduino Alvik robot.
549
+
Feel free to expand to it by adding customized responses to each different press.
550
+
456
551
457
552
### Detecting Obstacles
458
553
@@ -598,7 +693,6 @@ except KeyboardInterrupt as e:
598
693
599
694
In this example, the robot uses its line follower sensor array to navigate along a line. The `calcu2late_center` function determines the center of the line's position, and the robot adjusts its wheel speeds to stay on the line based on the calculated error from this center.
0 commit comments