I did admit in my last post that LED related projects weren’t the most riveting. However, they still matter; so I want to take the time to explain how you can do something a little more interesting and control one through the Serial Monitor.
The Serial Monitor can be accessed in the Arduino IDE through Tools -> Serial Monitor. This is the link between your Arduino and computer and can be used to send and receive text messages. This can prove useful for debugging and is also kind of cool at the same time.
What You’ll Need
So, to get started with this you will only need a few things;
- An Arduino / Arduino-like board (Obviously).
- Some M-M (Male to Male) jumper wires.
- A 220 Ohm resistor.
- An LED.
The wiring for this project is very bare bones. The only thing to keep in mind here is that instead of wiring the anode of the LED directly to the 5v port on the Arduino, we are instead wiring it to a PWM enabled pin. This is a digital pin that we can control through code.
See below for attached fritzing diagrams I have constructed;
I’ve taken the liberty of writing the code to go with the project. Its rather basic, and enables you to turn the LED on, off and also flash. This is dependant on the input to the Serial Monitor. To use it, copy and paste the code from the gist above into a new window in the Arduino IDE and upload it either through Sketch -> Upload or by clicking the arrow in the top left corner of the IDE.
To check whether everything is working after uploading, the LED should have now come on instead of being off. Go ahead and open the Serial Monitor and you should see a (basic) menu/introduction come up. Try inputting the -, + and f values .
If you are having problems, try checking the baud rate on the Serial Monitor window at the bottom right, it should be 9600 baud.
Also, make sure that you have wired everything up correctly, check the diagrams up there. If you still have problems comment down below and I will do my best to help.