User Tools

Site Tools


arduino:arduino_crash_course:misc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:arduino_crash_course:misc [2015/02/16 03:48] mithatarduino:arduino_crash_course:misc [2015/02/16 04:22] (current) – [Serial communication] mithat
Line 127: Line 127:
 int ANALOG_PIN = 3;  // Maps to A3 we think. int ANALOG_PIN = 3;  // Maps to A3 we think.
 int val = 0; int val = 0;
- 
-... 
  
 void loop() { void loop() {
Line 134: Line 132:
 } }
 </code> </code>
 +
 +
 +----
 +
 +===== Serial communication =====
 +
 +  * Serial I/O consumes pins 0 (for RX) and 1 (for TX) if used.
 +  * [[http://arduino.cc/en/Reference/Serial|Serial reference]]
 +
 +==== Serial output ====
 +
 +Simple reporting:
 +<code c>
 +void setup() {
 +  Serial.begin(9600);  // init serial communication at 9600 bps
 +}
 +
 +void loop() {
 +  Serial.write(65);           // write a byte (interpreted as ASCII)
 +  Serial.print(42);           // print a number
 +  Serial.println("Yo.");      // print a string as a line
 +  Serial.print(78, HEX);      // print "4E"
 +  Serial.println(1.23456, 4); // print "1.2346"
 +  Serial.end();               // release pins 0 and 1 for general use
 +}
 +</code>
 +
 +==== Serial output ====
 +Later.
 +
 +
 +----
 +
  
arduino/arduino_crash_course/misc.1424058501.txt.gz · Last modified: 2015/02/16 03:48 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki