PC817 Adapter Module with Arduino - zonemaker.com







Arduino Sketch


int input_pin = 7;
int led_pin   = 9;
void setup() {
  // put your setup code here, to run once:
  pinMode(input_pin,INPUT_PULLUP);
  pinMode(led_pin , OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int i = digitalRead(input_pin);

  digitalWrite(led_pin,i);

  Serial.println( i);
  delay(250);
}

ความคิดเห็น