Difference between revisions of "MCookie-LEGOShield"

From Microduino Wiki
Jump to: navigation, search
(Specification)
 
(2 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
  
mCookie-LEGOShield(hereafter refered to as shield)is a plate compatible with Lego. At the same time compatible with Lego NXT interface and motor, it can continue to be stacked with mCookie modules, to make the Lego more smart.
+
mCookie-LEGOShield(hereafter referred to as shield)is a plate compatible with Lego. At the same time compatible with Lego NXT interface and motor, it can continue to be stacked with mCookie modules, to make the Lego more smart.
 
 
 
 
  
  
Line 26: Line 24:
 
! rowspan="1" |MCookie pins||Shield chip pins||Function
 
! rowspan="1" |MCookie pins||Shield chip pins||Function
 
|-
 
|-
| SDA||SDA|| IIC interface SDA pin|
+
| SDA||SDA|| IIC interface SDA pin
 
|-
 
|-
| SCL||SCL|| IIC interface SCL pin|
+
| SCL||SCL|| IIC interface SCL pin
 
|-
 
|-
 
| D0|| D1|| Serial1 RX of mCookie(You can decide weld it or not, and the default is not connecting)
 
| D0|| D1|| Serial1 RX of mCookie(You can decide weld it or not, and the default is not connecting)
 
|-
 
|-
| D1|| D0||mCookie的Serial1 TX (You can decide weld it or not, and the default is not connecting)
+
| D1|| D0||Serial1 TX of mCookie(You can decide weld it or not, and the default is not connecting)
 
|-
 
|-
 
| 5V||5V||Shield can be used to supply power to mCookie.
 
| 5V||5V||Shield can be used to supply power to mCookie.

Latest revision as of 03:38, 4 August 2017

Language: English  • 中文
mCookie-LEGOShield


mCookie-LEGOShield(hereafter referred to as shield)is a plate compatible with Lego. At the same time compatible with Lego NXT interface and motor, it can continue to be stacked with mCookie modules, to make the Lego more smart.


Features

  • 4 motor interfaces, compatible with Lego NXT motors;
  • 4 common sensor interfaces, compatible with the button of NXT interface and sound sensors, and so on;
  • 2 fully functional sensor interfaces, beside compatible with all sensors of common sensor interfaces, also compatible with the NXT ultrasonic sensors and color sensors;
  • IIC interface protocol, and not take up other spare IO ports.

Specification

  • Power supply: Use 2S model aircraft lithium battery to supply power, 7.4V.
  • Master control: MCookie-LEGOShield adopts Atmega328p master control, and it can run driver independently.
  • Communication: IIC communication, and the address is 0x08(can be customized)
  • Interface: 4 NXT motor interfaces, and 6 NXT sensor interfaces(only S1 and S2 support the ultrasonic sensors and color sensors among them)
MCookie pins Shield chip pins Function
SDA SDA IIC interface SDA pin
SCL SCL IIC interface SCL pin
D0 D1 Serial1 RX of mCookie(You can decide weld it or not, and the default is not connecting)
D1 D0 Serial1 TX of mCookie(You can decide weld it or not, and the default is not connecting)
5V 5V Shield can be used to supply power to mCookie.
GND GND Common ground
  • Note:
    • The bit of IIC slave address of shield is adjustable, and you need to rewrite the firmware.
  • If you use shield to supply power, because the initialization of shield firmware needs a certain time, when mCookie writes the control program, you should run it after delayed for a while.
MCookie-LEGOShield-TOP.jpg
MCookie-LEGOShield-BUT.jpg

Documents

mcps17 A3906 Atmega328p

Development

Shield adopts IIC interface communication, and the address of IIC is defaulted to 0x08, which can read and write register address just like other chips. Explanation of API interface.pdf

  • Driver package has been done for each sensor and motor, so you needn't focus on the basic API any more.
  • Directly use the methods in the library to operate, and the specific protocols have been realized in shield's own master control.
  • Before using various sensors and motors, you should set the type of the sensors and each interface connected or not.
  • Only S1 and S2 support ultrasonic and color sensors.

Use Lego NXT Interface key

Common method:

Determine Whether to Press

Determine Whether to Release

Use Lego NXT Interface Motor

Common method:

Set a Fixed Speed

Range of speed: -255~255

#include <mCookieLEGO.h>
#include "Wire.h"

mCookieLEGO m;
void setup(){
	Wire.begin();
	m.configConnection(0xFFFF); //Set the connection of each interface.
}

void loop(){
	m.motor_setFixedDrive(mCookieLEGO::M1, 50);
	delay(1); // very important
 	m.motor_setFixedDrive(mCookieLEGO::M2, 50);
 	delay(1); // very important
 	m.motor_setFixedDrive(mCookieLEGO::M3, 50);
 	delay(1); // very important
	m.motor_setFixedDrive(mCookieLEGO::M4, 50);
	delay(2000);
}

Use Lego NXT Interface Ultrasonic

Common method:

Get the Current Distance

#include <mCookieLEGO.h>
#include "Wire.h"

mCookieLEGO m;
void setup(){
    Wire.begin();

    m.configSensorType(mCookieLEGO::S1, mCookieLEGO::SENSOR_ULTRA); // Set S1 as ultrasonic sensor.
    m.configConnection(0xFFFF);
}

uint8_t dis;

void loop(){
	dis = m.sensor_ultra_getDistance(mCookieLEGO::S1);
	Serial.print("dis: ");
	Serial.println(dis);
	delay(1000);
}

Application

Lego remote control car

Purchase

No open purchase now.

History

Map storage

MCookie-LEGOShield-pic1.jpg

Video