Arduino Reference Library Arduino

The Arduino programming language is the main language used to program Arduino and Arduino-based microcontroller boards like Hummingbird Duo. The language is a simplified version of the Java programming language applied to the specific needs of creating programs for microcontrollers.

Initialization

void init()
Fully initializes the Hummingbird. By default it will set as outputs all LED and Vibration motor pins (Arduino pins 2 to 12), it will also enable intensity control for LEDs (using Timer 3) and for vibration motors (using Timer 1). This is the recommended initialization method if you use Hummingbird Duo only with top side connectors.

void initOnlyMotorsAndServos()
Initializes just the SPI communication with Hummingbird’s integrated motor/servo controller. All regular Arduino pins except for digital I/O pin 8 are left alone. Pin 8 is the slave select line for SPI communication with the motor/servo controller and is set to output. This is the recommended initialization method if you use Hummingbird Duo with Arduino shields, even if you also connect some kit components to the top side connectors.

void init(boolean turnOnLEDFading, boolean turnOnVibrationSpeed, boolean turnOnLEDandVibrationOutputs)
Provides user control over specific initialization steps.
Parameters:

  • turnOnLEDFading: Initializes software interrupt on Timer 3 that provides intensity control of the LEDs. If this is not initialized, the LED functions only turn LEDs on or off and Timer 3 is free for user control.
  • turnOnVibrationSpeed: Initializes speed control over the vibration motors, using Timer 1. If this is not initialized, the vibration motors can only be turned on or off and Timer 1 is free for user control.
  • turnOnLEDandVibrationOutputs: Sets Arduino pins 2-7 and 9-13 as outputs.

LEDs

void setLED(byte port, byte intensity)
Sets the intensity of the LED on port 1, 2, 3, or 4.
Parameters:

  • port: The LED’s port: 1, 2, 3, or 4.
  • intensity: The intensity of light from the LED, 0 is off, 255 is fully on. If LED fading is turned off, all non-zero values will result in the LED being fully on.

void setStatusLED(byte intensity)
Sets the intensity of the green status LED (also tied to ‘L’ LED on the Arduino side).
Parameter:

  • intensity: The intensity of light from the LED, 0 is off, 255 is fully on. If LED fading is turned off, all non-zero values will result in the LED being fully on.

void setTriColorLED(byte port, byte red, byte green, byte blue)
Sets the color and brightness of the tri-color LED on port 1 or 2.
Parameters:

  • port: The LED’s port: 1 or 2.
  • red: The intensity of red light from the LED, 0 is off, 255 is fully on. If LED fading is turned off, all non-zero values will result in the red LED being fully on.
  • green: The intensity of green light from the LED, 0 is off, 255 is fully on. If LED fading is turned off, all non-zero values will result in the green LED being fully on.
  • blue: The intensity of blue light from the LED, 0 is off, 255 is fully on. If LED fading is turned off, all non-zero values will result in the blue LED being fully on.

void turnOnLEDFade() and void turnOffLEDFade()
Turns on or off fading control over the LEDs.

Motors and Servos

void setMotor(byte port, int power)
Sets the power to a gear motor on port 1 or 2.
Parameters:

  • port: The gear motor’s port: 1 or 2.
  • power: The power sent to the motor, the range is -255 to 255: 0 is off, 255 is full speed in one direction, -255 is full speed in the other direction. The motor has a dead zone where it will not spin for values between approximately -30 to 30.

void setServo(byte port, byte degrees)
Sets the angle of the servo on ports 1, 2, 3 or 4.
Parameters:

  • port: The servo’s port: 1, 2, 3, or 4.
  • degrees: The servo angle, specified in degrees, with a range of 0 to 180.

void setVibration(byte port, byte intensity)
Sets the intensity of the vibration motor on port 1 or 2.
Parameters:

  • port: The vibration motor’s port: 1 or 2.
  • intensity: The speed of the vibration motor, 0 is off, 255 is fully on. If vibration motor speed control is turned off, all non-zero values will result in full speed for the motor.

void turnOnVibrationMotorSpeed() and void turnOffVibrationMotorSpeed()
Turns speed control on or off for vibration motors.

Sensors

float readInputVoltage()
Returns a reading in volts of the voltage of VIN. Voltages higher than 10V will read as 10V.

int readSensorValue(byte port)
Reads the analog value at the port specified. Values can range from 0 to 1023, with 0 corresponding to 0V and 1023 corresponding to 5V.
Parameter:

  • port: The sensor’s port: 1, 2, 3, or 4.
Back to Top