Hi guys i've gotten back into coding so i'm super rusty at it
i'm making a program for my manual car
using arduino - joystick(X,Y axis)
1 2 3 4 5 6 7
|
so far i've used
Sketch uses 3600 bytes (11%) of program storage space. Maximum is 32256 bytes.
Global variables use 480 bytes (23%) of dynamic memory, leaving 1568 bytes for local variables. Maximum is 2048 bytes.
left for my code
|
i'm trying to find the most efficient way to do it
so far i've got variables for
the absolute X,Y for each gear
1 2 3 4 5 6 7 8 9 10 11 12 13
|
nutural_X = 524;
nutural_Y = 504;
int almost_1st_or_2ndX = 524;// far left of joystick about to move into first or second gear
int almost_1st_or_2ndY = 1023;
int first_X =0;
int first_Y = 1023;
//repeating each gear and its variable 6 times
|
the two options i can see are as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
while x and y are in range{
if x and y == "moving into 1st or 2nd gear variable "
if x and y == "first gear variables"
print car is in first gear
if x and y == "second gear variables"
print car is in second gear
if x and y == "moving into 5th or 6th gear variable "
if x and y == "fifth gear variables"
print car is in fifth gear
//ect...
}
|
so basically the method 1 will check if the joystick is on the far left middle before moving on to the next conditional statement
(how shifting in a manual gearbox works in real life, you can't jump right into first without going left then up )
method 2
1 2 3 4 5 6 7 8 9 10
|
while x and y are in range{
if x and y == "first gear variables"
print car is in first gear
else if x and y == "second gear variables"
print car is in second gear
//ECT
|
so basically method 2 skips the middle point in between gear changes, (neutral to first)
at the moment i'm coding both options to be flashed into the Arduino memory, and i'll have the option to change methods by a push of a button.