Skip to content

This page is archived material from a previous course. Please check for updated material.

    TINAH (2015)

    – software has been written to allow programming of the board in the Arduino IDE. Although the software has been tested with the demo program, there is no guarantee that it will carry out all functions allowed for the board. If there are any long-term problems, the ENPH 253 class may need to shift back to the older IDE, described on previous TINAH document pages (e.g. TINAH 2014).

    Changes in code required to run old TINAH programs from Wiring in the updated Arduino IDE:

    • revising the #include statements at the start of the file and in “void setup()”
    • DC motors will only run from -255  to 255   (the motors are now 8-bit PWM, rather than the old 10-bit in Wiring)

    What is TINAH?

    TINAH is an extension shield designed and built for the ENPH 253 course. The TINAH board connects to the Wiring Board, an open-source electronics IO board that is similar to Arduino boards.

    The TINAH board design was inspired by the Handyboard, a Motorola 6811-based microcontroller system designed for educational, hobbyist, and industrial robotics applications. The Handyboard was designed by Fred Martin at MIT in the mid 1990s and was used by hundreds of engineering physics students from 2001 to 2008. The TINAH board replaced the Handyboard starting in 2009. This new board provides functionality intended to be useful for robot design and prototyping in ENPH 253. Features include:

    • Four DC motor outputs connected to on-board H-bridge drivers (9V, 1A/motor)
    • Three RC Servo motor outputs
    • Buffered digital and analog IO pins (for protecting the Wiring board)
    • Two buttons and two knobs for on-board control
    • 16×2 character LCD
    • Enable and direction pins for external motor control (5V logic)

    Many thanks to the funding sources which made the development of the TINAH boards possible: UBC Skylight, UBC Teaching and Learning Enhancement Fund, and UBC Physics and Astronomy.

    Getting Started

    Install the Arduino IDE

    Download and install most recent Arduino IDE for your operating system (1.6.2 or newer).

    You may need to manually install the USB VCP driver if your computer has problems communicating with or recognizing the TINAH board. Users running Windows 8 may need to disable driver signing in order to install the necessary drivers.

    Install the TINAH library



    Extract the Hardware and Libraries folders to My Documents\Arduino


    Extract the Hardware and Libraries folders to Documents\Arduino

    Manually create the directories if they were not automatically created when installing the Arduino IDE. Restart the Arduino IDE after extracting the Hardware and Libraries folders.

    Start with the the template code

    The TINAH board requires some special initialization code that is found in the template code below. The code below can be copied directly into the Arduino IDE and should be used as a starting template for any programs flashed onto the TINAH board.

    Note: The line of code

    should come before any other code inside the void setup() function.

    Power the TINAH board

    The TINAH board requires external power to operate, either through an external battery or the power jack input. Plugging the board into the USB port does not provide the power to operate the board.

    Note: a small piece of plastic has been inserted into the power jack in the Wiring board – do not remove this plastic! This does not properly power the TINAH shield board.

    Upload code

    Enable verbose output

    In the File -> Preferences menu, ensure that the compilation and upload boxes are checked. Enabling verbose output makes it easier to debug issues when programming the TINAH board.

    Board and port selection

    Ensure that the correct board and port are selected in the Tools drop down menu.

    Compile and Upload

    Once your code is ready, press Verify to compile, then press Upload to flash the code to the TINAH board. Press and release the Reset button on the TINAH board within five seconds of pressing Upload to initiate the transfer. On some computers, uploading works better when the Reset button is pressed immediately prior to pressing Upload.

    Try the demo program

    The demo program shows some of the functionality of the board (LCD screen, digital and analog inputs, and motor/servo motor outputs). You can find the demo program here.


    Power Switch

    Used to turn the board on and off.  The board must be externally powered through either the 12V DC input jack or through the battery wire.  Plugging the USB cable into the board does not provide any power to the board.

    12V DC Input

    The board is fully functional with a DC input 12 to 16V. The Wiring board, LCD and all digital logic works at voltages greater than 7V, but the motor outputs will not operate properly at voltages less than 12V. The DC input jack is center-positive.

    Battery Output

    This screw-down header connector gives direct connection to the battery connected to the TINAH board. This connection can be used to connect the battery to any external circuitry (external motor drivers, sensors/switches which require power, etc).

    Stop and Start Buttons

    The buttons are named start and stop, but can be used interchangably depending on the code that you write, using the stopbutton() and startbutton() commands. Commands can be found in the Software writeup.

    Motor outputs and indicators

    4 motors can be controlled using the setup (Motor 0, 1, 2, and 3). The LEDs indicate the direction and intensity of the motor (brighter = higher PWM = faster motor).  Commands for using the motors can be found in the Software writeup.

    Motors can be connected directly to the board through either the screwdown terminals, or the header pins immediately to the left of the screw terminals (they are electrically connected). The figure below shows the groupings for the screw terminals and the header sockets for the motors.

    The header pins are in groups of 3 pins, with the middle pin not connected to anything; this means that a motor on a 3-pin header will not be powered in case the motor is accidentally shifted over by a single pin on the header.

    The TINAH board limits the output of the motors connected to 9V at a maximum of ~700 mA per motor (the board uses an H-bridge chip, the SN754410NE, with power through a 7809 regulator) .  Any motor with larger voltage or current requirements should be driven with an external H-bridge controller using the signals generated using these inputs/outputs or the motor control signal outputs described below.

    Motor control signal output

    These digital logic-level signal outputs are meant to connect with an external H-bridge or other motor control circuit for arbitrary current or voltage requirements.  See the information for the H-bridge chip used on the TINAH, the SN754410NE. This is similar to many types of single-chip H-bridge chips as well, such as the L293D.   These are signal outputs, and do not source or sink sufficient current to directly to power a DC motor.

    Servo Motor Outputs

    The servo motor outputs can be connected as shown. The board can take any standard RC servo motors, as explained here with a default 5V power connection as shown. Take care to insert RC servo motors into the plug-in headers so that the Signal Line is connected to the motor correctly (typically the white or yellow line).

    Reset Button

    This button resets the microprocessor on the Wiring board. This button must be pressed within approximately five seconds of uploading code to the TINAH board from the Arduino IDE.

    Digital Inputs

    16 digital input lines grouped into two ports (Port0 and Port1).

    The pinout convention matches the setup used in the Handy Board, with a sensor signal pin, a gap, followed by a row of 5V and ground.

    Analog Input

    8 analog input lines, with 0-5V input range. Note that Analog Inputs 6 and 7 are tied to the two knobs, but can be redirected to the Analog Input header by changing the jumper settings next to the knobs. The pinout convention matches the setup used in the Handy Board, with a sensor signal pin, a gap, followed by a row of 5V and ground.

    PWM Outputs

    Six of the TINAH board pins can be used as general purpose PWM (pulse width modulation) outputs. Four of these pins (PWM0, PWM1, PWM4, PWM5) are assigned to motor outputs, but can be used as PWM outputs if motors are not connected. See the Software for details about using PWM pins. PWM pins can also be configured as general purpose digital input/output pins.

    Rx/Tx Indicators

    LEDs indicate when there is communication along the USB/Serial port interface to the main computer. This occurs if either the board is being reprogrammed, or if information is being transferred to or from the main computer using the Serial library commands.

    LCD Screen

    16 column x 2 row LCD display. Use the LCD commands as described in the Software writeup to write information to the screen.

    Note that the LCD does not automatically reset when the Reset Button is pressed. This means that the program may be halted and a new program received and downloading while the LCD displays the most recent update, sometimes for several seconds while the program is downloading.

    Power Indicator

    On when the TINAH board receives sufficient power to operate.


    Access the value of the two knobs by calling the knob functions knob(6) or knob(7). Can change the jumpers in order to connect Analog Inputs 6 and 7 to the analog input header pins instead of from the knobs

    Pinout Reference

    Refer to the pinout reference below for a detailed overview of the TINAH board pins. Click to see the full size pinout reference.


    The majority of software used for the TINAH board is the default Wiring language,which containsMany examples and tutorials showing how to interface the Wiring board to a variety of devices.   Note that the TINAH board contains several ICs used to protect and buffer the pins on the Wiring board, so you are not able to interface with some items)The following table summarizes the functions available specifically for the TINAH board through the phys253wiringvX library:


    Functional Area Command Description Notes

    LCD Commands

    Clears the display screen. The instructions for writing to the LCD screen are the same as described in Wiring, except the pinouts have already been defined and the class “LCD” has already been defined.
      Sets the cursor to the specified column and row. Note that the LCD screen used is a 16×2 character display, and will not automatically word wrap the text to the next line.
      Sets the cursor display in the upper-left corner.  Equivalent to LCD.setCursor(0, 0).  

    Knobs and Buttons

    Returns the analog value of the hardware knob connected to pin 6 or pin7 on the TINAH board (a 10-bit input value, ranging from 0 to 1024).  Equivalent to the command analogRead(6) and analogread(7).  
      Returns the Boolean value of the start and stop buttons on the board.  The buttons are named start and stop, but can be used interchangably depending on the code that you write.  

    DC Motors

    motor_num = 0, 1, 2, or 3 velocity = -255 to 255   (negative values move motor in one direction, positive numbers in the opposite direction).  
      turn off the output to the specified motor  
      turns off all of the 4 DC motor outputs  

    PWM Outputs

    Writes an analog value to the specified PWM pin. Analog output is in the form of a pulse width modulated square wave. Digital pins 29, 30, 31, 35, 36, and 37 may be used as PWM outputs. For more PWM pin information, see the TINAH pinout reference. For more information about analogWrite(pin, value), refer to the official Arduino documentation.
      Resets the PWM pin outpin and allows digital information to be written to outpin using the digitalWrite command.  

    Servo Motors

    angle = integer from 0 to 180. The RC Servo moves to the specified angular position. DO NOT EXCEED 180, as excess current is drawn through the motor circuit, which likely results in the servo motor glitching and may affect the rest of the board function.
      To remove the RC servo motor from usage, and to free up the corresponding PWM output for general use.  

    Checklist, Bugs and Revisions


    Upload Checklist

    A brief list of items before compiling and uploading programs to the TINAH boards:

      1. DO NOT MODIFY ANY JUMPERS – for the time being, unless you verify your design with one of the course instructors please do not modify any of the jumpers on your board.
      2. DO NOT USE digitalWrite or portWrite COMMANDS – there is the potential for the board to have issues with the digital buffers and the wiring board if the digital output lines are used without resetting the jumper.  Unless you have your board design verified by one of the course instructors, refrain from using these two commands with Digital Ports 0 or 1.  Instead, write to one of the unused PWM lines (PWM 3 or PWM4) to gain an additional output line.

    Bugs and Code Revisions

      1. BUZZER – There is an onboard buzzer (located just under the LCD screen) which is connected to PWM3.  Originally, it was intended to use the pulseOut function to vary the frequency of the PWM output and change the sound of the buzzer.  There is currently a conflict with the signal generated by the pulseOut function and the DC motor outputs (which use PWM0, 1, 4, and 5), so that when the buzzer is connected there is always some audible “clicking” which currently cannot be turned off without disabling two of the DC motors.  The buzzer is connected by a jumper connection, and is currently disabled until the software is corrected.
      2. BUFFERS FOR DIGITAL INPUT/OUTPUT –  at present, the buffer chips (74ls245 octal bus transceivers) were used to connect the wiring board digital i/o lines to the pinouts on the TINAH board.  However, no series resistors were put in line between the 74ls245 pins and the wiring board pins.  This results in the situation whereby the jumper pins on the digital ports (used to select the input or output lines) must be changed in conjunction with changing the status of the ports using the “portMode” command.  Not doing so means that both the 74ls245 and the ATmega128 pins are both driving the same line, which may result in damage to either or both of the pins.  Care must be taken before changing the jumper pins on these settings..


    Examples (Advanced)

    External Interrupts

    External interrupts are events that can be triggered when certain digital pins change state. When an interrupt routine is triggered, the processor immediately stops what it is doing, executes the interrupt routine, and then resumes normal operation.

    Timer Interrupts

    Timer interrupts can be used to trigger an interrupt service routine at a regular interval. In the code example below, and interrupt routine toggles an LED at a specified interrupt frequency. Note: Timer1 is also used by Motor1, and the code below may interfere with motor functionality.

    Menu System

    The example below shows one possible way to implement a menu system on the TINAH board. The start button opens the menu and the stop button closes the menu. Knob(6) is used to scroll through items in the menu, and knob(7) is used to adjust the value of each item in the menu. When item values are changed, the value is stored permanently using EEPROM. When the TINAH board is rebooted each item will remember the last value.


    This involves features and functions that are likely not going to be used during Physics 253, but are available with the boards used in higher-level courses (e.g. APSC 459/479), or if you are interested in exploring some of the other features on the board.

    Core Libraries:

    • Core Libraries (likely not used for Phys 253, but has potentially useful items for later courses, and allows for modification of the lower-level functions on the board)    The TINAH board uses a modified version of the LCD and Servo commands.

    Undocumented features on the TINAH board


    Serial Ports / TWI  (Two-Wire Interface)

    ISP header

    Digital Outputs

    Accessing I/O lines normally used for the LCD screen

    Circuit Schematics



    Board Pinouts

    Wiring Pin# Wiring / TINAH Port# Port Pin# Wiring Functions TINAH functions External Interrupt
    0 0 1 I2C – SCL Digital IO Int 0
    1 0 2 I2C – SDA Digital IO Int 1
    2 0 3 Serial1 – Rx Digital IO Int 2
    3 0 4 Serial1 – Tx Digital IO Int 3
    4 0 5   Digital IO  
    5 0 6   Digital IO  
    6 0 7   Digital IO  
    7 0 8   Digital IO  
    8 1 1   Digital IO  
    9 1 2   Digital IO  
    10 1 3   Digital IO  
    11 1 4   Digital IO  
    12 1 5   Digital IO  
    13 1 6   Digital IO  
    14 1 7   Digital IO  
    15 1 8   Digital IO  
    16 2 1   LCD Data 0  
    17 2 2   LCD Data 1  
    18 2 3   LCD Data 2  
    19 2 4   LCD Data 3  
    20 2 5   LCD Data 4  
    21 2 6   LCD Data 5  
    22 2 7   LCD Data 6  
    23 2 8   LCD Data 7  
    24 3 1   Motor_Dir 0  
    25 3 2   Motor_Dir 1  
    26 3 3   LCD RS  
    27 3 4   LCD R/W  
    28 3 5   LCD E  
    29 3 6 PWM 5 Motor_En 0  
    30 3 7 PWM 4 Motor_En 1  
    31 3 8 PWM 3 ServoOut1/Buzzer  
    32 4 1 Serial0 – Rx    
    33 4 2 Serial0 – Tx    
    34 4 3   ServoOut2  
    35 4 4 PWM 2 ServoOut0  
    36 4 5 PWM 1 Motor_En 2 Int 4
    37 4 6 PWM 0 Motor_En 3 Int 5
    38 4 7   Motor_Dir 2 Int 6
    39 4 8   Motor_Dir 3 Int 7
    40 Analog 0      
    41 Analog 1      
    42 Analog 2      
    43 Analog 3      
    44 Analog 4      
    45 Analog 5      
    46 Analog 6   Knob 1 (jumper)  
    47 Analog 7   Knob 0 (jumper)  
    48     LED (board)    
    49     Stop_button    
    50     Start_button    

    End of Page