Menu
Microbots
0
  • Make
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • English
  • Your Cart is Empty
Microbots
  • Make
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

CodeCell: Read Analog Values with ADC

Analog sensors, potentiometers, and other variable inputs require an Analog-to-Digital Converter (ADC) to be read by a microcontroller. With CodeCell, reading an analog signal is as simple as calling pinADC().

How to Use pinADC()

To read an analog value, use:

uint16_t myADC = myCodeCell.pinADC(uint8_t pin_num);
  • pin_num → The ADC pin you want to read from (IO1, IO2, or IO3).
  • Returns a 12-bit value between 0 and 4095 (corresponding to 0V – 2.5V, due to the internal voltage reference).

Example: Reading a Potentiometer

If you connect a potentiometer to IO2, you can read its position with:

uint16_t potValue = myCodeCell.pinADC(2);
Serial.println(potValue);

Correct Potentiometer Wiring:

Since the maximum voltage on CodeCell’s ADC pins should not exceed 3.3V, you should connect the potentiometer to 3V3 instead of Vo:

3V3 → One end of the potentiometer  
GND → Other end of the potentiometer  
IO2 → Middle pin of the potentiometer  

Important: Internal Voltage Reference is 2.5V

The onboard microcontroller uses a 2.5V internal voltage reference. This means:

  • If your input voltage is 2.5V, the ADC reading will be 4095 (max value) - any voltage above 2.5V will be 4095
  • If your input voltage is 1.25V, the ADC reading will be around 2048.

To scale readings properly:

float voltage = (myCodeCell.pinADC(2) / 4095.0) * 2.5;
Serial.println(voltage);

Why Use This Function?

  • Works on IO1, IO2, and IO3 - flexibility in choosing ADC pins
  • No need for extra configuration - just call pinADC()
  • Built-in 12-bit resolution for precise readings.

Whether you're reading a potentiometer,  sensor, or other analog signals, CodeCell makes ADC reading easy. 

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2025 Microbots.