![]() ![]() If desired, print output to serial monitor for debugging If the puzzle had been solved, but now the meters are no longer correct If we get this far and allGaugesCorrect is still true, every value must have been within accepted toleranceĭigitalWrite(relayPin, HIGH) // Turn on the solenoid switchĭigitalWrite(relayPin, LOW) // Turn off the solenoid switch Set the output pin to control the relay when the puzzle is solved 50Hz provides 20ms standard servo phase length Supported baud rates are 100kHz, 400kHz, and 1000kHz Initialise I2C interface used for the PCA9685 PWM controller Serial.println("Compiled: " _DATE_ ", " _TIME_) Print some useful debug output - the filename and compilation time Start the serial connection (used for debugging) These will be converted to 16-bit PWM values in the range (0-4096) Output values represent gauge angle from -90 to 90 10-bit input values from the ADC have values in the range (0-1023) Helper class for calculating correct PWM values for angles etc. The PCA9685 controller will send values to servos How much tolerance either side of target will we allow and still consider value as correct? ![]() 90 = min (extreme counter-clockwise), 0 = midpoint, -90 = max (extreme-clockwise)Ĭonst int8_t targetValues = Positive angles rotate the servo clockwise BUT we're viewing gauges from the front, so The angle (-90 - 90) which each meter needs to be set to to solve the puzzle This pin will be written HIGH when the puzzle is solved for temporary release of solenoid lock To read analog inputs, we need to use a GPIO pin that supports analogRead (i.e. PCA9685 16-channel PWM controller used to control the servo gauges Wire library used for I2C communication * is energised which could release a maglock etc. * When all gauge needles are pointing to the correct pressure (within allowed tolerance), a relay * Players use the lever valves to adjust the pressure value displayed on each of the gauges * - output gauges (using servo motors on a 3D printed gauge indicator) * - input valves (using an LED and LDR either side of a plumbing lever) * This puzzle demonstrates a typical "plumbing" escape room puzzle that makes use of: * Valves and Gauges Puzzle, Copyright (c) 2022 Playful Technology Any guidance in getting back on track would be much appreciated. Unfortunately, when saving, I get multiple error messages for PCA9685. A few months ago I uploaded this code just fine, today I made a quick change from the output being a solenoid switch instead of a magnetic lock. I have reached out to him via Patreon but am also seeking assistance here. This makes the linker happy and allows your program to build.I need assistance with code I am slightly modifying from Alistair Atchison. the program file that contains your start and loop functions). The magic thing to know is that if any of your libraries use Wire.h or SPI.h you must Include them in the main source file (i.e. It’s one of those horrible situations where you have to know the “magic” trick to make it work. ![]() I’ve had this before, it is very frustrating. The compiler kept complaining about the Wire.h and SPI.h libraries not being available. I’d added the AdaFruit libraries and at that point my program broke. I’ve been creating a “Connected Little Boxes” driver for the BME280 environmental sensor (a personal favourite of mine). I hardly ever use them personally, I rely on people much cleverer than me to create libraries that I can use to talk to the hardware I want to use. They’re used by programs to communicate with devices over the I2C and SPI busses. The Wire.h and SPI.h Arduino libraries are kind of important. ![]()
0 Comments
Leave a Reply. |