Hardware

testing serial

maetel 2006. 12. 10. 17:23

processing

// Serial Output + debug
int ledPin = 48;

int switchpin = 0;  // switch connected to pin 0
 
void setup() {
  pinMode(switchpin, INPUT);  // pin 0 as INPUT
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);         // start serial communication at 9600bps

}
 
void loop() {
  digitalWrite(ledPin, HIGH);
  Serial.print(1);                  // send 1 to Processing
  delay(500);

  digitalWrite(ledPin, LOW);
  Serial.print(0);                  // otherwise send 0 to Processing
  delay(300);
/*  delay(200);
  digitalWrite(ledPin, LOW);
  delay(200);
  if(digitalRead(switchpin) == HIGH)  // if switch is ON
  {
    digitalWrite(ledPin, HIGH);
        Serial.print(1);                  // send 1 to Processing
  }else{
    digitalWrite(ledPin, LOW);
    Serial.print(0);                  // otherwise send 0 to Processing
  }
  delay(100);                         // wait 100ms
  */
}