Skip to content

README.md

Machine-translated by Robotheca from the original in Japanese (opens in a new tab). License: CC-BY-SA-4.0 (opens in a new tab).

Code

[!NOTE] Upload using the Arduino IDE. For the board manager, use arduino-pico (opens in a new tab).

examples

mind_2-1

〈Second generation〉 Basic program for Korobo

#include "KoroboLib_2_1.h"

KoroboLib_2_1 korobo;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  korobo.begin(TC); // TC: TC78H653, DRV: DRV8833, OLD: main-board ver. 3.1
}

void loop() {
  // put your main code here, to run repeatedly:
  if (korobo.Sleep(ALL)) {
    korobo.Eye(ALL);
    korobo.Voice(ALL);
    korobo.Move();
  }
}
  1. Loading the library
    The KoroboLib_2_1 korobo; part of korobo can be any word you choose. However, when calling functions such as korobo.begin() afterward, you need to change them to the word you specified.
    #include "KoroboLib_2_1.h"
    
    KoroboLib_2_1 korobo;
    
  2. Initial processing
    korobo.begin() is required.
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      korobo.begin(TC); // TC: TC78H653, DRV: DRV8833, OLD: main-board ver. 3.1
    }
    
  3. Loop processing
    void loop() {
      // put your main code here, to run repeatedly:
      if (korobo.Sleep(ALL)) {
        korobo.Eye(ALL);
        korobo.Voice(ALL);
        korobo.Move();
      }
    }
    

KoroboLib_2_1

Library required to operate the 〈Generation 2.1〉 Korobo

[!IMPORTANT] KoroboLib_2_1 depends on several existing libraries. Please install these libraries in advance1234. Also, each library is licensed under different licenses. If you intend to modify these libraries independently or incorporate them into the Korobo library, please review the licenses carefully.

  • void begin(unsigned int num) : Setup processing function for each module (see mind_2-1 / 2. Initial Processing).

    Compatibility is ensured by specifying the type of motor driver mounted and the version of the main board in the argument.

  • void Imu_getData() : Gets the values of the 9-axis sensor (acceleration, angular velocity, magnetism) at the time of the call.

    Even if executed multiple times within one loop iteration, the value obtained from the first execution is returned.

    void loop() {
      // put your main code here, to run repeatedly:
      float acc_x, acc_y, acc_z;
      korobo.Imu_getData();
      acc_x = korobo.korobo_acc.x();
      acc_y = korobo.korobo_acc.y();
      acc_z = korobo.korobo_acc.z();
    }
    
  • int AmbientLight_getData() : Gets the value of the upper light sensor (0 to 1023).

  • int Mic_getData() : Gets the value of the microphone sensor (0 to 1023).

  • void Eye(3-pattern)

    • void Eye(unsigned int num)
      

      Selects whether to display the pupils and the information the pupils express.

      void loop() {
        // put your main code here, to run repeatedly:
        korobo.Eye(SOUND);        // 音情報のみ利用する.(1つの場合)
        korobo.Eye(IMU * LIGHT);  // 加速度・角速度および光情報を利用する.(複数の場合)
        korobo.Eye(ALL);          // すべての情報を利用する.
      }
      
    • void Eye(int dX_point_u, int dY_point_u, int dX_size_u, int dY_size_u)
      

      Displays the pupils and allows arbitrary changes to the default values of the various pupil parameters.

    • void Eye(int dX_point_u, int dY_point_u, int dX_size_u, int dY_size_u, unsigned int num)
      

      Combination of the above two items.

Footnotes

  1. https://github.com/adafruit/Adafruit-GFX-Library (opens in a new tab) ↩

  2. https://github.com/adafruit/Adafruit_SSD1306 (opens in a new tab) ↩

  3. https://github.com/adafruit/Adafruit_Sensor (opens in a new tab) ↩

  4. https://github.com/adafruit/Adafruit_BNO055 (opens in a new tab) ↩

  • void Motor(2-pattern) : Arbitrary control values can be applied to the left and right motors.

    • void Motor(int motor_power_l, int motor_power_r)
      

      When connected to the microcontroller board via USB, the motors are stopped. When the control value is 50 or less, the gearbox output is too small and it stops inside the capsule. For this reason, control values from 0 to 50 are treated the same as 0.

    • void Motor(int motor_power_l, int motor_power_r, bool flug)
      

      Disables the motor stop when connected via USB in void Motor(int motor_power_l, int motor_power_r) (flug = false).

  • void Move() : The default behavior function. Using the acceleration on the x and y axes, the tires move to keep the body level.

    The plan is to allow this behavior and arbitrary user operation to run at the same time.

  • boolean Voice_state() : Checks whether Korobo is ready to speak.

  • void Voice_send(char Talk[20]) : Speaks an arbitrary string. For the string syntax, see the datasheet of AquesTalk pico LSI (opens in a new tab).

    Voice_state() is built in internally.

  • void Voice(unsigned int num) : The default speech function. You can select the information that the speech expresses.

    void loop() {
      // put your main code here, to run repeatedly:
      korobo.Voice(SOUND);        // 音情報のみ利用する.(1つの場合)
      korobo.Voice(IMU * LIGHT);  // 加速度・角速度および光情報を利用する.(複数の場合)
      korobo.Voice(ALL);          // すべての情報を利用する.
    }
    
  • (Under adjustment) boolean Sleep(unsigned int num) : Sleep function. You can select the information used as the condition for transitioning to sleep.

    void loop() {
      // put your main code here, to run repeatedly:
      // 例:Sleep(SOUND), Sleep(IMU * LIGHT)...
      if (korobo.Sleep(ALL)) {
        /* スリープ中に行わない処理... */
      }
      /* スリープ中にも行う処理... */
    }
    

Files by @KORokoro-rOBOt-project, at commit 16168ac, read from GitHub in your browser. Hardware license: CC-BY-SA-4.0; software license: CC-BY-SA-4.0. Robotheca doesn't review code: read it before running it.