Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 struct {unsigned int running:1; unsigned int stopped:1; unsigned int counter:4;} machine; machine.stopped = 1; // only 0 and 1 values are allowed, this is a bit machine.running = 0; // only 0 and 1 values are allowed, this is a bit machine.counter++; // this is a 4 bit value so 0-15 are allowed
@alexan:the values are restricted to 0 and 1 but the datatype of variables represent int(byte).storage space not reduced.correct???
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT)) #define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT)) char mychar; SETBIT(mychar,0); // set bit 0 to 1 CLEARBIT(mychar,0); // set bit 0 to 0 SETBIT(mychar,1); // set bit 1 to 1 CLEARBIT(mychar,1); // set bit 1 to 0 SETBIT(mychar,2); // set bit 2 to 1 CLEARBIT(mychar,2); // set bit 2 to 0
Code C - [expand] 1 2 3 4 #define CHECKBIT(ADDRESS,BIT) (ADDRESS & (1<<BIT)) if CHECKBIT(mychar,0) // check for 1 if (!CHECKBIT(mychar,0)) // check for 0
volatile bit RC1 @ ((unsigned)&PORTC* 8 )+1;
You can create your own but usually you can use simple char variable, is the space that limited?
This should work:
Code C - [expand] 1 2 3 4 5 struct {unsigned int running:1; unsigned int stopped:1; unsigned int counter:4;} machine; machine.stopped = 1; // only 0 and 1 values are allowed, this is a bit machine.running = 0; // only 0 and 1 values are allowed, this is a bit machine.counter++; // this is a 4 bit value so 0-15 are allowed
Alex