Skip to content

Commit c0c16f9

Browse files
Update user-manual.md
1 parent 2d3bce8 commit c0c16f9

File tree

1 file changed

+107
-13
lines changed
  • content/hardware/08.edu/solution-and-kits/alvik/tutorials/user-manual

1 file changed

+107
-13
lines changed

content/hardware/08.edu/solution-and-kits/alvik/tutorials/user-manual/user-manual.md

Lines changed: 107 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ In this tutorial, you will find useful information to get started, test, and mai
6666
- [Controlling power and time in degrees/s cm/s](#controlling-power-and-time-in-degreess-cms)
6767
- [Encoder’s Control](#encoders-control)
6868
- [Reading Buttons](#reading-buttons)
69+
- [Example Usage](#example-usage-1)
6970
- [Detecting Obstacles](#detecting-obstacles)
7071
- [Function](#function)
71-
- [Example Usage](#example-usage-1)
72+
- [Example Usage](#example-usage-2)
7273
- [Following a Line](#following-a-line)
7374
- [Function](#function-1)
74-
- [Example Usage](#example-usage-2)
75+
- [Example Usage](#example-usage-3)
7576
- [Sensing Colors](#sensing-colors)
7677
- [Functions](#functions-1)
7778
- [Detecting Falling and Crashes (IMU)](#detecting-falling-and-crashes-imu)
@@ -297,6 +298,9 @@ Alvik has two high-precision geared motors and two RGB LEDs. The test programs a
297298
| Geared motors w/ encoder | GM12-N20VA-08255-150-EN | wheels_positions.py |
298299
| RGB LEDs | RGB LEDs | leds_settings.py |
299300

301+
TODO: Does this make sense to group together?
302+
303+
300304
## What the Robot Includes
301305

302306
TODO: Content for this section
@@ -379,11 +383,7 @@ Open **Arduino Lab for MicroPython** and **connect** Alvik. Then:
379383

380384
[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!
381385

382-
`(venv)$ pip install mpremote`
383-
384-
or
385-
386-
`(venv)$ python3 -m pip install mpremote`
386+
`(venv)$ pip install mpremote` or `(venv)$ python3 -m pip install mpremote`
387387

388388
Depending on how you configure Python on your machine.
389389

@@ -392,11 +392,9 @@ Depending on how you configure Python on your machine.
392392
Run the following line to upload all files and download the dependencies needed to run the Arduino Alvik MicroPython library.
393393

394394
Linux
395-
396395
`$ ./install.sh -p <device port>`
397396

398397
Windows
399-
400398
`install.bat -p <device port>`
401399

402400

@@ -415,12 +413,10 @@ The `<device port>` is the name of the USB port that your computer assigned to t
415413
2. Go into `utilities` folder and run the `flash_firmware` script:
416414

417415
Linux
418-
419416
`$ ./flash_firmware.sh -p <device port> <path-to-your-firmware>`
420417

421418

422419
Windows
423-
424420
`flash_firmware.bat -p <device port> <path-to-your-firmware>`
425421

426422

@@ -434,6 +430,8 @@ TODO: Content for this section
434430

435431
### Controlling the Motors
436432

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+
437435
#### High level, fix power x amount of time or distance
438436

439437
TODO: Content for this section
@@ -452,7 +450,104 @@ TODO: Content for this section
452450

453451
### Reading Buttons
454452

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+
while True:
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+
except KeyboardInterrupt as 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+
456551

457552
### Detecting Obstacles
458553

@@ -598,7 +693,6 @@ except KeyboardInterrupt as e:
598693

599694
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.
600695

601-
602696
TODO: Content for this section
603697

604698
### Sensing Colors

0 commit comments

Comments
 (0)