[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Hardware and software requirements” tab_id=”1395207296-1-5″][vc_column_text]Software: install java development environment first.
Hardware:
- 1 x pcDuino
- 1 xLinker LDR module
[/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1395207296-2-10″][vc_column_text]The parts are wired in the following way:
- GND of Light sensor module to GND of pcDuino
- VCC of Light sensor module to 3.3Vof pcDuino
- SIG of Linker sensor module to ADC1 of pcDuino
[/vc_column_text][/vc_tab][vc_tab title=”Test Results” tab_id=”1395209287903-2-7″][vc_column_text]When run the sample code, it will output:
[/vc_column_text][/vc_tab][vc_tab title=”Test Code” tab_id=”1395209394228-3-9″][vc_column_text]ADC class
package com.test.bean; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ADC_Pin { private int pin = 0; private String pinURI = "/proc/"; public int getPin() { return pin; } public String getPinURI() { return pinURI; } public ADC_Pin(int pin) { // TODO Auto-generated constructor stub this.pin = pin; this.pinURI += "adc" + pin; } public int analogRead() throws IOException { // TODO Auto-generated method stub FileReader fr = new FileReader(this.pinURI); BufferedReader br = new BufferedReader(fr); String string = br.readLine(); fr.close(); int value = Integer.parseInt(string.substring(5)); return value; } }
Test class
package com.test.main; import java.io.IOException; import com.test.bean.ADC_Pin; public class Test { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub ADC_Pin adc1=new ADC_Pin(1); while(true) System.out.println("ADC"+adc1.getPin()+" value:"+adc1.analogRead()); } }
Download source project[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.