Functions Guide

Here we provide short descriptions of some of the more useful Rokit Smart functions included in the SmartInventor Arduino Library.  This page will be updated continuously as the Rokit Smart community develops.

Contents:

  1. Library
  2. Remote Control
  3. DC Motors
  4. Buzzer
  5. Sensors
  6. Advanced LEDs


Library

#include <SmartInventor.h>

  • The #include function tells Arduino that we plan to use the SmartInventor.h library.
  • This allows the use of all Smart Inventor class functions and variables.
  • Be sure to include this line at the top of your code, before void setup().

RemoteControl

SmartInventor.TVRemoconUse();

  • This function initializes the remote control receiver
  • This is a mandatory function that must be used in order to use the remote control 

SmartInventor.TVRecmoconClose();

  • This function disables the remote control functionality until a SmartInventor.TVRemoconUse() is called.

SmartInventor.TVRemoconData();

  • This function receives the information from the remote.
  • It returns a value to indicate the button that was pressed.
  • The button values are mapped to the constant labeled below:RemoteImg

  DC Motors

These commands will allow you to control the DC Motors in your Rokit Smart Kit.

SmartInventor.DCMotorUse();

  • This function gets everything ready for the DC motors to wor
  • It is required if you want to use the DC motors

SmartInventor.DCMotorClose();

  • This function disables the DC motor functionality until a SmartInventor.DCMotorUse(); is called.

SmartInventor.DCMotor(Motor, Direction, Speed);

  • This is the command to control a DC motor
  • Motor: the name of the motor, either M1, M2, M3, or M4
  • Note that M1 is paired with M3, and M2 is paired with M4, so if you control M1, then M3 will do the same thing
  • Direction: This is the direction that the motor will spin. The options are CW (Clockwise), CCW (Counter-Clockwise), STOP (stop and hold), LOOSE (free spin)
  • Speed: The speed to turn at, values can be from 0 (slowest) to 127 (fastest)

SmartInventor.DCMove(Direction, Speed);

  • This is the command to control two DC motors with one command.
  • To work correctly the left motor must be connected to M1 and the right motor must be in M2.
  • Direction: The direction to move the robot. The options are forward, backward, right, left, stop, and loose (free spin).
  • Speed: The speed to move at, values can be from 0 (slowest) to 127 (fastest)

  Buzzer

These commands will allow you to control the Buzzer located on the SmartInventor Board

SmartInventor.Buzz(Frequency, Tempo);

  • This function makes a beep of a specified frequency and time
  • Frequency: The pitch of the beep.
  • By default, the following are the series of tones predefined in the Arduino IDE: NOTE_B0, NOTE_C1, NOTE_CS1, NOTE_D1, NOTE_DS1, NOTE_E1, NOTE_F1, NOTE_FS1, NOTE_G1, NOTE_GS1, NOTE_A1, NOTE_AS1, NOTE_B1, NOTE_C2, NOTE_CS2, NOTE_D2, NOTE_DS2, NOTE_E2, NOTE_F2, NOTE_FS2, NOTE_G2, NOTE_GS2, NOTE_A2, NOTE_AS2, NOTE_B2, NOTE_C3, NOTE_CS3, NOTE_D3, NOTE_DS3, NOTE_E3, NOTE_F3, NOTE_FS3, NOTE_G3, NOTE_GS3, NOTE_A3, NOTE_AS3, NOTE_B3, NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4, NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5, NOTE_C6 , NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6, NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7, NOTE_C8, NOTE_CS8, NOTE_D8, NOTE_DS8
  • Tempo: The time to play the sound for, the smaller the value the longer the time it will play.

  Sensors

These commands will allow you to calibrate and adjust the sensitivity of the sensors within a specific range. 

SmartInventor.SensorCalibration(Pin);

  • This function reads the specified sensor and returns the smallest value it reads in 100 readings.
  • This can be used to determine what a normal reading for a sensor is.
  • Pin: The pin number of the sensor to be read.

  Advanced LEDs

SmartInventor.LedPerformanceNumber(Number);

  • This function displays the number onto the board LEDs. It uses the format of the program selection mode where it moves an LED from the left to the right. Whenever an LED reaches the end it stays there an another LED starts moving over.
  • Number: The number to be displayed, it can display any value between 0 and 36

SmartInventor.LedArray(Number);

  • This function displays the number onto the board LEDs. It uses binary format to display the values (left most LED is the ones, second LED is the twos, next is the fours, next is the eights and so on, doubling each time). For example if the first and third LEDs are lit, then the value is 5 (1 + 4).
  • Number: The number to be displayed, it can be any value from 0 to 255.