[vc_row][vc_column width=”1/1″][vc_column_text]There are two serial ports on pcDuino. One is the debug serial port, which is used to enter commands in command mode. The other one is application UART (located in GPIOS pins 1 and 0), which is used to communicate with other modules.
In this experiment,We use the ADC of pcDuino to read the LDR output, and display the reading on both monitor and the application UART.
[/vc_column_text][vc_tour][vc_tab title=”Parts List” tab_id=”1387950640-1-75″][vc_column_text]1. pcDuino experimental platform
2.Serial debug cable
3.photoresistor
4. 10K ohm resistor
5.Several jumper wires[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1387950640-2-86″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Principle” tab_id=”1387952717479-2-0″][vc_column_text]As the resistance of the LDR changes with regards to the changing light intensity, the voltage of the ADC varies. The stronger the light, the smaller the reading. We read the voltage through ADC, and print this reading through the application UART of pcDuino and print the value at the monitor that the same time.
We use a UART to USB converter to display the UART message on a PC. The serial program can be downloaded here.[/vc_column_text][/vc_tab][vc_tab title=”Sample Code” tab_id=”1387952718637-3-0″][vc_column_text]
#include <core.h>
#define SENSOR 1
int val=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
val=analogRead(0);
Serial.println(val);
printf("%d\n", val);
delay(100);
}
[/vc_column_text][/vc_tab][vc_tab title=”Results” tab_id=”1387953198009-4-7″][vc_column_text]The screenshot of pcDuino is shown below:
At the same time, the screenshot of the PC is as below:
Leave a Reply
You must be logged in to post a comment.