Skip to content
Snippets Groups Projects
Commit 6494dc82 authored by Dan Stone's avatar Dan Stone
Browse files

vifdeo draft

parent ebdac5d8
No related branches found
No related tags found
No related merge requests found
Pipeline #398147 passed
......@@ -14,10 +14,17 @@ const int DRUM_FAST = 30;
const int DRUM_STOP = 0;
int potVal;
Servo esc;
const int HX_OUT_PIN = D4;
const int HX_SCK_PIN = D5;
void setup() {
enum HX_MODE { NONE, DIFF_10Hz, TEMP_40Hz, DIFF_40Hz};
const byte HX_MODE = DIFF_40Hz;
void setup() {
pinMode(HX_SCK_PIN, OUTPUT);
pinMode(HX_OUT_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(WASH_BUTTON_PIN, INPUT_PULLUP);
pinMode(DRY_BUTTON_PIN, INPUT_PULLUP);
......@@ -34,6 +41,7 @@ void setup() {
void loop() {
// Wait for the wash button press
Serial.println(readHX());
if (digitalRead(WASH_BUTTON_PIN) == LOW) {
// Check the water level and lid status
if (digitalRead(WATER_SENSOR_PIN) == HIGH && digitalRead(LID_SENSOR_PIN) == LOW) {
......@@ -117,3 +125,32 @@ void loop() {
}
unsigned long readHX() {
// pulse clock line to start a reading
for (char i = 0; i < HX_MODE; i++) {
digitalWrite(HX_SCK_PIN, HIGH);
digitalWrite(HX_SCK_PIN, LOW);
}
// wait for the reading to finish
while (digitalRead(HX_OUT_PIN)) {}
// read the 24-bit pressure as 3 bytes using SPI
byte data[3];
for (byte j = 3; j--;) {
data[j] = shiftIn(HX_OUT_PIN, HX_SCK_PIN, MSBFIRST);
}
data[2] ^= 0x80; // see note
// shift the 3 bytes into a large integer
long result;
result += (long)data[2] << 16;
result += (long)data[1] << 8;
result += (long)data[0];
return result;
}
docs/projects/Plate/watercap1.jpg

33.5 KiB

docs/projects/Plate/watercap2.jpg

53.2 KiB

docs/projects/Plate/watercap3.jpg

20.3 KiB

File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment