I use a Nano to build the UDPI interface and try to blink a LED on a bare metal ATTiny404 chip. It is successful.
However, I choose one pin ( pin 11 of the IC package (SOP14) or from the data sheet , it is PA1 / AIN 1 ) as the analog pin.
I can make it blink a LED using the following command.
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
digitalWrite(8,LOW);
I have no idea why it is 8 by the way.
When I try to change the pin as analog input
pinMode(A8,INPUT); // which I suppose if digitalmode is 8, then analog is A8
however the program fails to compile.
Also, do the IDE have a ATTiny404 library to access the ATTiny404 manufacturer ID.
I wish to have it so each MCU can communicate a different key
There is (in simple terms) a "translation" from the number 8 to PA1. There will be a similar "translation" for analogue inputs. I'm not familiar with the ATTiny404, if it has one analogue input, it should be A0, else it's trial an error to find the mapping for the analog input.
Which core do you use? You can start digging through there.
Your topic is not really related to Interfacing w/ Software on the computer and hence has been moved to a more suitable location on the forum.
You can't make assumptions about a pin's number when you change it's function. The core I use for my Attiny85 has this diagram https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/extras/ATtiny_x5.md showing that for my chip. It doesn't look like there is one for the 404 there though, but there may be info with whatever core you used, like sterretje mentioned.
pinMode(x, INPUT) does NOT usually change the pin to an analog input (but rather, to a digital input.) I'm not sure if there's a specific command for switching to analog mode, or whether just using analogRead() should do it. (assuming that the pin number is correct. Tiny404 doesn't HAVE an "A8." PA1 looks to be "A1")
(Arduino "pin numbers" are normally completely arbitrary, and based on some particular board. If you're not using a particular board, you should be able to use symbols like "PIN_PA1" to select pins based on the chip port/pin numbers. See ...variants/txy4/variant.h)
Thank you very much for all your help. I now uses something like
PORTA.DIRCLR = 0b11110100;
PORTA.OUT = PORTA.IN | 0b00001000; // toggle high the pin
ADC0.MUXPOS = ADC_MUXPOS_AIN1_gc;
to directly address the registers and keep on debugging
and these links provides information that I cannot replicate