Kamis, Juli 10, 2014

Two ways/shematics ON/OFF Led Using Arduino

There are two ways to ON and OFF led using arduino:
  1. Make schematic as follows:
    • Connect anode of led to pin 13 of arduino
    • Connect cathode of led to pin GND of arduino
    • Add resistor (example 150 Ω) series with led

    Then upload sketch as follows:

    int led = 13;

    void setup()
    {
      pinMode(led, OUTPUT);
    }

    void loop()
    {
      digitalWrite(led, HIGH); //led ON, change HIGH with LOW to led OFF
    }


  2. Make schematic as follows:
    • Connect anode of led to pin 5V of arduino
    • Connect cathode of led to pin 13 of arduino
    • Add resistor (example 150 Ω) series with led

    Then upload sketch as follows:

    int led = 13;

    void setup()
    {
      pinMode(led, OUTPUT);
    }

    void loop()
    {
      digitalWrite(led, LOW); //led ON, change LOW with HIGH to led OFF
    }


    seem pin digital of arduino in condition LOW can be functioned as pin GND, really? not also know. ???(confuse...)

0 komentar: