#include "avr/io.h" main() { unsigned char= z ; for(z=0;z<200;z++) PORTA=z; //PORTA dispalys the value of z }
Please explain the working of the loop as z is char and is acting as int
char (and by extension, unsigned char) is an integral type. An unsigned char can hold values from 0 to 255.
char
unsigned char
Characters are typically stored in char variables as well. What they actually store is the ASCII value of the character in question. For example:
char c = 'A';
The variable c contains the value 65, which is the ASCII value of A.
c
A
In the case of this code, an unsigned char variable is being used in an integer context.
char(and by extension,unsigned char) is an integral type. Anunsigned charcan hold values from 0 to 255.Characters are typically stored in
charvariables as well. What they actually store is the ASCII value of the character in question. For example:The variable
ccontains the value 65, which is the ASCII value ofA.In the case of this code, an
unsigned charvariable is being used in an integer context.