final project

Wooden Structure

The plan is to modify the file for the wooden maze from week 8. I will need to use a thinner wood because now it is too heavy. Also there needs to be a place for the motors and a way to attach them to the board.

I made more test mills for the connectors to the board to find the exact size.

final project

final project

I milled the maze again and assembled it.

final project

final project

The outer frames turned out too thin so I decided to mill them again out of the 20mm plywood. For that to happen, I needed to modify the file again and make the connectors bigger.

final project

final project

As bearings I used a 10mm steal rod like the one from week 8. For the inner bearings I cut them 35mm long and for the outer ones 45mm long, each rod has a 5mm wooden disc to operate as a spacer between the frames.

final project

final project

Mechanism

For the servo to move the board I needed to build a mechanism that changes circular motion to a linear one. Here are a few ideas I had:

final project

final project

final project

final project

I used the Shopbot to mill aluminum arms for the servos. When milling aluminum you need to put some soap on it to reduce the friction and avoid heating of the endmill.

final project

final project

Connected the aluminum arms to the servos, used a metal rod from an old umbrella as another arm and connected it to the board. In the video you can see the maze controlled by an Arduino and performing the Sweep example for the two servos.

final project

Next I needed to make the mechanism more durable, efficient and easy to fabricate. I printed a Bracket for the wooden plate.

final project proposal

final project proposal

final project
final project

I replaced the aluminum arms with laser cutter 5mm plastic ones. These are the .DXF and .3dm files.

final project

And used threaded rods, bolts and washers to assemble everything together.

Electronics

For the electronics I started with an Arduino Uno. I made a shield that connects to the Arduino with places for the wires to the servo motors and controllers. The Shield is soldered with 4 10K Resistors and one 0 OHM Resistor. This is the board I used for the maker fair. I had a problem with the power of the Arduino and had to keep it connected to my computed for it to work.

final project
final project
final project
final project

Next I made I made another board based on the AtTiny44 micro-controller. It has a 5V regulator and pin headers for the servos and controllers. You can download the Traces and Interior files

final project

Programing

Generally the Code for the game is very simple. Each motor is has a range of 180 degrees. When positioned at 90 degrees the maze is leveled and the tilts back and forth are around that point. The input of each controller is from two photo-resistors. The difference between the two is the data needed to be translated to the angle between 0 and 180 degrees.

It took a while playing with the sensors and the serial monitor to determine the specific inputs. Using the Map function I translated the difference to angle. This is the Code for the Arduino.

//Or Shoval //fablabil //The aMazing Maze - Code for Arduino Uno with Shield #include <Servo.h> #define S_1 A0 #define S_2 A1 #define S_3 A2 #define S_4 A3 Servo myservo1; Servo myservo2; int pos1 = 0; int pos2 = 0; int def1; int def2; int sensor_1_Value = 0, sensor_2_Value = 0; int sensor_3_Value = 0, sensor_4_Value = 0; void setup() { myservo1.attach(9); myservo2.attach(10); pinMode(S_1, INPUT); pinMode(S_2, INPUT); pinMode(S_3, INPUT); pinMode(S_4, INPUT); Serial.begin(9600); } void loop() { //read values from 4 sensors sensor_1_Value = analogRead(S_1); sensor_2_Value = analogRead(S_2); sensor_3_Value = analogRead(S_4); sensor_4_Value = analogRead(S_3); //calculate defference between each pair def1=sensor_1_Value-sensor_2_Value; def2=sensor_3_Value-sensor_4_Value; //translate defference to angle pos1= map(def1, -450, 375, 30, 165); pos2= map(def2, -435, 420, 20, 170); //print data to serial monitor Serial.print(sensor_1_Value); Serial.print(" "); Serial.print(sensor_2_Value); Serial.print(" "); Serial.print(sensor_3_Value); Serial.print(" "); Serial.print(sensor_4_Value); Serial.print(" "); Serial.print(def1); Serial.print(" "); Serial.println(def2); //update servo angle myservo1.write(pos1); myservo2.write(pos2); }

Now I need to modify the code to work on the AtTiny44. In order to program the AtTiny44 with Arduino code you need to install the Tiny for Arduino. Download the attiny-ide-1.6.x ZIP file and install according to the tutorial in the High-Low link

The code for operating a servo motor with the AtTiny44 Chip is a bit different. Instead of using the regular servo.h library I used the SoftwareServo.h. After downloading the .zip file I opened the Sketch menu->Include Library->Add .ZIP Library and browsed to the downloaded zip file.

When using the SoftwareServo library you need to also use the SoftwareServo::refresh() function. This is the Code for the AtTiny44.

//Or Shoval //fablabil //The aMazing Maze - AtTiny44 code #include <SoftwareServo.h> #define X1 A0 #define X2 A1 #define Y1 A2 #define Y2 A3 SoftwareServo myservo_X; // create servo object to control a servo SoftwareServo myservo_Y; // create servo object to control a servo int X1_val=0, X2_val=0, Y1_val=0, Y2_val=0; int X_def, Y_def, X_pos, Y_pos; void setup() { myservo_X.attach(6); // X Axis Servo on pin 6 myservo_Y.attach(7); // Y Axis Servo on pin 7 pinMode(X1, INPUT); // X Axis controller on pins A0 A1 pinMode(X2, INPUT); pinMode(Y1, INPUT); // Y Axis controller on pins A2 A3 pinMode(Y2, INPUT); } void loop() { X1_val=analogRead(X1); //Reads from pin X2_val=analogRead(X2); //Reads from pin X_def = X2_val-X1_val; //calculates the diference X_pos = map(X_def, -400, 350, 60, 180); //changes the diference to angle for servo Y1_val=analogRead(Y1); //same for other controller Y2_val=analogRead(Y2); Y_def = Y2_val-Y1_val; Y_pos = map(Y_def, -350, 350, 30, 180); myservo_X.write(X_pos); //updates servos SoftwareServo::refresh(); myservo_Y.write(Y_pos); SoftwareServo::refresh(); }