ART^2 Code

Debugging the code

Below is the code that I have been slaving away at for the past two hours for ART^2. This is the code that has a working diagonal system. Before we could only draw/paint in squares, because only one motor could be on at a time. That is always true the way we have the code set up right now, so I made a sudo-diagonal method of doing it. One motor is on at one time, but they move only the slightest amount before they let the other one go and it repeats. This made an appearance of diagonal that is imperceptible to the human eye and a pencil.

Technical Junk

Also it turns out that for loops called inside the main “loop()” function makes everything stop working completely, which is why there is a while loop used as a for loop in the code. not using the for loop/while loop in the code makes the pencil move too slowly and stutter.

Next Steps in the Code

1. Make this work for all the directions
2. Use the map function to allow for sensitivity variability
3. Use the buttons on the Nunchuck for rotation of the servo motor

void stepper_controller() {

joystick_input();
joystick_input_neg();

if(directions[0]){
if(directions[1]){
int i = 0;
while(i < 500) {
stepy(true, 1/*map(joy_y_axis, 152, 233, 0, 1600)*/);
stepx(true, 1/*map(joy_x_axis, 145, 230, 0, 1600)*/);
i++;
}
}
}
}

void joystick_input() {
int joy_x_axis = nunchuck_buf[0];
int joy_y_axis = nunchuck_buf[1];

if(joy_x_axis > 145) {
directions[0] = true;
}
if(joy_y_axis > 152) {
directions[1] = true;
}
}

void joystick_input_neg() {
int joy_x_axis = nunchuck_buf[0];
int joy_y_axis = nunchuck_buf[1];

if(!(joy_x_axis > 145)) {
directions[0] = false;
}
if(!(joy_y_axis > 152)) {
directions[1] = false;
}
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s