W3
This week, we mainly focus on the collaborative puzzle. These 2 parts are separately put in 2 rooms. And players’ ultimate goal is to press the right blocks in 2 rooms in a correct sequence. But they cannot yell out loud. So it becomes another puzzle for them to figure out how to communicate with each other.
And to make it a little bit harder, we re-align all the texts. These are the paper prototype of this collaborative puzzle.
This is the Arduino version of it. Currently, it is only a 4 button version. But it should not be too hard to further develop it.
Then, we test whether the weight measuring sensor which we are going to use in the previous water puzzle.
This is the testing code. And it can weigh the objects under 5kg precisely.
#include <Q2HX711.h> const byte hx711_data_pin = 3; const byte hx711_clock_pin = 4; float y1 = 20.0; // calibrated mass to be added long x1 = 0L; long x0 = 0L; float avg_size = 10.0; // amount of averages for each mass measurement #define puzzelSolved 25.00 Q2HX711 hx711(hx711_data_pin, hx711_clock_pin); // prep hx711 void setup() { Serial.begin(9600); // prepare serial port delay(1000); // allow load cell and hx711 to settle // tare procedure for (int ii=0;ii<int(avg_size);ii++){ delay(10); x0+=hx711.read(); } x0/=long(avg_size); Serial.println("Add Calibrated Mass"); // calibration procedure (mass should be added equal to y1) int ii = 1; while(true){ if (hx711.read()<x0+10000){ } else { ii++; delay(2000); for (int jj=0;jj<int(avg_size);jj++){ x1+=hx711.read(); } x1/=long(avg_size); break; } } Serial.println("Calibration Complete"); } void loop() { // averaging reading long reading = 0; for (int jj=0;jj<int(avg_size);jj++){ reading+=hx711.read(); } reading/=long(avg_size); // calculating mass based on calibration and linear fit float ratio_1 = (float) (reading-x0); float ratio_2 = (float) (x1-x0); float ratio = ratio_1/ratio_2; float mass = y1*ratio; Serial.print("Raw: "); Serial.print(reading); Serial.print(", "); Serial.println(mass); if(mass >= puzzelSolved){ Serial.println("Puzzel Solved!"); } }