I have a project with arduino UNO . first i write this code:
int a;
void setup(){
for (byte i=0;i<8;i++){
pinMode(i,OUTPUT);
}
}
void loop(){
a = analogRead(A0);//read voltage at A0
a = (a+1)/4 - 1;//scale from 10 bit (0-1023) to 8 bit (0-255)
if (a<0)
{
a = 0;
}
PORTD = a;
}
it works well but there is a problem . i convert the a value 10 bit to 8 bit . but now i want to use the 10 bit value for a. now how can i repalce the pin number Instead PORTD = a;