Go Down

### Topic: Using a mapped value which is then ramped analog output (Read 3045 times)previous topic - next topic

#### WizenedEE

#15
##### Nov 21, 2012, 12:21 am

Thanks! I'm happy to have solved it mostly myself.

Can you explain the purpose of byte and unsigned long?

They're other types of integers. in an arduino (it changes), an int is two bytes; a byte is one byte; and a long is four bytes. `unsigned' means it will never be negative, so instead of representing (for a 1 byte number for example) -128 to 127, an unsigned byte can represent 0 to 255.

unsigned long is the type returned by millis() so it should be used for variables storing the time.
byte is the shortest possible value so I used it to save memory because it can only be HIGH or LOW anyway

#### squid08

#16
##### Nov 21, 2012, 01:56 am

Thanks! I'm happy to have solved it mostly myself.

Can you explain the purpose of byte and unsigned long?

They're other types of integers. in an arduino (it changes), an int is two bytes; a byte is one byte; and a long is four bytes. `unsigned' means it will never be negative, so instead of representing (for a 1 byte number for example) -128 to 127, an unsigned byte can represent 0 to 255.

unsigned long is the type returned by millis() so it should be used for variables storing the time.
byte is the shortest possible value so I used it to save memory because it can only be HIGH or LOW anyway

Now, I was trying to understand how to simplify my "if else if" statements into an array as previously advised. I will have multiple switches with plenty of options for each, and for the sake of code speed, I will need to minimize what happens in each loop.

Can you help me make sense of how to apply the array to an output with multiple possibilities? Also, the idea of having the arduino check if the switch has moved and if it hasn't avoiding that part of the loop in entirety.

I have tried to search beyond the basic description of array, but I can't find the proper wording.

Go Up

Please enter a valid email to subscribe