Attiny85 and analog input addressing
Moderators: adafruit_support_bill, adafruit

Attiny85 and analog input addressing

by zedin on Mon Feb 04, 2013 6:31 pm

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.
zedin
 
Posts: 9
Joined: Tue Nov 06, 2012 5:54 pm

Re: Attiny85 and analog input addressing

by adafruit_support_mike on Thu Feb 07, 2013 8:38 pm

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 | TOGGLE FULL SIZE
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.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 10073
Joined: Thu Feb 11, 2010 2:51 pm