• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeStarter Kit for pcDuino8 Uno User Guide3.C Language and Arduino type IDE for pcDuino8 Uno3.2.Arduino library and samples3.2.2.ADC
Previous Next

3.2.2.ADC

Posted by: Olva , August 10, 2016
#include <core.h>void setup() {//Initialize serial with baudrate setting, the default config is SERIAL_8N1  int rate = 115200;  Serial.begin(rate);  //you will see the string on the terminal  Serial.println("Serial begin: ");}void loop() {  //if you type the character in the terminal, available() will return the size you typed  if (Serial.available() > 0) {    // read the incoming byte:    char thisByte = Serial.read();    //print it on the terminal with DEC format    Serial.print("I received: ");    Serial.println(thisByte, DEC);  }  delay(200);}

ADC

Arduino functions

analogReference()
andalogRead()

Because pcDuino8 Uno has no on-chip ADC module, so if you want to use analogRead() you should mount an external ADC module(as shown in the following image) on J10 to read analog signal.

This ADC module has ADI AD7997 12-bit ADC chip, and 6 ADC channels are available. Users can access these ADC port on J7, please check the details from the image below.

Notes:

  1. If you want to measure the high voltage, you can purchase the bridge board for pcDuino, it can measure max 5V input.

Connect

Please take the picture to mount the ADC module to pcDuno8 Uno.

Setup

Connect the battery’s N to any GND and P to the ADC0.

/* 
* ADC test program 
*/ 
#include <core.h> 
int adc_id = 0; 

void setup() 
{ 
    if ( argc != 2 ) 
    { 
        printf("Usage %s ADC_ID(0/1/2/3/4/5)\n", argv[0]); 
        printf("Default will get ADC0 value\n");   
    } 

    if(argc==2)  
        adc_id = atoi(argv[1]); 
} 

void loop() 
{ 
    int value = analogRead(adc_id); // get adc value 

    printf("ADC%d level is %d\n",adc_id, value); 

    delay(1000); 
}

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors