Programming mBot with Arduino(C/C++) IDE


#1

Hi, searching for a guide or a documentation for learn how to program a mBot with Arduino IDE i realized that a link served by Makeblock is not working.
The link is the following: http://learn.makeblock.cc/learning-arduino
I hope you could fix it.
I write this also because i can’t find any documentation or related to program the mBot with the Arduino IDE.
I appreciate your help so much and any link to any page or something that could be useful to learn what i expressed, regards.
PS: Also i found this link to a doc: http://learn.makeblock.cc/Makeblock-library-for-Arduino/index.html
but it doesn’t work neither.


To what pins are RGB LEDs attached?
Getting started with Arduino C coding with mBot Ranger
#2

I wrote a blog post (link) for setting up the Arduino IDE to program using the official Makeblock libraries. Below is an example of turning on and off the LEDs on the mBot (mCore) board. Remember that the mCore is an Arduino Uno…

/***********************************************************************
 * Program:     Turn_On_All_Onboard_LEDs
 *
 * Author:      Charles McKnight
 *
 * Description:
 *  This program sets the color of the onboard LEDs to a shade of red,
 *  waits 2 seconds and then turns the onboard LEDs to black (off).
 ************************************************************************/

#include <MeMCore.h>

/******************* Global Declarations *******************************/

// Onboard LED port/slot definitions
const int PORT = 7;
const int SLOT = 2;

// LED Control settings
const int BOTH_LEDS = 0;
const int RIGHT_LED = 1;
const int LEFT_LED  = 2;

// Declare the MeRGLed object
MeRGBLed onboardLEDs(PORT, SLOT);

/**************** End of Global Declarations ***************************/

/***********************************************************************
 * Method:  updateLED(int led, int red, int green, int blue)
 *
 * Arguments:
 *           Variable        Values
 *          --------------------------
 *          led             0 - 2  (0 - Both LEDs; 1 - Right LED; 2 - Left LED)
 *          red             0 - 255
 *          green           0 - 255
 *          Blue            0 - 255
 *
 * Returns: N/A
 *
 * Description:
 *  The updateLED method manages the current color of the onboard
 *  LEDs.
 ************************************************************************/
void updateLED(int led, int red, int green, int blue) {
  onboardLEDs.setColor(led, red, green, blue);
  onboardLEDs.show();
}

/***********************************************************************
 * Method:       setup
 *
 * Arguments:    None
 *
 * Returns:      N/A
 *
 * Description:
 *    This method handles all of the initialization for the program.
 ************************************************************************/
void setup() {
  // set the led color components to generate a shade of red
  int red = 150;
  int green = 0;
  int blue = 0;
  int wait_duration = 2000;  // duration in milliseconds

  // set the color of the leds to a shade of red
  updateLED(BOTH_LEDS, red, green, blue);

  // wait for wait duration
  delay(wait_duration);

  // set the led color components to generate black (off)
  red = green = blue = 0;

  // set the color of the leds to black (off)
  updateLED(BOTH_LEDS, red, green, blue);
}

/***********************************************************************
 * Method:      loop
 *
 * Arguments:   None
 *
 * Returns:     N/A
 *
 * Description:
 *    This method executes continuously after the setup method
 *    completes its tasks.
 ***********************************************************************/
void loop() {
}

You can find out the majority of the information by reading through the defines for “MeMCore.h” and the other header files.

Have fun! :slight_smile:

Chuck


#3

It was fatnastic thank you so much! :slight_smile:
I think i’m getting crazy searching for MeMCore, i only want to know if is there any doc of all the libraries or some,
regards.
PS: I only found examples of several persons, but it may not help in the future, because i would like to do complex things and only have examples as reference, you know.


#4

Makeblock builds this file using Doxygen. You could, in theory, generate the files yourself from the source. Much beyond that, you’ll need to think in terms of Arduino programming and treat the mCore, et al., boards as either an Uno (mCore, Orion) or a Mega2560 (Auriga, MegaPi) and use the mappings for any onboard devices or port mappings for anything you plug into the board.


#5

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.