Skip to main content
corrected spelling and grammar
Source Link
duck
  • 1.3k
  • 10
  • 27

LetsLet's assume value that will be stored into "keyInsert" is only 0 and 1are either "1" or "0". Therefore, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 bytes variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bits data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}

Lets assume value that will stored into "keyInsert" is only 0 and 1. Therefore, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 bytes variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bits data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}

Let's assume value that will be stored into "keyInsert" are either "1" or "0". Therefore, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 bytes variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bits data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}

I dont know about the dataLets assume value that will be stored ininto "keyInsert", so i assume its is only 0 and 1. Therefore, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 bytebytes variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bitbits data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}

I dont know about the data that will be stored in "keyInsert", so i assume its only 0 and 1, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 byte variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bit data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}

Lets assume value that will stored into "keyInsert" is only 0 and 1. Therefore, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 bytes variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bits data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}
Post Undeleted by duck
Post Deleted by duck
Source Link
duck
  • 1.3k
  • 10
  • 27

I dont know about the data that will be stored in "keyInsert", so i assume its only 0 and 1, its a waste to declare them as an array byte

byte keyInsert[15] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    

It means that you will have 15 * 8 byte variable, and its overkill. it will be much simpler if you declare it as

uint16_t keyInsert;    

Which have 16 bit data (2 bytes).
in your code, you can implement it by doing

void LedIFs() {
if (keyInsert == 0x0001) registerWrite(0xFF,0); else 
if (keyInsert == 0x0002) registerWrite(......)......
......
}