• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

arduino IDE command equivalent? (for MicroPyhton, pot.atten(ADC.ATTN_11DB)

Q&A Forum › Category: ESP32 › arduino IDE command equivalent? (for MicroPyhton, pot.atten(ADC.ATTN_11DB)
0 Vote Up Vote Down
Virapong Chongpatiyutt asked 7 years ago

(The following line applies just to the ESP32. It defines that we want to be able to read voltage in full range. This means we want to read voltage from 0 to 3.3 V.)

pot.atten(ADC.ATTN_11DB)

what is this equivalent commend for Arduino IDE?
1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 7 years ago

Hi.
In the setup() try the following:

analogSetPinAttenuation(ADC_PIN,ADC_6db);

in which ADC_PIN corresponds to the GPIO you are getting the readings. The second argument can be one of the following:
(ADC_ATTEN_DB_0) 0dB attenuaton: gives full-scale voltage 1.1V
(ADC_ATTEN_DB_2_5) – 2.5dB attenuation gives full-scale voltage 1.5V
(ADC_ATTEN_DB_6) – 6dB attenuation  gives full-scale voltage 2.2V
(ADC_ATTEN_DB_11) – 11dB attenuation gives full-scale voltage

Then, right after that add the following lines:

adcAttachPin(ADC_PIN);
adcStart(ADC_PIN);

I hope this helps.
Regards,
Sara 🙂

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.