Attiny85 and analog input addressing

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
zedin
 
Posts: 26
Joined: Tue Nov 06, 2012 5:54 pm

Attiny85 and analog input addressing

Post by zedin »

So been trying to find an answer and even just test stuff but nothing working.

I am using the HLT core for the attiny85 and trying to read an analog signal in but am hitting a brick wall. Using the HLT cores how do you properly address the pin? I am trying to read in on the chip pin 3 (HLT pin 4). I have tried using:
analogRead(3)
analogRead(4)
analogRead(A2)
analogRead(2)

but none seem to work. Does anyone have experience with these cores or shoud I use the attiny-core on google?
I am basically using two pins (0, 1 on HLT scheme) for a ping style sensor, pins 2,3 (on HLT scheme) for LEDS, and pin 4 for reading in a pot for a setting the user can adjust.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Attiny85 and analog input addressing

Post by adafruit_support_mike »

Looking at the files HLT installs, the ATTiny85 is listed as a 'tiny8' variant, and the header for that variant doesn't seem to define any analog input pins. You might try adding:

Code: Select all

const static uint8_t A0 = 1;
const static uint8_t A1 = 7;
const static uint8_t A2 = 3;
const static uint8_t A3 = 2;
to your own header files and seeing if that helps. analogRead()'s bit operations might want the unsigned 8-bit value.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”