User Tools

Site Tools


arduino:arduino_crash_course:serial_communication

Differences

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

Link to this comparison view

Next revisionBoth sides next revision
arduino:arduino_crash_course:serial_communication [2012/09/14 01:18] – created mithatarduino:arduino_crash_course:serial_communication [2012/11/03 21:20] mithat
Line 1: Line 1:
 ====== Serial Communication ====== ====== Serial Communication ======
 +
 +//Tools > Serial Monitor//
  
 ===== Switch controlled LED with serial reporting ===== ===== Switch controlled LED with serial reporting =====
Line 7: Line 9:
  Turn an LED on and off and send switch state to serial monitor  Turn an LED on and off and send switch state to serial monitor
  */  */
- +
 int pushButtonPin = 2;  // connect the push button to digital pin 2 int pushButtonPin = 2;  // connect the push button to digital pin 2
 int ledPin = 13;        // connect the LED to pin 13 int ledPin = 13;        // connect the LED to pin 13
- +
 void setup() { void setup() {
   Serial.begin(9600);  // initialize serial communication at 9600 bits/second   Serial.begin(9600);  // initialize serial communication at 9600 bits/second
Line 22: Line 24:
 void loop() { void loop() {
   int buttonState = digitalRead(pushButtonPin);  // read the input pin   int buttonState = digitalRead(pushButtonPin);  // read the input pin
- +
   // set LED state accordingly   // set LED state accordingly
   if (buttonState == LOW)         // if the button is pushed   if (buttonState == LOW)         // if the button is pushed
Line 28: Line 30:
   else                            // otherwise   else                            // otherwise
     digitalWrite(ledPin, LOW);    // turn the LED off     digitalWrite(ledPin, LOW);    // turn the LED off
- +
   Serial.println(buttonState);    // print out state of button   Serial.println(buttonState);    // print out state of button
   delay(500);                     // delay between reads   delay(500);                     // delay between reads
 } }
 </file> </file>
arduino/arduino_crash_course/serial_communication.txt · Last modified: 2012/11/12 18:23 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki