PlatformIO helper library for programming a Studuino legacy board
Find a file
2026-05-02 15:00:41 +02:00
include Initial commit, v0.0.1 2026-05-01 11:20:37 +02:00
lib Initial commit, v0.0.1 2026-05-01 11:20:37 +02:00
src Fix readNEC return value 2026-05-02 12:29:17 +02:00
test Initial commit, v0.0.1 2026-05-01 11:20:37 +02:00
.gitignore Initial commit, v0.0.1 2026-05-01 11:20:37 +02:00
library.json Bump version to 0.0.3 2026-05-02 15:00:41 +02:00
platformio.ini Initial commit, v0.0.1 2026-05-01 11:20:37 +02:00
README.md Added a simple IR receiver driver 2026-05-02 12:17:16 +02:00

Studuino drivers for PIO (and Arduino IDE)

This project aims to simplify programming Studuino boards (specifically the "Mérd Magad" physics kit from Abacusan) in c++, just because i dont like Scratch.

The code currently has 2 parts: the DC motor drivers (studuino_motor.h) and sensor drivers (studuino_sensor.h)

Motor driver

The board uses a TB6552FNG as the motor driver IC.

The pin layout is the following:

Function MCU pin
A_{in_1} D2
A_{in_2} D4
A_{pwm} D3
B_{in_1} D7
B_{in_2} D8
B_{pwm} D5

When a motor channel is active, the corresponding pins can not be used. You have to keep this in mind when hooking up servos, or sensors.

Enums

Motor

  • STUDUINO_MOTOR1: M1 motor channel (value=1)
  • STUDUINO_MOTOR2: M2 motor channel (value=2)

Direction:

  • STUDUINO_DIRECTION_CW: Rotation direction - clockwise (value=0)
  • STUDUINO_DIRECTION_CCW: Rotation direction - counter clockwise (value=1)

Usage

Almost everyhing has been abstarcted regarding the motor controls.

  • initMotor(int motor):

    Initializes a motor channel. Because the pins are fixed can automatically be set up.

    motor: Channel ID of the motor (values in the Motor enum)

  • runMotor(int motor, int direction, uint8_t value):

    Starts a motor

    motor: Channel ID of the motor (values in the Motor enum)

    direction: Sets the rotation direction (values in the Direction enum)

    power: Sets the speed of the motor (values 0-255)

Example

#include <Arduino.h>
#include <studuino_motor.h>

void setup() {
    // Initialize M1 and run the motor clockwise at full power
    initMotor(STUDUINO_MOTOR1);
    runMotor(STUDUINO_MOTOR1, STUDUINO_DIRECTION_CW, 255);
}

void loop() {}

Sensor drivers

Some drivers for simple sensors. For saving flash space, the sensor modules have to be manually included.

Ultrasound Distance (HCSR04)

Standard simple driver for HCSR04

  • Include the driver for usage with #define ST_INCLUDE_ULTRASOUND

  • class HCSR04 (alias UltrasoundSensor):

    • HCSR04(uint8_t triggerPin, uint8_t echoPin)
    • int read(): Measures the distance (in millimeters)
    • void begin(): Sets up the pins specified in the constructor (optional if the pins are manually set up)