Blink LED
In this lesson, you’ll learn how to write a program that blinks an LED!

Write Code (Java)
Copy the code below into the project you created. If you don't have a project or forgot how to create one, revisit the Configure section.
Not your programming language? Set your preferences so we can display relevant code examples
Write Code (Python)
Copy the code below into the project you created. If you don't have a project or forgot how to create one, revisit the Configure section.
Not your programming language? Set your preferences so we can display relevant code examples
Write Code (C#)
Copy the code below into the project you created. If you don't have a project or forgot how to create one, revisit the Configure section.
Not your programming language? Set your preferences so we can display relevant code examples
Write Code (Swift)
Create two buttons in your window and copy the code below into the project you created. If you don't have a project or forgot how to create one, revisit the Configure section.
Not your programming language? Set your preferences so we can display relevant code examples
Create two buttons
Run Your Program
You will see the red LED blink.
Run Your Program
You will see the red LED blink.
Run Your Program
You will see the red LED blink.
Run Your Program
Click on the buttons to turn the red LED on and off.
Practice
- Modify your code so the LED stays on for 2 seconds.
- Modify your code so the LED flashes on and off 3 times.
- Modify your code to flash the green LED. (Hint: Address)
Practice
- Modify your code so the LED stays on for 2 seconds.
- Modify your code so the LED flashes on and off 3 times.
- Modify your code to flash the green LED. (Hint: Address)
Practice
- Modify your code so the LED stays on for 2 seconds.
- Modify your code so the LED flashes on and off 3 times.
- Modify your code to flash the green LED. (Hint: Address)
Practice
- Modify your code so only one button is used to turn the LED on and off.
- Modify your code to flash the green LED. (Hint: Address)
Troubleshoot
I am getting a "Timed Out" exception.
- Make sure the USB cable from your VINT Hub to your computer is attached properly.
- Make sure you are connected to the correct port on your VINT Hub. In this case your red LED should be connected to port 1.
- Make sure no other program is running that uses Phidgets. If a Phidget is already in use in another program, it will be busy and won't respond to this one.
I can't see the LED flash.
- The LED flash is quick, make sure you are looking the the Getting Started Kit when you run your program.
- If you think you have a defective LED, try swapping it out for another (a classmates or the green LED). If you do have a defective LED, take one from your classroom's spare kits or contact us.
- If you are using PyCharm make sure you have the correct script selected. Sometimes, if you have more than one Python file in your project, you may be running the wrong script. You can select the script from the drop-down menu in the top right corner.
Still having issues?
Visit the Advanced Troubleshooting Page or contact us (education@phidgets.com).