NXT Shield Library
After several questions on how to use the NXT Shield I decided to create an Arduino library. All the code is available at github: https://github.com/TKJElectronics/NXTShield.
The library is pretty easy to use, I have provided three examples witch demonstrates all the libraries functionalities.
I works with all official Arduinos including Arduino Mega. To use the ultrasonic sensor with an Arduino Mega, one have to connect pin 20 (SDA) to A4 and pin 21 (SCL) to A5. A new revision of the shield might use the two extra SDA and SCL pins that are near to the AREF pin on r3 versions of the new Arduino boards.
Below are some photos of the NXT Shield:
[nggallery id=4]
Categories: Arduino, Development boards, TKJ Electronics
Hie,
Wanted to understand why is the shield necessary? Can we connect the Lego motors and Arduino directly?? And use the library for the communication ?
@Shoriya Chauhan
No, the NXT motor can not be directly connected to the Arduino.
The NXT shield contains the necessary DC motor driver H-bridge for controlling the current through the motor together with analog to digital filters (schmitt trigger) for the encoder signals.
Hello,
I am a noob and trying to learn to connect Lego ultrasonic sensor and Ardunio Mega using the library provided.
I have copied the i2cmaster.h library to “ArduinoData\packages\arduino\hardware\sam\1.6.12\libraries\i2c” (using Windows 10) and NXTShield library to “ArduinoData\packages\arduino\hardware\sam\1.6.12\libraries\NXTShield”
and create extracted the part for ultrasonic sensor code from the examples provided in the GitHub but on compiling the code i get an error as below:
ArduinoData\packages\arduino\hardware\sam\1.6.12\libraries\NXTShield\NXTShield.cpp:30:5: error: ‘TWSR’ was not declared in this scope
TWSR |= _BV(TWPS0); // Set prescaler to 4
as well the same error for the TWPS0, _BV , TWPS1 , TWBR.
I would be using breadboard to connect Arduino Mega and the Ultrasonic sensor for using the NXT connector but connecting the SDA to the pin 20 and SCL to pin 21in the Arduino.
Could you please help me.
Hie,
I am using ultrasonic sensor with the breadboard. I have managed to get the output “Error reading sensor” but i am not sure how do i proceed with it. I connected pin 6 of the NXT connector to the pin 20 on arduino mega and pin 5 of the NXT connector to the pin 21 of the arduino.
@Shoriya
But i am still not able to get the out put.