Pages: 1 [2]   Go Down
Author Topic: Using a mapped value which is then ramped analog output  (Read 1002 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Your description makes sense. Thanks.

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.
Logged

Pages: 1 [2]   Go Up
Jump to: