im() | Arduino Reference

  • TUTORIALS
  • HARDWARE & TOOLS
  • REFERENCES
  • FAQs
  • ABOUT US
Home References Language References
  • English
  • |
  • Deutsch
  • |
  • Português
  • |
  • 한국어
  • |
  • Français

Sketch

  • Function
  • loop()
  • setup()

Control Structure

  • break
  • continue
  • do while
  • if else
  • for
  • goto
  • if
  • return
  • switch...case
  • while

Further Syntax

  • /* */ (block comment)
  • {} (curly braces)
  • #define (define)
  • #include (include)
  • ; (semicolon)
  • // (single line comment)

Data Types

  • array
  • bool
  • boolean
  • byte
  • char
  • double
  • float
  • int
  • long
  • short
  • size_t
  • string
  • String()
  • unsigned char
  • unsigned int
  • unsigned long
  • Variable
  • void
  • word

Constants

  • constants
  • Floating Point Constants
  • Integer Constants

Variable Scope & Qualifiers

  • const
  • scope
  • static
  • volatile

Digital IO

  • digitalRead()
  • digitalWrite()
  • pinMode()

Analog IO

  • analogRead()
  • analogReference()
  • analogWrite()

Advanced IO

  • noTone()
  • pulseIn()
  • pulseInLong()
  • shiftIn()
  • shiftOut()
  • tone()

Serial

  • Serial
  • Serial.available()
  • Serial.availableForWrite()
  • Serial.begin()
  • Serial.end()
  • Serial.find()
  • Serial.findUntil()
  • Serial.flush()
  • Serial.getTimeout()
  • if(Serial)
  • Serial.parseFloat()
  • Serial.parseInt()
  • Serial.peek()
  • Serial.print()
  • Serial.println()
  • Serial.read()
  • Serial.readBytes()
  • Serial.readBytesUntil()
  • Serial.readString()
  • Serial.readStringUntil()
  • serialEvent()
  • Serial.setTimeout()
  • Serial.write()

Stream

  • Stream
  • Stream.available()
  • Stream.find()
  • Stream.findUntil()
  • Stream.flush()
  • Stream.getTimeout()
  • Stream.parseFloat()
  • Stream.parseInt()
  • Stream.peek()
  • Stream.read()
  • Stream.readBytes()
  • Stream.readBytesUntil()
  • Stream.readString()
  • Stream.readStringUntil()
  • Stream.setTimeout()

String Functions

  • String.c_str()
  • String.charAt()
  • String.compareTo()
  • String.concat()
  • String.endsWith()
  • String.equals()
  • String.equalsIgnoreCase()
  • String.getBytes()
  • String.indexOf()
  • String.lastIndexOf()
  • String.length()
  • String.remove()
  • String.replace()
  • String.reserve()
  • String.setCharAt()
  • String.startsWith()
  • String.substring()
  • String.toCharArray()
  • String.toDouble()
  • String.toFloat()
  • String.toInt()
  • String.toLowerCase()
  • String.toUpperCase()
  • String.trim()

String Operators

  • String += (append)
  • String == (comparison)
  • String + (concatenation)
  • String != (different from)
  • String [] (element access)
  • String > (greater than)
  • String >= (greater than or equal to)
  • String < (less than)
  • String <= (less than or equal to)

Keyboard

  • Keyboard
  • Keyboard.begin()
  • Keyboard.end()
  • Keyboard Modifiers
  • Keyboard.press()
  • Keyboard.print()
  • Keyboard.println()
  • Keyboard.release()
  • Keyboard.releaseAll()
  • Keyboard.write()

Mouse

  • Mouse
  • Mouse.begin()
  • Mouse.click()
  • Mouse.end()
  • Mouse.isPressed()
  • Mouse.move()
  • Mouse.press()
  • Mouse.release()

Time

  • delay()
  • delayMicroseconds()
  • micros()
  • millis()

Math

  • abs()
  • constrain()
  • map()
  • max()
  • min()
  • pow()
  • sq()
  • sqrt()

