STEMBoT 2 User’s Manual ======================================================================== Table of Contents 1.0.0.0 Introduction 1.1.0.0 The Purpose of the STEMBoT 2 1.2.0.0 How to use this manual 2.0.0.0 Hardware Overview 2.1.0.0 STEMBoT 2 Board 2.2.0.0 Battery and Charger 2.2.1.0 Charging the SB2 Battery 2.3.0.0 Remote Controller 2.3.1.0 Pairing the Remote to the SB2...
This manual should be read start to finish by those new to programming Python. The purpose of this manual is not to teach Python, but to show how the STEMBoT 2 board works. For those already familiar with programming in Python, this manual contains high-level function descriptions at the end.
======================================================================== 2.0.0.0 Hardware Overview The STEMBoT 2 package comes with all of the parts necessary to construct the robot as well as a remote control and starter set of UEXT modules. The remote control and UEXT modules come pre-assembled and assembly instructions for the robot are outlined in the following section (3.0.0.0).
XBox controller design with custom internal hardware. 2.3.1.0 Pairing the Remote Controller To pair the remote, navigate to “Tools” on your STEMBoT 2 and then click the B button to enter into the pairing mode. Next press the sync button on the remote, near to Left-button bumper.
======================================================================== 4.0.0.0 Programming - Introduction Programming of the STEMBoT 2 is done through the USB port of the board and the provided cable. With the USB plugged in, the user can view and edit Python files on the board, and program the board through a serial communication program.
Python programs can be added to the SB2 by dragging and dropping files into the /apps folder located on the PYBFLASH drive. Restarting the STEMBot 2 will allow the user to start using their new programs right away, assuming there are no compilation or runtime errors. On your computer, create a new file using the text editor of your choice.
STEMBoT 2 User’s Manual ======================================================================== There are three modules used for accessing low-level functions of the SB2: p yb a nd . The module is used for the multicolor LED, as demonstrated in switch buzzer p yb...
STEMBoT 2 User’s Manual ======================================================================== The three available colors, red, green, and blue, are numbered 1, 2, and 3, respectively, when using the f unction. LED() 4.2.2.0 Switches As detailed in the Hardware Overview (section 2.1.0.0 of this guide) the SB2 has five programmable switches.
STEMBoT 2 User’s Manual ======================================================================== 4.2.3.0 Buzzer Use of the piezoelectric buzzer requires the b uzzer P ython module. The buzzer is used for creating sounds, from simple tones to more complex musical pieces 4.2.3.1 Playing Songs from the Board The SB2 comes with several songs pre loaded.
STEMBoT 2 User’s Manual ======================================================================== 4.3.0.0 Liquid Crystal Display (LCD) Liquid crystal displays (LCDs) are used virtually anywhere modern electronics are found. From TVs to computers to cell phones, they allow people to connect with technology in an intuitive and seamless way. The LCD on the SB2 is 320x240 pixels wide, and manipulating pixels is done by defining their location, and then the data to be written.
STEMBoT 2 User’s Manual ======================================================================== 4.3.2.0 Text Writing text to the LCD is done through the function of the module. p rint() g raphics() The function takes four parameters: the string to be written, the x location, the y p rint()...
Page 14
STEMBoT 2 User’s Manual ======================================================================== Text that is printed to the LCD will not automatically clear if new text is printed, so it’s up to the programmer to “clean up” after printing text. # The following program is a basic second counter. It prints to the LCD how many # seconds have passed.
STEMBoT 2 User’s Manual ======================================================================== 4.3.3.0 Shapes The SB2 includes functions for drawing various shapes, either filled or unfilled, to the LCD. The functions require defined coordinates as well as the desired color of the shape. # This program demonstrates the SB2’s ability to draw shapes by drawing a green...
STEMBoT 2 User’s Manual ======================================================================== 4.4.0.0 Radio The SB2 has a built in radio for communicating with the remote control. 4.4.1.0 Initialization and Configuration 4.4.2.0 Reading Radio Signals Once the remote control is paired with the SB2, it starts transmitting button presses and joystick information.
4.6.0.0 UEXT (Plug-and-Play) Headers On the STEMBoT 2, there are three headers for UEXT connections. UEXT is a standard means of connecting to modules via three types of serial interfaces, UART, SPI, and I2C. The header also contains pins for power (3.3V) and ground.
STEMBoT 2 User’s Manual ======================================================================== Figure 1: UEXT Header Pin Labels 4.6.1.0 General Purpose Use The pins used for serial communication can also be used as GPIO (general purpose input/output) pins. These pins can be accessed by including the p np m odule, which contains the ...
The pins can be also be assigned individually by importing the m odule. In the m achine case of J11, the header on the top of the STEMBoT 2, the pins have been defined below. pinTX=machine.Pin('C12',machine.Pin.OUT) pinRX=machine.Pin('D2',machine.Pin.OUT) pinSDA=machine.Pin('B11',machine.Pin.OUT) pinSCL=machine.Pin('B10',machine.Pin.OUT)
STEMBoT 2 User’s Manual ======================================================================== I2C based UEXT modules can either accept commands directly or consist of a set of registers which can be accessed individually. Writing via I2C can be done using the w riteto() function by using an integer for the address and a bytes() type value for the data to be sent. A third boolean (True/False) parameter can be sent to include or exclude a stop condition (check the appropriate datasheet for more information).
STEMBoT 2 User’s Manual ======================================================================== 4.6.3.2 Seven Segment Display Module The Seven Segment Display Plug and Play module can be controlled through the class of the pnp module. This class takes one parameter, and that is the SevenSegmentDisplay() port into which the module is plugged in (“top”, “right”, or “left”). This class contains 3 primary methods: ...
Page 22
STEMBoT 2 User’s Manual ======================================================================== 4.6.3.9 Motion Tracking Sensor (Accelerometer/Gyroscope) The motion tracking sensor uses an MPU6050 chip which has an on-board accelerometer and gyroscope to read acceleration and angular velocity, respectively. Acceleration is measured in meters per second squared, and angular velocity is measured in degrees per second.
STEMBoT 2 User’s Manual ======================================================================== 4.7.0.0 Servos The SB2 comes with a 3x4 pin header to be used with servos. From left to right, the pins are the control pin, the power (5V) pin, and the ground (0V) pin. Servos, unlike motors, are used for precise control, typically between 0 and 180 degrees.
STEMBoT 2 User’s Manual ======================================================================== 8. If the servo arm has moved 90 degrees from its original (center) position, the first parameter of the calibration() function is correct. If not, either increase (if the arm moved too far) or decrease (if the arm hasn’t moved far enough) the value of the first parameter.
Page 25
STEMBoT 2 User’s Manual ======================================================================== 6.3.1.0 Linux Creating/editing .py files in Linux: In terminal, type “findmnt” to determine the SB2 filepath. As a root user, type “mount -o remount,rw /PATH” where path is the previously identified filepath. This will change the SB2 from a read-only filesystem to a read/write filesystem.
Page 26
STEMBoT 2 User’s Manual ======================================================================== KeyboardInterrupt: >>> CTRL-D - soft reset This basically reset the python interpreter without resetting the processor. It wipes any progam in memory and reruns boot.py and main.py and then returns you to the REPL. So for example, if when you first boot up the board and you use the dir() command: >>>...
Page 27
STEMBoT 2 User’s Manual ======================================================================== foo() At the regular REPL if you tried to paste that in you'd see something like this: >>> def foo(): print('This is a test to show paste mode') print('Here is a second line') foo() Traceback (most recent call last): File "<stdin>", line 3...
STEMBoT 2 User’s Manual ======================================================================== 7.0.0.0 Module/Class/Function Quick Reference The purpose of this section is to provide a high level overview of the SB2 API’s functions for quick reference. Modules need to be included in the code using the i mport statement.
Page 29
STEMBoT 2 User’s Manual ======================================================================== (Function) - p aint(color) - Fills the LCD with a given color. Colors can be created using the RGB() function of the color class (Function) - p rint(string, x, y, color) - Prints the given string to the LCD starting at the x,y coordinate.
Page 30
STEMBoT 2 User’s Manual ======================================================================== (Class) - Motor(x) - Used for interacting with the motors. Accepts either 1 or 2 as a parameter. (Method) - s leep(bool) - Forces the associated motor to enter or exit sleep mode. True sets the motor to sleep and False wakes it up. Leaving the parameter blank returns either True or False depending on the sleep state.
Page 31
STEMBoT 2 User’s Manual ======================================================================== (Method) - r ead(RemoteData, timeout) - Reads the current radio data and puts the information into a RemoteData object. If data cannot be read before the timeout, nothing happens. (Class) - R emoteData() - Used to store remote controller data (Object) - ...
Page 32
STEMBoT 2 User’s Manual ======================================================================== (Class) - S HT21(position) - Used to access the methods of the SHT21 temperature/humidity sensor plug and play module. Accepts one parameter, either “top”, “left”, or “right”. (Method) - g etTempC() - Returns the current temperature in degrees Celsius.
Need help?
Do you have a question about the STEMBoT 2 and is the answer not in the manual?
Questions and answers