Introduction
- For this project i will show you how to use a useful feature of the arduino; the serial monitor.
- it can be used to display serial data which is read form or sent to a peripherals
- it can be used to display the value of an analog signal read by the arduino.
- it can also be used to do simple debugging. The value of variables and print statements can be displayed.
- we will be using the same circuit as the previous project.
- for this project we will display the value read from the light sensor in the arduino's serial monitor
Materials
- Arduino
- Breadboard
- wires
- (one) phototransistor
- (one) LED
- (one) 220 ohm resistor
- (one) 10k ohm resistor
Circuit
Here is the circuit diagram for this project.
Things to note:
- This is the exact same circuit from the Light Sensor project.
Code
Here is code for this project. The entire code can be found here
things to note:
- Serial.begin(9600) This function starts serial communication.
- 9600 is the baud rate.
- baud rate is the rate of serial data transfer in bits per second.
- for more information, please see the arduino reference page.
- 9600 is the baud rate.
- Serial.print() this function prints to the serial monitor.
- This will print any message in between the parenthesis.
- it does not print a new line at the end.
- Serial.println() this function prints to the serial monitor.
- This is similar to the print function, except that it prints a new line at the end.
Accessing The Serial Monitor
How to access the Serial Monitor |
- To access the Serial monitor, first make sure the arduino is plugged into your computer.Next you will need to go to 'Tools' on the top bar of the IDE, then select 'Serial Monitor.'
- next you will see a window pop up. This is the serial monitor window.
Serial Monitor window |
Final Conclusions,Remarks,and Results
- Once the monitor is open and your circuit is set up, you should see data being printed to the monitor window.
- try changing the amount of light received by the light sensor and checking the changing output on the monitor window.
- the serial monitor is a useful feature of the arduino and can come in handy in many situations.
Going further
Things to do to continue this project:
- try printing out different messages to the serial monitor
- just play around with it and you'll quickly learn everything you may need to know about using it.
Thank you for reading through my tutorial. Please check back again for the next part of my arduino tutorial.