Difference between revisions of "MCookie-LEGOShield"
From Microduino Wiki
(→Specification) |
(→Development) |
||
Line 51: | Line 51: | ||
==Development== | ==Development== | ||
− | Shield adopts IIC interface communication, and the address of IIC is defaulted to | + | 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 | Explanation of API interface.pdf | ||
− | *Driver package has been done for each sensor and motor, so you | + | *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 | + | *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. | *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. | *Only S1 and S2 support ultrasonic and color sensors. | ||
===Use Lego NXT Interface key=== | ===Use Lego NXT Interface key=== | ||
− | Common | + | Common method: |
====Determine Whether to Press==== | ====Determine Whether to Press==== | ||
====Determine Whether to Release==== | ====Determine Whether to Release==== | ||
Line 66: | Line 66: | ||
===Use Lego NXT Interface Motor=== | ===Use Lego NXT Interface Motor=== | ||
− | Common | + | Common method: |
====Set a Fixed Speed==== | ====Set a Fixed Speed==== | ||
− | Range of | + | Range of speed: -255~255 |
<source lang="cpp"> | <source lang="cpp"> | ||
#include <mCookieLEGO.h> | #include <mCookieLEGO.h> |
Revision as of 09:08, 24 August 2016
Language: | English • 中文 |
---|
ContentsFeatures
Specification
Documentsmcps17 A3906 Atmega328p DevelopmentShield 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
Use Lego NXT Interface keyCommon method: Determine Whether to PressDetermine Whether to ReleaseUse Lego NXT Interface MotorCommon method: Set a Fixed SpeedRange 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 UltrasonicCommon 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);
} ApplicationPurchaseNo open purchase now. HistoryMap storageVideo |