Attaching an LED

Materials: LED and 2 Aligator Clips

LED = Light Emitting Diodes

These diodes light up when a current is passed through. They have only two states ON or OFF.

In all of computer science the following idea / statements will be true

light on = 1
    //1 sends the electrical current
ligth off = 0
    //0 does NOT send an electrical current

Examine your diode: our LED's come in 4 options: red, yellow, blue, green or clear/white. They have two legs - one is longer than the other

  1. Disconnect your microbit from the computer or batteries (aka take away all power while be play with electricity)

  2. Attach your ground wire to the GRD Pin on your microbit

  3. Attach the other end to the short leg of your LED

  4. Attach the 2nd clip to PIN 0

  5. Attach the other end of your 2nd clip to the long leg of your led

Here is the code for the microbit. LED's can be "finicky" so this is a good time to have an image appear on start - this debugging technique will ensure that your program was loaded properly.

When Button A is pressed
    digital write Pin 0 to 1
    //locate the red pin code blocks in the advanced section
    

Now download and test your code. When you press the A button your LED should light up. Sometimes the codes need to be slightly adjusted so if it does not immediately light up, spend some time double checking your clip connections and wires. This can take a bit of patience.

Now return to your code and modify it so that when Button A is pressed the LED light turns off.

Last updated