Characters

  • isAlpha()
  • isAlphaNumeric()
  • isAscii()
  • isControl()
  • isDigit()
  • isGraph()
  • isHexadecimalDigit()
  • isLowerCase()
  • isPrintable()
  • isPunct()
  • isSpace()
  • isUpperCase()
  • isWhitespace()

Bits and Bytes

  • bit()
  • bitClear()
  • bitRead()
  • bitSet()
  • bitWrite()
  • highByte()
  • lowByte()

Arithmetic Operators

  • + (addition)
  • = (assignment operator)
  • / (division)
  • * (multiplication)
  • % (remainder)
  • - (subtraction)

Bitwise Operators

  • << (bitshift left)
  • >> (bitshift right)
  • & (bitwise and)
  • ~ (bitwise not)
  • | (bitwise or)
  • ^ (bitwise xor)

Boolean Operators

  • && (logical and)
  • ! (logical not)
  • || (logical or)

Comparison Operators

  • == (equal to)
  • > (greater than)
  • >= (greater than or equal to)
  • < (less than)
  • <= (less than or equal to)
  • != (not equal to)

Compound Operators

  • += (compound addition)
  • &= (compound bitwise and)
  • |= (compound bitwise or)
  • ^= (compound bitwise xor)
  • /= (compound division)
  • *= (compound multiplication)
  • %= (compound remainder)
  • -= (compound subtraction)
  • -- (decrement)
  • ++ (increment)

Conversion

  • byte()
  • char()
  • float()
  • int()
  • long()
  • (unsigned int)
  • (unsigned long)
  • word()

Random Numbers

  • random()
  • randomSeed()

Trigonometry

  • cos()
  • sin()
  • tan()

External Interrupts

  • attachInterrupt()
  • detachInterrupt()

Interrupts

  • interrupts()
  • noInterrupts()

Utilities

  • PROGMEM
  • sizeof()

Pointer Access Operators

  • * (dereference operator)
  • & (reference operator)

Zero, Due, MKR Family

  • analogReadResolution()
  • analogWriteResolution()
String.trim()

Description

Get a version of the String with any leading and trailing whitespace removed. As of 1.0, trim() modifies the String in place rather than returning a new one.

Syntax

myString.trim()

Parameter Values

  • myString: a variable of type String.

Return Values

  • Nothing

Example Code

String myString; void setup() { Serial.begin(9600); myString = " Arduino "; Serial.println(myString.length()); // length before trimming myString.trim(); Serial.println(myString.length()); // length after trimming Serial.println(myString); // string after trimming } void loop() { }

The result on Serial Monitor:

COM6 Send 10 7 Arduino Autoscroll Show timestamp Clear output 9600 baud   Newline  

As we can see, the length of the myString before trimming is 10. After trimming, the length is 7. That is because one leading and two trailing whitespace charecters are removed.

※ NOTES AND WARNINGS:

If the string is modified, it is highly recommended using String.reserve() to prevent the memory fragmentation issue

See Also

  • Language : Arduino - String
  • Language : String.c_str()
  • Language : String.charAt()
  • Language : String.compareTo()
  • Language : String.concat()
  • Language : String.endsWith()
  • Language : String.equals()
  • Language : String.equalsIgnoreCase()
  • Language : String.getBytes()
  • Language : String.indexOf()
  • Language : String.lastIndexOf()
  • Language : String.length()
  • Language : String.remove()
  • Language : String.replace()
  • Language : String.reserve()
  • Language : String.setCharAt()
  • Language : String.startsWith()
  • Language : String.substring()
  • Language : String.toCharArray()
  • Language : String.toDouble()
  • Language : String.toFloat()
  • Language : String.toInt()
  • Language : String.toLowerCase()
  • Language : String.toUpperCase()
  • Example : String Tutorials

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
PREVIOUS NEXT DISCLOSURE ArduinoGetStarted.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com, Amazon.it, Amazon.fr, Amazon.co.uk, Amazon.ca, Amazon.de, Amazon.es, Amazon.nl, Amazon.pl and Amazon.se The Arduino Reference text is licensed under a Creative Commons Attribution-Share Alike 3.0 License. The content is modified based on Official Arduino References by: adding more example codes and output, adding more notes and warning, rewriting some parts, and re-formating Email: [email protected] ×

Tag » Arduino Remove N