-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the MiP_ESP8266_Library wiki!
We've got a lot of stuff to sort out. In time, all this documentation will be sorted into separate pages. Unfortunately, I'm still in the middle of moving function groups into their own pages.
- ChestLED: Take control of the RGB LED in the chest of the MiP.
- Clap: Send descriptive messages to the Arduino IDE about each clap event deteced by the MiP robot.
- ContinuousDrive: You want to control the motion of the MiP in real time? This is the example for you.
- DisconnectApp: Disconnect all apps, including this sketch and any app that may be connected to Bluetooth.
- DistanceDrive: Tell the MiP robot exactly how far to travel and forget about it.
- DriveForwardBackward: Tell the MiP robot how long to drive forward/backward and forget about it.
- EnableGameMode: Cycle through each of the game modes available.
- EnableMiPDetectionMode: Allow your MiP to be discovered by others.
- FallDown: Tired of standing around? Command MiP to fall flat on his face.
- Gesture: Use your hand to make gesture to your MiP robot. Send descriptive messages to the Arduio IDE about each gesture event detected.
- GestureRadarMode: Want to learn more about how to enable/disable IR based gesture and radar measurements? Check out this example.
-
GetUp: If your MiP robot falls down, learn how to have him try getting back up on his
feetwheels. - HeadLEDs: Take control of the 4 individual eye LEDs on the MiP robot's head.
- Odometer: How far has your MiP robot been traveling around your personal robot laboratory? This example shows you how to find out and reset its measurement.
- PlaySound: Learn how to get the MiP robot vocalizing under your control!
- Radar: Is there anything in front of your MiP robot? This example sends descriptive text to the Arduino IDE when it detects changes in the obstacles around it.
- RawSendReceive: You found a command in WowWee's Protocol Specification that isn't supported by this library? This example shows you how to experiment with these new commands.
- ReadWriteEeprom: Read and write your own data to MiP's EEPROM. This is useful for storing data across power cycles. See also ZeroEeprom.
- ReadIRDongleCode: Reads IR signals sent from another MiP. See also SendIRDongleCode.
- SendIRDongleCode: Sends IR signals to another MiP. See also ReadIRDongleCode.
- SRSdemo: The MiP robot made an appearance at the Seattle Robotics Society meeting on April 21st, 2018. This is what he was running!
- Shake: Is someone shaking your poor little MiP robot? This example shows you how to detect such rudeness and report it to the Arduino IDE.
- SoftwareHardwareVersion: This example shows you how to peek under the covers and see what hardware / software is running inside your MiP robot.
- Status: Detect changes in the MiP robot's battery level or pose and report them to the Arduino IDE.
- Stop: Danger! Danger! MiP Robot! Stop your MiP robot in its tracks before it gets itself into more trouble.
- TurnLeftRight: Tell the MiP robot exactly how many degrees to turn and forget about it.
- Volume: Your MiP robot is too loud? Turn down the volume with this example.
- Weight: Detect weight changes in what the MiP is carrying and report them to the Arduino IDE.
- ZeroEeprom: Write zeroes to each available byte in EEPROM. See also ReadWriteEeprom.
float readBatteryVoltage()
Read the MiP robot's current battery level.
None
The current battery voltage in Volts.
- The MiP robot status updates, which include the battery level, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}MiPPosition readPosition()
Read the MiP robot's current position.
None
One of the values from the following table:
| MiPPosition Value |
|---|
| MIP_POSITION_ON_BACK |
| MIP_POSITION_FACE_DOWN |
| MIP_POSITION_UPRIGHT |
| MIP_POSITION_PICKED_UP |
| MIP_POSITION_HAND_STAND |
| MIP_POSITION_FACE_DOWN_ON_TRAY |
| MIP_POSITION_ON_BACK_WITH_KICKSTAND |
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isOnBack()
Is the MiP robot currently lying on its back?
None
- true if the MiP robot is currently lying on its back.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isFaceDown()
Is the MiP robot currently lying on its front?
None
- true if the MiP robot is currently lying on its front.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isUpright()
Is the MiP robot currently standing upright and self-balancing?
None
- true if the MiP robot is currently standing up right and self-balancing.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isPickedUp()
Has the user picked the MiP robot up?
None
- true if the MiP robot has been picked up by the user.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isHandStanding()
Is the MiP robot currently in a hand stand pose?
None
- true if the MiP robot is currently in a hand stand pose.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isFaceDownOnTray()
Is the MiP robot currently face down on the tray?
None
- true if the MiP robot is currently face down on the tray.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}bool isOnBackWithKickstand()
Is the MiP robot currently laying back on its kickstand?
None
- true if the MiP robot is currently laying back on its kickstand.
- false otherwise.
- The MiP robot status updates, which include the position, may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
- These status updates are usually sent every 30 seconds or earlier if the MiP detects a change in position.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Status.ino - Display MiP status as it changes."));
}
void loop() {
static float lastBatteryLevel = 0.0f;
static MiPPosition lastPosition = (MiPPosition) - 1;
float currentBatteryLevel = mip.readBatteryVoltage();
MiPPosition currentPosition = mip.readPosition();
if (currentBatteryLevel != lastBatteryLevel) {
Serial.print(F("Battery: "));
Serial.print(currentBatteryLevel);
Serial.println(F("V"));
lastBatteryLevel = currentBatteryLevel;
}
if (currentPosition != lastPosition) {
if (mip.isOnBack()) {
Serial.println(F("Position: On Back"));
}
if (mip.isFaceDown()) {
Serial.println(F("Position: Face Down"));
}
if (mip.isUpright()) {
Serial.println(F("Position: Upright"));
}
if (mip.isPickedUp()) {
Serial.println(F("Position: Picked Up"));
}
if (mip.isHandStanding()) {
Serial.println(F("Position: Hand Stand"));
}
if (mip.isFaceDownOnTray()) {
Serial.println(F("Position: Face Down on Tray"));
}
if (mip.isOnBackWithKickstand()) {
Serial.println(F("Position: On Back With Kickstand"));
}
lastPosition = currentPosition;
}
}int8_t readWeight()
Read the MiP robot's current estimate of how much weight it is carrying.
None
A signed integer representing how much it is tilted to keep its center of mass directly over the wheels. A positive value if it is front heavy and a negative value if it is back heavy.
- The MiP robot weight updates may be lost if you are spending too much time sending output back to the Arduino IDE's serial monitor. See Limitations section above.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Weight.ino - Use weight update functions."));
}
void loop() {
static int8_t lastWeight = -128;
int8_t currentWeight = mip.readWeight();
if (currentWeight != lastWeight) {
Serial.print(F("Weight = "));
Serial.println(currentWeight);
lastWeight = currentWeight;
}
}void enableClapEvents()
Enable the MiP robot to detect user claps. Once this is enabled, your code can call availableClapEvents() and readClapEvent to determine when clap events have been detected by the MiP.
None
Nothing
- The MiP robot defaults to having the clap detection feature disabled after the ProMini Pack attaches.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}void disableClapEvents()
Disables the MiP robot's ability to detect user claps.
None
Nothing
- The MiP robot defaults to having the clap detection feature disabled after the ProMini Pack attaches.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}bool areClapEventsEnabled()
Returns whether the MiP robot's clap detection feature is currently enabled.
None
- true if the MiP robot was successfully placed in clap detection mode with a previous call to enableClapEvents().
- false if it is not in clap detection mode.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}void writeClapDelay(uint16_t delay)
Sets the expected delay between user claps.
- delay is the new delay to be used for clap detection.
Nothing
- I don't know what the units are for this setting. Maybe milliseconds?
- The MiP defaults to having the clap delay set to 500 after the application first connects.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}uint16_t readClapDelay()
Read the MiP robot's current clap delay.
None
The current setting of the delay expected between claps. It defaults to 500.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}uint8_t availableClapEvents()
Returns the number of clap detection events that the library currently has sitting in its queue, ready to be read by calling readClapEvent(). The MiP robot must have already been placed in clap detection mode via a call to enableClapEvents() for new clap detection events to be added to this queue.
None
- 0 if there are currently no clap detection events ready for reading. Calling readClapEvent() now would retun 0.
- Non-zero value indicates the number of readClapEvent() calls that can be made and successfully return a valid clap detection event.
- The maximum number of clap detection events that can be queued up between calls to readClapEvent() is 8. If this count is exceeded, the oldest events will be overwritten.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}uint8_t readClapEvent()
Returns a clap detection event from the library's queue. They will be returned in the order that the MiP robot detected them. The MiP robot must have already been placed in clap detection mode via a call to enableClapEvents() for new clap detection events to be added to this queue.
None
- 0 if the clap detection event queue is empty. availableClapEvents() would return 0 in this scenario.
- The number of claps detected in this event (ie. 2 for a double clap).
- The maximum number of clap detection events that can be queued up between calls to readClapEvent() is 8. If this count is exceeded, the oldest events will be overwritten.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Clap.ino - Use clap related functions."));
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}
Serial.println();
Serial.println(F("Waiting for clap events!"));
}
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}bool hasBeenShaken()
Returns whether the MiP robot has been shaken since the previous call.
None
- true if the MiP robot has been shaken by the user since the previous call.
- false otherwise.
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Shake.ino - Detect shakes."));
}
void loop() {
if (mip.hasBeenShaken()) {
Serial.println(F("Shake detected!"));
}
}void readSoftwareVersion(MiPSoftwareVersion& software)
Get the version information for the software in the MiP robot.
- software is a MiPSoftwareVersion object to be filled in with the version information of the MiP robot software.
class MiPSoftwareVersion
{
public:
// ...
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t uniqueVersion;
};
Nothing
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("SoftwareHardwareVersion.ino - Use readSoftwareVersion() & readHardwareInfo() functions."));
MiPSoftwareVersion softwareVersion;
mip.readSoftwareVersion(softwareVersion);
Serial.print(F("software version: "));
Serial.print(softwareVersion.year);
Serial.print('-');
Serial.print(softwareVersion.month);
Serial.print('-');
Serial.print(softwareVersion.day);
Serial.print('.');
Serial.println(softwareVersion.uniqueVersion);
MiPHardwareInfo hardwareInfo;
mip.readHardwareInfo(hardwareInfo);
Serial.println(F("hardware info"));
Serial.print(F(" voice chip version: "));
Serial.println(hardwareInfo.voiceChip);
Serial.print(F(" hardware version: "));
Serial.println(hardwareInfo.hardware);
Serial.println();
Serial.println(F("Sample done."));
}
void loop() {
}void readHardwareInfo(MiPHardwareInfo& hardware)
Get the version information for the hardware in the MiP robot.
- hardware is a MiPHardwareInfo object to be filled in with the version information of the MiP robot's hardware.
class MiPHardwareInfo
{
public:
// ...
uint8_t voiceChip;
uint8_t hardware;
};Nothing
#include <mip.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("SoftwareHardwareVersion.ino - Use readSoftwareVersion() & readHardwareInfo() functions."));
MiPSoftwareVersion softwareVersion;
mip.readSoftwareVersion(softwareVersion);
Serial.print(F("software version: "));
Serial.print(softwareVersion.year);
Serial.print('-');
Serial.print(softwareVersion.month);
Serial.print('-');
Serial.print(softwareVersion.day);
Serial.print('.');
Serial.println(softwareVersion.uniqueVersion);
MiPHardwareInfo hardwareInfo;
mip.readHardwareInfo(hardwareInfo);
Serial.println(F("hardware info"));
Serial.print(F(" voice chip version: "));
Serial.println(hardwareInfo.voiceChip);
Serial.print(F(" hardware version: "));
Serial.println(hardwareInfo.hardware);
Serial.println();
Serial.println(F("Sample done."));
}
void loop() {
}void enableAppMode()
Place MiP in app mode. The chest LED will turn green. App mode allows the MiP to interface with applications running on either the UART port or via Bluetooth.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void enableCageMode()
Place MiP in cage mode. The chest LED will turn white and the MiP will try to escape from you. Place your hand in front of MiP's eyes to block its path. MiP moves faster as the game progesses and makes victory sounds if it escapes from you. To restart the game, clap twice.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void enableDanceMode()
Place MiP in dance mode. The chest LED will turn turquoise and MiP will dance around and play music.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void enableStackMode()
Place MiP in stack mode. The chest LED will turn pink and MiP will play the stack game with you. You will have only a few seconds to stack a heavy object or many light objects on top of the tray. If it can balance correctly, MiP will add additional time for you to stack. If you fail to reset the timer and the clock runs out, MiP spins around, tossing all the stacked items off the tray.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void enableTrickMode()
Place MiP in trick mode. The chest LED will flash red. While the chest LED is flashing MiP will record your hand gestures. MiP will signal each successful gesture by saying "OK" and lighting up its eyes. You can record up to 50 gestures. When complete, clap twice and MiP will replay the movements given by your gestures.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void enableRoamMode()
Place MiP in roam mode. The chest LED will turn yellow and roam freely, avoiding obstacles detected by the IR sensors.
None
Nothing
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isAppModeEnabled()
Returns whether the MiP is in app mode.
None
- true if the MiP robot was successfully placed in app mode with a previous call to enableAppMode().
- false if it is not in app mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isCageModeEnabled()
Returns whether the MiP is in cage mode.
None
- true if the MiP robot was successfully placed in cage mode with a previous call to enableCageMode().
- false if it is not in cage mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isDanceModeEnabled()
Returns whether the MiP is in dance mode.
None
- true if the MiP robot was successfully placed in dance mode with a previous call to enableDanceMode().
- false if it is not in dance mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isStackModeEnabled()
Returns whether the MiP is in stack mode.
None
- true if the MiP robot was successfully placed in stack mode with a previous call to enableStackMode().
- false if it is not in stack mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isTrickModeEnabled()
Returns whether the MiP is in trick mode.
None
- true if the MiP robot was successfully placed in trick mode with a previous call to enableTrickMode().
- false if it is not in trick mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}bool isRoamModeEnabled()
Returns whether the MiP is in roam mode.
None
- true if the MiP robot was successfully placed in roam mode with a previous call to enableRoamMode().
- false if it is not in roam mode.
#include <mip.h>
MiP mip;
// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));
delay(500);
}
void loop() {
mip.enableCageMode();
if (mip.isCageModeEnabled()) {
Serial.println(F("Cage mode enabled."));
}
delay(delayPeriod);
mip.enableDanceMode();
if (mip.isDanceModeEnabled()) {
Serial.println(F("Dance mode enabled."));
}
delay(delayPeriod);
mip.enableStackMode();
if (mip.isStackModeEnabled()) {
Serial.println(F("Stack mode enabled."));
}
delay(delayPeriod);
mip.enableTrickMode();
if (mip.isTrickModeEnabled()) {
Serial.println(F("Trick mode enabled."));
}
delay(delayPeriod);
mip.enableRoamMode();
if (mip.isRoamModeEnabled()) {
Serial.println(F("Roam mode enabled."));
}
delay(delayPeriod);
mip.enableAppMode();
if (mip.isAppModeEnabled()) {
Serial.println(F("App mode enabled."));
}
delay(delayPeriod);
}void setUserData(uint8_t addressOffset, uint8_t userData)
Stores one byte of user data to the offset specified. Valid offsets are 0x00-0x0F.
- addressOffset is the address offset at which to write the user's data.
- userData is the one byte of data to be written to EEPROM.
Nothing
#include <mip.h>
MiP mip;
// Use an offset between 0x00 and 0x0F.
const uint8_t eepromAddressOffset = 0x00;
// Try different hex values here to see them stored and
// recovered from EEPROM.
uint8_t secretPassword = 0x0D;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("ReadWriteEeprom.ino - Writes data to EEPROM and reads it back."));
Serial.print(F("Original password: "));
Serial.println(secretPassword, HEX);
// Power-off the MiP, comment out this line, recompile and load to the ProMini-Pack to see EEPROM
// data preserved across power cycles.
mip.setUserData(eepromAddressOffset, secretPassword);
// "Scramble" the secret password.
secretPassword = 0xFF;
Serial.print(F("Scrambled password: "));
Serial.println(secretPassword, HEX);
Serial.print(F("Recovered password: "));
Serial.print(mip.getUserData(eepromAddressOffset), HEX);
}
void loop() {
}uint8_t getUserData(uint8_t addressOffset)
Reads one byte of user data from the address offset specified. Valid addresses are 0x00-0x0F.
- addressOffset is the address at which to read stored data.
- The contents of the EEPROM read from the given address offset.
#include <mip.h>
MiP mip;
// Use an offset between 0x00 and 0x0F.
const uint8_t eepromAddressOffset = 0x00;
// Try different hex values here to see them stored and
// recovered from EEPROM.
uint8_t secretPassword = 0x0D;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("ReadWriteEeprom.ino - Writes data to EEPROM and reads it back."));
Serial.print(F("Original password: "));
Serial.println(secretPassword, HEX);
// Power-off the MiP, comment out this line, recompile and load to the ProMini-Pack to see EEPROM
// data preserved across power cycles.
mip.setUserData(eepromAddressOffset, secretPassword);
// "Scramble" the secret password.
secretPassword = 0xFF;
Serial.print(F("Scrambled password: "));
Serial.println(secretPassword, HEX);
Serial.print(F("Recovered password: "));
Serial.print(mip.getUserData(eepromAddressOffset), HEX);
}
void loop() {
}void enableMiPDetectionMode(uint8_t id, uint8_t txPower);
Allows MiP to be discovered by another MiP using IR. MiP broadcasts a user-defined identification number for another MiP to read.
-
id is the user-defined identification number to send to another MiP.
-
txPower is the IR transmission power. Valid values are 1 to 120 for about 1-300cm.
Nothing
#include <mip.h>
MiP mip;
// Load this sketch on a pair of MiPs facing each other and use a different MIP_ID_NO for each.
#define MIP_ID_NO 0x10
#define MIP_IR_TX_POWER 0x78
void setup() {
bool connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableMiPDetectionMode.ino - Enable your MiP to be discovered by another using IR."));
if (!mip.isMiPDetectionModeEnabled())
Serial.println(F("I am not discoverable."));
mip.enableMiPDetectionMode(MIP_ID_NO, MIP_IR_TX_POWER);
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
}
void loop() {
delay(3000);
uint8_t detectedMiP = 0x00;
// Spend about 10 seconds broadcasting MiP's ID while looking for another MiP.
for (int i = 0; i < 3; i++) {
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
delay(3333);
}
// MiP doesn't want to be found anymore.
mip.disableMiPDetectionMode();
// Verify it and keep looking for other MiPs.
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
else
Serial.println(F("I am not discoverable."));
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
}void disableMiPDetectionMode();
Prevents MiP from being discovered by another MiP using IR.
None
Nothing
#include <mip.h>
MiP mip;
// Load this sketch on a pair of MiPs facing each other and use a different MIP_ID_NO for each.
#define MIP_ID_NO 0x10
#define MIP_IR_TX_POWER 0x78
void setup() {
bool connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableMiPDetectionMode.ino - Enable your MiP to be discovered by another using IR."));
if (!mip.isMiPDetectionModeEnabled())
Serial.println(F("I am not discoverable."));
mip.enableMiPDetectionMode(MIP_ID_NO, MIP_IR_TX_POWER);
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
}
void loop() {
delay(3000);
uint8_t detectedMiP = 0x00;
// Spend about 10 seconds broadcasting MiP's ID while looking for another MiP.
for (int i = 0; i < 3; i++) {
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
delay(3333);
}
// MiP doesn't want to be found anymore.
mip.disableMiPDetectionMode();
// Verify it and keep looking for other MiPs.
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
else
Serial.println(F("I am not discoverable."));
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
}bool isMiPDetectionModeEnabled()
Checks whether MiP is broadcasting an identification number using IR.
None
- true if MiP is broadcasting its identification number.
#include <mip.h>
MiP mip;
// Load this sketch on a pair of MiPs facing each other and use a different MIP_ID_NO for each.
#define MIP_ID_NO 0x10
#define MIP_IR_TX_POWER 0x78
void setup() {
bool connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableMiPDetectionMode.ino - Enable your MiP to be discovered by another using IR."));
if (!mip.isMiPDetectionModeEnabled())
Serial.println(F("I am not discoverable."));
mip.enableMiPDetectionMode(MIP_ID_NO, MIP_IR_TX_POWER);
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
}
void loop() {
delay(3000);
uint8_t detectedMiP = 0x00;
// Spend about 10 seconds broadcasting MiP's ID while looking for another MiP.
for (int i = 0; i < 3; i++) {
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
delay(3333);
}
// MiP doesn't want to be found anymore.
mip.disableMiPDetectionMode();
// Verify it and keep looking for other MiPs.
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
else
Serial.println(F("I am not discoverable."));
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
}int8_t readDetectedMiP(uint8_t& detectedMiP)
Reads the identification number of a detected MiP.
- detectedMiP contains the identification number of a detected MiP after calling the function.
- 0 if no MiP was detected.
- 1 if a MiP was detected.
#include <mip.h>
MiP mip;
// Load this sketch on a pair of MiPs facing each other and use a different MIP_ID_NO for each.
#define MIP_ID_NO 0x10
#define MIP_IR_TX_POWER 0x78
void setup() {
bool connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("EnableMiPDetectionMode.ino - Enable your MiP to be discovered by another using IR."));
if (!mip.isMiPDetectionModeEnabled())
Serial.println(F("I am not discoverable."));
mip.enableMiPDetectionMode(MIP_ID_NO, MIP_IR_TX_POWER);
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
}
void loop() {
delay(3000);
uint8_t detectedMiP = 0x00;
// Spend about 10 seconds broadcasting MiP's ID while looking for another MiP.
for (int i = 0; i < 3; i++) {
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
delay(3333);
}
// MiP doesn't want to be found anymore.
mip.disableMiPDetectionMode();
// Verify it and keep looking for other MiPs.
if (mip.isMiPDetectionModeEnabled())
Serial.println(F("Now I can be discovered."));
else
Serial.println(F("I am not discoverable."));
if (mip.readDetectedMiP(detectedMiP)) {
Serial.print(F("I detected MiP with ID number ")); Serial.println(detectedMiP, HEX);
}
}void sendIRDongleCode(uint8_t sendCode[], uint8_t dataNumbers, uint8_t transmitPower)
Sends code to another MiP using IR. The code to send may be of two, three or four bytes in length.
For two-byte codes any value may be sent, i.e. { 0xNN, 0xNN }.
For three-byte codes the following formats are valid: { 0x00-0x03, 0xNN, 0xNN } or { 0xNN, 0xNN, 0xFF }.
For four-byte codes the following formats are valid: { 0xNN, 0xNN, 0xFF, 0xFF } or { 0x00-0x03, 0x00-0x03, !0xFF, !0xFF }.
- sendCode is a four-byte array containing code to send to another MiP. sendCode[3] is the most significant byte. In sends of two significant bytes, sendCode[2] and sendCode[3] are sent. In sends of three significant bytes, sendCode[1], sendCode[2] and sendCode[3] are sent.
- dataNumbers is the number of bytes to send. Allowable values are 2, 3 or 4.
- txPower is the IR transmission power. Valid values are 1 to 120 for about 1-300cm.
Nothing
#include <mip.h>
// Try different values for VALID_DATA_BYTES (2, 3 or 4)
#define VALID_DATA_BYTES 4
// Try different values for transmission power (0x01 - 0x78)
#define MIP_IR_TX_POWER 0x78
#define MAX_DATA_BYTES 4
MiP mip;
bool connectResult;
// Try different codes for dongleCode[].
const uint8_t dongleCode[4] = { 0xBB, 0x0AB, 0xFF, 0xFF };
void setup() {
connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("SendIRDongleCode.ino - Send code to another MiP using IR."));
}
void loop() {
Serial.print(F("Sending "));
for (int i = MAX_DATA_BYTES - VALID_DATA_BYTES; i < MAX_DATA_BYTES; i++) {
Serial.print(dongleCode[i], HEX); Serial.print(F(" "));
}
Serial.println();
mip.sendIRDongleCode(dongleCode, VALID_DATA_BYTES, MIP_IR_TX_POWER);
delay(1000);
}int8_t readIRDongleCode(MiPIRCode& codeEvent)
Reads code sent by another MiP using IR.
- codeEvent is the MiPIRCode object containing the received code after a call to the function.
- MIP_ERROR_NO_EVENT if no transmitted data was found.
- 0 if the data was received.
#include <mip.h>
MiP mip;
uint8_t dongleCode[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
MiPIRCode receiveCode;
bool connectResult;
void setup() {
connectResult = mip.begin();
if (!connectResult)
{
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("ReadIRDongleCode.ino - Receive code from another MiP using IR."));
}
void loop() {
mip.readIRDongleCode(receiveCode);
if (receiveCode.dataNumbers) {
Serial.print(F("Receiving ")); Serial.print(receiveCode.dataNumbers); Serial.println(F(" data numbers."));
for (int i = 0; i < receiveCode.dataNumbers ; i++)
{
Serial.print(receiveCode.code[i], HEX); Serial.print(F(" "));
}
Serial.println();
}
receiveCode.clear();
delay(500);
}🔗 Quick Links: Main Repository • Report an Issue • Wiki Home
An open-source API for the WowWee MiP Robot. Licensed under Apache-2.0.
- MiP
- MiPChestLED
- MiPClapSettings
- MiPDebug
- MiPHardwareInfo
- MiPHeadLEDs
- MiPIRDongleCode
- MiPSoftwareVersion
- MiPStatus
- MiP_Battery
- MiP_ChestLED
- MiP_Clap
- MiP_EEPROM
- MiP_Gesture
- MiP_HeadLEDs
- MiP_Infrared
- MiP_Mode
- MiP_Motion
- MiP_Odometer
- MiP_Position
- MiP_Radar
- MiP_Serial
- MiP_Shake
- MiP_Sound
- MiP_Version
- MiP_Weight
- MiP_WiFi