~ubuntu-branches/debian/experimental/arduino/experimental

« back to all changes in this revision

Viewing changes to build/shared/examples/8.Strings/StringCharacters/StringCharacters.pde

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2012-03-11 18:19:42 UTC
  • mfrom: (1.1.5) (5.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120311181942-be2clnbz1gcehixb
Tags: 1:1.0.1~rc1+dfsg-1
New upstream release, experimental.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  String charAt() and setCharAt()
3
 
 
4
 
 Examples of how to get and set characters of a String
5
 
 
6
 
 created 27 July 2010
7
 
 by Tom Igoe
8
 
 
9
 
 http://arduino.cc/en/Tutorial/StringCharacters
10
 
 
11
 
 This example code is in the public domain.
12
 
 */
13
 
 
14
 
void setup() {
15
 
  Serial.begin(9600);
16
 
  Serial.println("\n\nString  charAt() and setCharAt():");
17
 
}
18
 
 
19
 
void loop() {
20
 
  // make a string to report a sensor reading:
21
 
  String reportString = "SensorReading: 456";
22
 
  Serial.println(reportString);
23
 
  
24
 
  // the reading's most significant digit is at position 15 in the reportString:
25
 
  String mostSignificantDigit = reportString.charAt(15);
26
 
  Serial.println("Most significant digit of the sensor reading is: " + mostSignificantDigit);
27
 
 
28
 
// add blank space:
29
 
  Serial.println();
30
 
  
31
 
  // you can alo set the character of a string. Change the : to a = character
32
 
  reportString.setCharAt(13, '='); 
33
 
  Serial.println(reportString);
34
 
 
35
 
  // do nothing while true:
36
 
  while(true);
37
 
}
 
 
b'\\ No newline at end of file'