Page 230 - 최강 아두이노 퍼스트 참고서
P. 230

Serial.begin(9600);

                   pinMode(xPin, INPUT);
                   pinMode(yPin, INPUT);

                   //activate pull-up resistor on the push-button pin
                   pinMode(buttonPin, INPUT_PULLUP);

                   // For versions prior to Arduino 1.0.1
                   // pinMode(buttonPin, INPUT);
                   // digitalWrite(buttonPin, HIGH);
                 }

                 void loop() {
                   xPosition = analogRead(xPin);
                   yPosition = analogRead(yPin);
                   buttonState = digitalRead(buttonPin);

                   Serial.print("X: ");
                   Serial.print(xPosition);
                   Serial.print(" | Y: ");
                   Serial.print(yPosition);
                   Serial.print(" | Button: ");
                   Serial.println(buttonState);

                   delay(100); // add some delay between reads
                 }
























                                                   230
   225   226   227   228   229   230   231   232   233   234   235