Módulos
Robotics
Dos motores, un servo y tus sensores, a las órdenes de una app del Kode Dot.

Con el módulo Robotics, el Kode Dot pasa a ser el cerebro de un robot. Mueves dos motores y un servo y lees tus sensores, todo desde una app de KodeOS.
Qué puedes hacer
Además de los motores y el servo, sus conectores admiten un dispositivo I2C y hasta cuatro sensores. El conector stepper mueve también en medios pasos un motor paso a paso bipolar, como un NEMA 17.

Cómo se conecta
- Encaja el módulo en el conector superior, con el chip del mismo lado que la pantalla.
- Conecta los motores a los bornes
motor Aymotor By el servo al conectorservo, con su cable de masa en el pinGND. - Instala en el Kode Dot una app para el módulo, por ejemplo la del final de esta página.
Los motores y el servo toman los 5 V del Kode Dot, así que deja puesto un cargador USB-C de 5 V y 3 A, como pide el SDK de Robotics.

Especificaciones
stepper para cargas de 5 V, como una tira de LED o una bomba.Si controlas los pines sin el SDK, estos son sus GPIO.

AIN1 y AIN2 del controlador.BIN1 y BIN2 del controlador.nSLEEP en bajo, el controlador se duerme.nFAULT baja a pulsos cuando el controlador se dispara por sobrecorriente o sobretemperatura.servo.GPIO8 y SDA en GPIO9, con una línea libre en GPIO10.GPIO16, GPIO17 y GPIO18.El circuito completo está en el esquema de Robotics.
Errores comunes
robotics_fault_clear().GPIO19 en bajo, así que ponlo en alto antes del primer PWM.Apps que lo usan
MotorsDrive a stepper motor and a servo from your Kode Dot. Each one is a 3D model on the screen that turns just like the real one. - Servo: slide it along a ruler from 0 to 180°, then Hold it there or Release it - Stepper: six speeds each way, from 10 to 90 rpm, with Stop and Go - The angle or the rpm, live at the top - Switch motor at the bottom of the screen, with a finger or the pad - It keeps the speed and the angle for next time Needs the Robotics module with a stepper motor (bipolar, like a NEMA 17) and/or a hobby servo (like an SG90), and 5 V: a USB-C charger, or the battery's boost.
Stepper PianoA player piano that a stepper motor plays. Each note is a speed, so the motor sings as it spins, while the paper roll scrolls down and the keys press themselves. What you need - A Kode Dot - The Robotics module, plugged into J3 - A stepper motor (bipolar, 1.8°, like a NEMA 17) on the module's stepper terminal - 5 V for the motor: a USB-C charger, or the Dot's battery boost What it does - Plays Jingle Bells, Can-Can and Happy Birthday - Shows the motor's rpm and the song's time, live - Settings: tempo, octave, spin direction and repeat, kept for next time - The BLUE button plays and stopsCódigo de ejemplo
Conecta un servo pequeño, como un SG90, al conector servo, con su cable de masa en el pin GND. Deja puesto el cable USB. El ejemplo lo lleva a 0, 90, 180 y 90 grados, uno cada dos segundos, una y otra vez. En el registro verás cada ángulo, como servo to 90 degrees.
/* SPDX-License-Identifier: GPL-3.0-or-later */
/**
* @file robotics_servo.c
* @brief Turns a servo on the Robotics module to 0, 90, 180 and 90 degrees, over and over.
*
* A KodeOS app on Kode's Robotics SDK. The servo on the servo connector, J402,
* moves to the next angle every two seconds.
*
* from Kode with love
*/
#include "kode.h"
#include "robotics.h"
#define SERVO_STEP_COUNT 4U /**< Angles in one round. */
#define SERVO_STEP_MS 2000U /**< Time at each angle, the turn included. */
#define MODULE_WAIT_MS 5000U /**< How long each look for the module lasts. */
/** @brief The angles the servo turns to, in degrees, in order. */
static const uint8_t ANGLES[SERVO_STEP_COUNT] = { 0U, 90U, 180U, 90U };
KODE_APP_MANIFEST("Servo", "example");
/** @brief Wait for the module, then turn the servo from angle to angle. */
void app_main(void)
{
kode_init();
kode_print("Running: looking for the Robotics module");
if ( !robotics_begin() )
{
kode_print("the Robotics SDK did not start: %s", robotics_error());
return;
}
while ( !robotics_wait_present(MODULE_WAIT_MS) )
{
kode_print("no Robotics module yet");
}
while ( true )
{
for ( size_t i = 0U; SERVO_STEP_COUNT > i; ++i )
{
if ( robotics_servo_angle(ROBOTICS_SERVO_1, ANGLES[i]) )
{
kode_print("servo to %u degrees", (unsigned)ANGLES[i]);
}
else
{
kode_print("servo refused %u degrees: %s", (unsigned)ANGLES[i], robotics_error());
}
kode_delay(SERVO_STEP_MS);
}
}
}Si prefieres compilarlo tú, sigue los pasos comunes a todos los módulos.
El SDK trae otros ejemplos como motors o stepper y un watchdog, robotics_watchdog_set(), que lo para todo si la app deja de darle órdenes.
En el SDK
robotics.hes el SDK de Robotics para una app de KodeOS.robotics_begin()busca el módulo yrobotics_motor_drive()mueve un motor de −100 a 100 %.robotics_servo_angle(),robotics_stepper_*(),robotics_output_set()yrobotics_i2c_*()controlan el resto.