# Final Project


My project is a **vegetable washing machine** 


![](../presentation.png)


<iframe width="560" height="315" src=../../presentation.mp4 frameborder="0" allowfullscreen></iframe>  


## Research
 What will it do?

 **Goal is to create a  kitchen appliance that can wash and dry greens and  other vegetables via a pre set cycle both saving time (and potentially water)**

**Who's done what beforehand?**

So far I only found limited similar project within the fab academy community and a few outside. 

Fab Academy projects

1) [here](https://fab.cba.mit.edu/classes/863.13/people/jfduval/final.html)


Outside of fab academy:

1. I like the automated spinning salad dryer that the You Tuber The Practical Engineer designed 

<iframe width="560" height="315" src="https://www.youtube.com/embed/hfGojmXrGfc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

I think that he has a good spinner design and using this approach can allow me to allow users to put in 
any colander they wish.

2. Commercial solution are mainly ultrasonic, manual or focused on drying (salad spinners)

[Here](https://www.amazon.com/dp/B0BCVW1DPR?pd_rd_i=B0BCVW1DPR&pf_rd_p=b000e0a0-9e93-480f-bf78-a83c8136dfcb&pf_rd_r=SXKKN0NRSWW8SSBCYA6G&pd_rd_wg=yaMUE&pd_rd_w=RtpxZ&pd_rd_r=91c7961a-a2a2-4e3e-a877-a44317f81a64) are some examples 

![](../projects/competitive1.jpg)

![](../projects/competitive2.jpg)

![](../projects/competitive3.jpg)

**What will you design?**
I will design all aspect of the project with 4 major components 

1) The box / frame  of the machine and water reservoir 

2) The spinning mechanism    

3) The machine lid and water dispensing mechanism       

4) Control board electronics - main board, pump breakout board, motor breakout board, button breakout board 

**What materials and components will be used?**

The main materials are 
1) T Rails + Plexiglass 

2) 3D print filament - TPU, PLA and XTC3D finishing resin 

3) Electronic components and PCB boards, motor/ESC and pump 

4) Molding plastic / rubber 

Below is a full BOM

**Where will come from?**

Most are either provided by lab, purchased from Digi key or Amazon 

**How much will they cost?**

![](../projects/BOM.jpg)

**What parts and systems will be made?**

Washbasin/box/frame, drain/skirt, spinning plate, lid, water reservoir, electronics boards. 

Only things not made are:
Motor + ESC, pump, salad spinner bowl, water tube, sprinkler head, power supply 

**What processes will be used?**
- 3D print 
- Laser cutting 
- PCB Board milling 
- Molding and casting / resin 
- System integration 

**What questions need to be answered?**

- Spinning mechanism - chain/band vs. direct drive (already answered)
- Frame materials - (already answered - TRail )
- Water drainage approach - TPU printed sloped base 

**How will it be evaluated?**

- does it wash and clean greens / veggies 

**Under what license is the project** 

The project is published under the 
[Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/)



## Project description 

![VMS SKETCH](../images/imagW1/VMS06.jpeg){: style="height:360px;width:720px"}

![Veg Washing Machine](../images/Finalproject/VWMSKETCHV1.jpg){: style="height:300px;width:300px"}


Here is a first cut at the base:

![Base](../images/Finalproject/2basesetup.jpg)

**There are 4 main parts to the appliance**

1. Water reservoir 

2. Main container (Wash basin)- base is designed to have a gravity fed drain

3. Lid with build in sprinkler 

4. Vegetable holding bowel that sites in the Wash basin and spins to dry 

**There are 2 Motor/pump used**

1. Water pump to move water from reservoir to sprinkler head 

2. Motor to spin Vegetable bowel 

**There are 2 potential sensors**

1. Lid sensor - stop operation if lid is open mid cycle 

2. Water level sensor to alert if reservoir is empty 

**Microcontroller usage**

1. Control sequencing of pumps / motors 

2. Interrupt operation if sensor is triggered 

3. Manage GUI 

**GUI**

1. Button that allow user to start cycle 

- Wash only

- Dry only

- Wash/dry

2. Announce alerts (ready/water empty/finished)


Here is a another view of the merging design 

![Bottom](../images/Finalproject/2baseupview.jpg)



## Project: Align parts to Fab Academy weekly topics  


 
| Weekly topics      | Parts |
| ----------- | ----------- |
| Computer controlled cutting | Outbox / wash basin holder  |
| Electronics production | Controller, motor ESC, Sensors  |
| 3D Scanning and printing | Motor housing, water connectors, sprinkler head, sproket/chain for motor drive|
| Electronics design | sensors / controller board / Motor ESC |
| Computer controlled machining |   Controller board  |
| Embedded programming | Cycle design / User input |
| Molding and casting | Drain / Spinning plate  |
| Input devices | GUI buttons / Sensors |
| Output devices | Screen |
 


**Key component breakdown**

Wash basin and lid  -  Laser cut plexiglass  

Outer box -  T-rails 

Water reservoir holder - 3D print  (PLA)

Electronic housing - 3D print box (PLA) / Laser cut cover 

Sprinkler  - 3D print (PLA)

Box base/drain/motor protective skirt - 3D print (TPU)

Controller board / Pump driver / button and sensor break out board - PCB milling 

Sensors - 1) Lid sensor 2) Water level sensor 

Machine feet - Molding and casting 

Power supply box - Laser cut plexiglass 

Purchased - ESC, motor, pump, power supply, water bottle/reservoir, spinner bowel 


## Project: Build / system overview 

My build split into the physical build and the electronics with notation of pins connected to each breakout board. 


![](../projects/build.jpg)



## Box: Frame build 

I decided to use a similar method that we used in machine week of T rails for the outside frame and then 1/4 inch plexiglass for the water tight box  and water reservoir  that are both mounted in side the frame 

![](../projects/Frame/B11.jpg)

Using a chop saw and aluminum cutting blade I got all the pieces ready for assembly 


![](../projects/Frame/B12.jpg)

![](../projects/Frame/B13.jpg)

3D printed bracket will be key together with T Rail    M5 screws and bolts 

![](../projects/Frame/B14.jpg)

You can see the bracket in action 

![](../projects/Frame/B15.jpg)

Assembly of the box was straight forward

![](../projects/Frame/B16.jpg)

COnfirming the size with spinning plate and bowel 

![](../projects/Frame/B17.jpg)

To make the water proof interior  box I decided to use 1/4 plexiglass that I will laser cut and then use cement and possible silicon to water proof 

![](../projects/Frame/B2.jpg)

I used the big epilog laser at the fab lab. Setting for 1/4 inch plexi glass was 100% power and 10% speed. 

![](../projects/Frame/B21.jpg)

I first cut and assembled a cardboard set to make sure it all worked well as I only have 1 sheet of plexiglass. I made sure the mounting holes for the motor were positioned correctly 


![](../projects/Frame/B24.jpg)

Now it was time to cut the plexiglass 

![](../projects/Frame/B22.jpg) 

4 of the five panels cut fine on the left side but the right side of the laser did not cut through. I refocused the laser on the right side and ran the cut for the 5th panel with 3 passes. Discussing with the person in charge of maintaining the laser it seems like they were having a focus issue they were working through. 


![](../projects/Frame/B23.jpg)

Once they were all cut the box fit nicely into the frame 

![](../projects/Frame/B25.jpg)

Now I needed to glue it together and so I used a plexiglass cement with the following [data sheet](https://assemblyadhesives.com/SDS/WELD-ON%204SC%20Low%20VOC%20Solvent%20Cement%20for%20Acrylic%20US_EN_v2.pdf)

I only did used it in the garage with the car door open to ensure enough ventilation 

![](../projects/Frame/B3.jpg)

This applicator was very useful 


![](../projects/Frame/B31.jpg)

I used clamps to keep it together until the cement dried 
 

![](../projects/Frame/B34.jpg)


## Box: Lid

The lid assemble was a smaller version of the box assembly with an addition of a hinge and a Door Lift Stay Support Hinge Damper [](https://www.amazon.com/gp/product/B01N5GQZK2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&th=1) 

They were both easy to mount onto the TRails 

![](../projects/Frame/LID01.jpg)

You can see the lid stay open 

![](../projects/Frame/LID1.jpg)

Now it is time to fabricate the internal plexiglass box including screw holes to mount the sprinkler head 

![](../projects/Frame/LID0.jpg)

First I cut out the shape from cardboard to make sure it would fit 

![](../projects/Frame/LID11.jpg)

Looks good

![](../projects/Frame/LID12.jpg)

Now cut the plexiglass 

![](../projects/Frame/LID13.jpg)

Clean cut 

![](../projects/Frame/LID2.jpg)

Use the clamps and cement. 

![](../projects/Frame/LID14.jpg)

I added holes to allow it to be secured to the T Rail 

![](../projects/Frame/LID15.jpg)


![](../projects/Frame/LID16.jpg)

Here you can see the water pump mounted and another hole for the water tube to go into the lid 

![](../projects/Frame/LID17.jpg)

And here it is with the spinkler mounted. 

![](../projects/Plate/sprinkler72.jpg)

## Box: Spinning plate 

First I set up some user parameters I will use in sizing the spinning plate and it base 

![User Parameters](../images/ImagW2/GraphicApps/40platebase1.jpg)

Now I made a round leg for the plate to sit on 

![Leg sketch](../images/ImagW2/GraphicApps/40platebase2.jpg)

To create the shape of the base I will create a new sketch on the top of the base leg. I then
create a circle and replicate it using the circular pattern tool followed but a cut.

![Pattern](../images/ImagW2/GraphicApps/40platebase3.jpg)

![Cut](../images/ImagW2/GraphicApps/40platebase4.jpg)

I then sketched on top again and created a circle to create the plate itself 

![Plate](../images/ImagW2/GraphicApps/40platebase5.jpg)

Here I made a mistake as I did not select the whole plate and where the handy timeline 
tool come into play

![Plate](../images/ImagW2/GraphicApps/40platebase6correction.jpg)

And we are back on track. I wanted to create a downward facing lip in order to provide some water 
protection for the spinning mechanism during the dry cycle.

To do this I am going to draw a sketch of the lip and have it rotate around the plate center axis

Start with sketch

![Plate lip](../images/ImagW2/GraphicApps/40platebase7lip.jpg)

Then used the revolve to create the lip and set it to join the plate base.

![Plate lip](../images/ImagW2/GraphicApps/40platebase8revolve.jpg)

and there you go a first cut at the base plate 

![Plate](../images/ImagW2/GraphicApps/40platebase9.jpg)



## Box: 3D printing the plate

I started off by printing a test model aprox 50 of the size 


![](../projects/Plate/Plate1.jpg)

After 5 hours, here it is:

When I put it up to the salad spinner bowel I have it seemed to me that the overall size of the machine \
can be much smaller then I originaly planned. 

I think a good approach is the max the size of the plate I can print on the MK3S

![](../projects/Plate/mk3s.jpg)

The original size had a 320mm diameter but I am going to resize it to a 200mm diameter 

![](../projects/Plate/Plate1.jpg)

I used the scale command leaving the Z as is and scaling the X and Y to 62.5% of the original 

Here it is printed

![](../projects/Plate/Plate0.jpg)


Now that I liked that size in order to make every thing work in fusion I had to go back and resize the plate in fusion to match.

![](../projects/Plate/Resize1.jpg)

![](../projects/Plate/Resize2.jpg)

Now we are ready to create the bowel holders


## Box: Out runner motor mounting 

See below for discussion on the motor drive selection and decision to move to a direct drive mount on a outrunner motor. I am used a D3548.

![](../images/Finalproject/d3548.jpg)

I found a model of the motor I am planning to use on GrabCad 

![](../projects/Plate/Motor1.jpg)

This an out runner and I would like to cut its shape into the bottom of the spinner to test a direct drive

As the CAD was made of many many pieces it was easier to create a similar shaped body. I traced the profile and used the revolved function to create an new body 
s
![](../projects/Plate/motor2.jpg)

![](../projects/Plate/Motor3.jpg)

Now I used the combined command to cut this out of the base of the plate for a direct mount 


![](../projects/Plate/Motor4.jpg)

Creating a nice mount for the plate - i also think i do not need the spinner base any more. 

![](../projects/Plate/Motor5.jpg)

I knew there was going to be a lot of stress on this when the plate spins so I filet everything I could to strength the joints.

 ![](../projects/Plate/Motor51.jpg)

Got it ready to 3D print 


![](../projects/Plate/Plate3.jpg)




## Box: Bowel holder 

Initially I printed a basic arm to get a physical sense of the shape and size 

![](../images/Finalproject/arm11.jpg)

After have a basic shape in the early design I needed to have a pieces that was help in place on the plate. 

I started by adding a wedge at the plate level and tweaking the shape but it was very unstable 

![](../images/Finalproject/arm12.jpg)


I decided to use to features to do that. 

1) Redesign the base to snugly fit on the shape of the plate 


![](../images/Finalproject/arm1.jpg)

![](../images/Finalproject/arm2.jpg)

2) Create a threaded rod on the bottom and print a nut that will hold the are in place 

![](../images/Finalproject/arm3.jpg)


![](../images/Finalproject/arm5.jpg)


![](../images/Finalproject/arm4.jpg)

![](../images/Finalproject/arm5.jpg)

![](../images/Finalproject/ARM6.jpg)

Here is it assembled 

![](../projects/Plate/holders.jpg)

and now to test 

<iframe width="560" height="315" src=../../images/Finalproject/Bowlfly.mp4 frameborder="0" allowfullscreen></iframe>  


When discussing my progress with my local instructure Dr. Fagan, the feedback I got is the need to have a screw to hold the plate to the motor shaft 

![](../projects/Plate/Motor6.jpg)


![](../projects/Plate/Motor61.jpg)

I decided to put in a pocket to hold the bolt 

![](../projects/Plate/Motor62.jpg)

Then a screw hole all the way to motor shaft 

![](../projects/Plate/Motor63.jpg)

Once the design looked goo it is time to reprint the plate.

<iframe width="560" height="315" src=../../projects/Plate/newplate.mp4 frameborder="0" allowfullscreen></iframe>  

After 13 hours we have a new plate 

![](../projects/Plate/Motor65.jpg)

And the screw fit with the bolt holding it in place.

![](../projects/Plate/Motor66.jpg)


## Box: Bowel hooks 

To ensure the spinner bowel does not fly out I need to add a hooks that will connect to the top of the plate arms and hols the bowel in place 

I decided to go with a simple 3D printed design 

![](../projects/Plate/Hook1.jpg)

Got them 3D printed 

![](../projects/Plate/Hook3.jpg)

And istalled 
![](../projects/Plate/Hook4.jpg)

After some testing i found out that the hooks allowed the bowel to have too much motion that got out of hand when the RPM went up. 

So I redesign the hooks to have a tighter fit with the bowel.


![](../projects/Plate/Hook6.jpg)

I also replaced the bolt with zip ties as the bolts came loose over time. These 2 changes got the bowel in with a tight fit that works well.   

![](../projects/Plate/Hook7.jpg)

## Box: Water reservoir    

I had decided to use a square water container as the water reservoir 

![](../projects/Frame/Water0.jpg)

I wanted to build a holder that will attached ot the back of the frame and hold the water bottle

![](../projects/Frame/Water1.jpg)

I added strong support to try and only connect it on the bottom rail 

![](../projects/Frame/Water2.jpg)

And we are ready to print 

![](../projects/Frame/Water3.jpg)



<iframe width="560" height="315" src=../../projects/Frame/Waterholdprint.mp4 frameborder="0" allowfullscreen></iframe>  

Looks like a good fit 

![](../projects/Frame/Water4.jpg)

3 M5 screws secure the holder to the frame 

![](../projects/Frame/Water5.jpg)

And here it is mounted and full of water  

![](../projects/Frame/Water6.jpg)

## Box: Water skirt and drainage 

My plan for water profing the motor and providing a gravity based drainage is to create a sloped rubber base for box with a rasied skirt. 

The skirt will go between the motor and the plate lip thus stopping any water for getting into the motor. 

I started with a fusion design 

![](../projects/Plate/waterskirt.jpg)

Added the drainage slopes 

![](../projects/Plate/waterskirt2.jpg)

Unfortunately my Prusa is too small to print the whole things at one so I had to cut it to be printed in parts 

![](../projects/Plate/waterskirt3.jpg)

![](../projects/Plate/waterskirt4.jpg)

Printing in TPU is slow if you do not want stringing It is a 23 hour print !!

![](../projects/Plate/waterskirt5.jpg)

Here it is in progress


![](../projects/Plate/waterskirt6.jpg)

Fully printed

![](../projects/Plate/waterskirt61.jpg)


Printing went well but remove the print from the plate was nearly impossible and ended up destrying the plate. 

This did not happen to me in smaller prints I did but after going back and reviewing the Prusa [materials guide](https://help.prusa3d.com/materials#_ga=2.250429327.883239654.1684193727-1420350994.1684193726) as well as reading some user form it seems that I missed the need to either 
1) Add a layer of glue stick 
2) Put down blue tape the print on 

![](../projects/Plate/waterskirt7.jpg)

Now I have all the parts printed time to check fit in the box 

![](../projects/Plate/waterskirt71.jpg)

After reivew it seems that Loctite 406 is a recommended glu for TPU so that is what I am going to use to turn these 3 parts into 1. But before I do that I can see 2 things that I need to add and adjust:

1. Add a drain connection

2. Expand the neck to fit the screw that I added to the plate 

![](../projects/Plate/waterskirt72.jpg)

I created a drain connection / edge 

![](../projects/Plate/waterskirt8.jpg)

Ready to print 

![](../projects/Plate/waterskirt81.jpg)

Here it is 

![](../projects/Plate/waterskirt82.jpg)

I also cut the next of the skirt to fit the new screw placemen.

I needed to connect the different parts of the bottom into one 

![](../projects/Plate/waterskirt833.jpg)

Some reaserch showed that for TPU  loctite 406 is a good option. 

![](../projects/Plate/waterskirt83.jpg)

I used ducktape on the bottom hold the pieces together until the glue dried  

![](../projects/Plate/waterskirt831.jpg)


![](../projects/Plate/waterskirt832.jpg)


after some more tests that drain was working well. 

<iframe width="560" height="315" src=../../projects/Plate/draintest.mp4 frameborder="0" allowfullscreen></iframe>  

The drain worked well but i still got a lot of water under the TPU base from all the side.

![](../projects/Plate/waterskirt84.jpg)

I decided to use some clear silicon to waterproof the edges and funnel all the water into the drain 

![](../projects/Plate/waterskirt841.jpg)

And we are ready to go 

![](../projects/Plate/waterskirt842.jpg)

Unfortunately over the next 2 days the caulk did not cure and was a mess. I ended up taking off the base, cleaning out as much of the caulk as I could and resealing it with silicon which cured much better.

![](../projects/Plate/waterskirt9.jpg)


## Box: Feet 

I used molding and casting to make mushroom shaped feet for the machine. 

Here you can see the design 

![](../images/imagW13/M6.jpg)

Milled out of wax 

![](../images/imagW13/m72.jpg)

Running a roughing pass followed by finishing pass 

![](../projects/Frame/feetruns.jpg)

Cast a rubber mold 

![](../images/imagW13/M88.jpg)


Plastic legs ready to go 

![](../images/imagW13/M96.jpg)


And here they are mounted 

![](../projects/Frame/feet.jpg)

## Box: Decorative design    

To help hide the silicon on the bottom of the box I found a garden silhouette.

![](../projects/Frame/gardenview1.jpg)

For the side I added a square cut out for the drain 

![](../projects/Frame/gardenview2.jpg)


I then cut it out of 1/8 inch plexiglass 

![](../projects/Frame/gardenview3.jpg)

and then I mounted them which worked out well

Here is the front 

![](../projects/Frame/gardenview4.jpg)

and the side

![](../projects/Frame/gardenview5.jpg)

## Box: Sprinkler head 

The machine needs a spinkler head and so started up fusion. It will be secured to the LID from the inside and will be feed by the 3/8 hose coming in from the pump.

![](../projects/Plate/sprinkler1.jpg)

I used a sphear with a pattern of holes 

![](../projects/Plate/sprinkler2.jpg)

![](../projects/Plate/sprinkler3.jpg)

Used fillet to fortify the connection 

![](../projects/Plate/sprinkler4.jpg)

I ensured the water flow path was open 

![](../projects/Plate/sprinkler5.jpg)

I ended up making the walls too thin and so it was very brittle during the print 

![](../projects/Plate/sprinkler51.jpg)

I added more fortification and a square peg on each side I will use to mount into the lid 

![](../projects/Plate/sprinkler6.jpg)

Print went well 

![](../projects/Plate/sprinkler61.jpg)

But agian as I remove the support it was very brittle 

![](../projects/Plate/sprinkler62.jpg)

I went through a number of priting settings to try and get this working as consistently the incoming connection kept have water leaking. 

![](../projects/Plate/sprinkler71.jpg)

I fortified the design, moved the square overhand to cover the bend of the pipe and reduced the printing layers to 0.15mm.  I also added 2 screw holes to mount onto lid.

![](../projects/Plate/sprinkler7.jpg)

And here is the final version 

![](../projects/Plate/sprinkler72.jpg)

## Motor: Spinning Motor set up 

For my vegetable washing machine I initially purchased 3 parts: 

1. 12-24V power supply 

2. 12-24V / 80W DC Motor

3. 12-24V Motor ESC 

![Motor](../images/imagW9/MOT1.jpg)

The ESC is controlled by a Potentiometer and once I got them connected they all worked well together. When 
I turned the knob the motor speed changed. 

I want to be able to control the ESC with the microcontroller so I can adjust the speed for the wash and 
dry cycles. 

First I need to understand how the Potentiometer works with the ESC. There is a plug with power and ground on either side 
the middle wire voltage change based on the potentiometer position ranging from 0.5V to 3.6V.

![Motor](../images/imagW9/MOT2.jpg)

![Motor](../images/imagW9/MOT3.jpg)


I was not sure how to approach this, my initial plan was to use 2 resistors and some relays to switch between 
2 speeds. After reviewing Dr. Gershenfeld class and reflecting on the transistor discussion I came up with the 
idea of used a transistor to replace the potentiometer and a capacitor to smooth out the control signal from the microcontroller. 

I ran this by our local instructor Mr. Dubick  and my classmate Adam Durrett that have strong electronics background and they 
agreed it should work!!!


## Motor: control circuit  design

I decided the set up the board to control both the motor the spin the Vesgtable Basket as well as the Water pump even 
though my focus this week was on the motor. 

For each I would have a control signal come in from the micro controller on the main board. I would change the frequency of 
the signal the change the speed, putting a capacitor on the line would smooth it and would replace the line in with the 
potentiometer.

![Circuit](../images/imagW9/PCB1.jpg)

Not to get things a bit more organized. It is a relatively simple circuit 

![Circuit](../images/imagW9/PCB2.jpg)

Not pushed it to the 2B Board and started tracing 

![Circuit](../images/imagW9/PCB3.jpg)


## Motor: control PCB design 

Pushed to the 3D board get ready to mill

![Circuit](../images/imagW9/PCB4.jpg)

![Circuit](../images/imagW9/PCB5.jpg)

When I reviewing the milling it was very tight due to the tracing. 

![Circuit](../images/imagW9/PCB8.jpg)

![Circuit](../images/imagW9/PCB6.jpg)

![Circuit](../images/imagW9/PCB81.jpg)

I reviewed the connectors and saw that by switch a few things around I could simplify the tracing 
and provide more space between traces to make for easier milling 

![Circuit](../images/imagW9/pcb7.jpg)

![Circuit](../images/imagW9/PCB82.jpg)



## Motor: control board milling 

Now I was ready to mill. I used the same set up with my Genmitsu 3020-Pro-Max from last week [here](https://fabacademy.org/2023/labs/charlotte/students/dan-stone/assignments/week09/#tool-path-set-up)

The tool path looked good 

![Mill](../images/imagW9/Mill1.jpg)

Got to cutting using a 0.8mm end mill 

![Mill](../images/imagW9/Mill2.jpg)

![Mill](../images/imagW9/Mill21.jpg)

I deburred and washed the board 

![Mill](../images/imagW9/Mill3.jpg)

Now we are ready to stuff and solder 

![Mill](../images/imagW9/Mill4.jpg)

Here are all the components 

![Mill](../images/imagW9/Mill5.jpg)

And we are ready to test 

![Mill](../images/imagW9/Mill6.jpg)

After stripping the connectors  on a number of boards and after rethinking the machine design I decided the break this board into 
2 one for the motor and one for the pump. 

I also increased the side of my traces to 30mil and replace the pad for my connector with A better connector from 
the fab library 

I started testing the board and it seemed like now matter what I did the Sources and Drain of the transistor was always connected. 

I checked for shorts, I added a pull down resistor to ensure the gate is 0 and not joy. The source and drain are connected. 

I went back to the lab and got another 2 transisotr (the lab only had 3 of them) and they all seemed to do that same. 

I reviewed them with my instructure and fellow student who is an electrical engineer and they could not find why it was 
acting this way other then it may be a bad batch of transistors. We put in an order for some more and for now this part 
of the project is on hold until the arrive. 

While this effort was on hold we completed Machine Building week and that changed my mind on how to set up the motor. 

## Motor: Moving to direct drive

After a success full machine week I got appreciation for the out runner motor capabilities and so I decided to try and mount the plat directly on a out runner motor and see if that work. 

I had a outrunner motor in the lab that was bigger then the one we used in machine week and I think would work well.

Here is it spec:

![](../images/Finalproject/motorspec.jpg)

I coupled that with a large ESC with the following [user manual](https://www.rcelectricparts.com/classic-esc-user-guide.html#03)


I decided to test the motor using a potentiometer to control the speed so I can find out what are good speeds for my final project. 

I set up the mounting bracket on the motor 

![](../images/Finalproject/motor1.jpg)

I used a scrap piece of wood to mount the motor onto the frame

![](../images/Finalproject/motor2.jpg)

## Motor: ESC wiring 

Power: The motor will connect directly to the 0-24V power supply I have 

![](../images/Finalproject/motor3.jpg)

ESC control: the ESC will be connect to the BOD via 3 wires: 5V / GND / and PMW from pin D0


## Motor: Arduino code for potentiometer control 

I wired a potentiometer to analog input A1 and the 5V/GND and ran the following code: 

```c
# include <Servo.h>

// create a Servo object to control the ESC
Servo esc;

int potVal;

void setup() {
  // set the baud rate for serial communication
  Serial.begin(9600);

  // attach the ESC to pin 9
   esc.attach(9, 1000, 2000); // the second and third parameters are the minimum and maximum pulse widths
  int potVal;
 esc.write(0); //arm ESP
 delay(1000);
}

void loop() {
  // set the speed to half of the maximum (which is 180)
  
 potVal = analogRead(A1); // read input from potentiometer.

int speed  = map(potVal,0, 1023, 0, 180); // maps potentiometer values to PWM val

  // send the speed to the ESC
  esc.write(speed);

   // print the speed to the serial monitor
  Serial.print("Speed: ");
  Serial.println(speed);
 
  // pause for a moment before starting again
}
```

This will both printout in the serial monitor the speed variable so I can see the which value I would want to use in the final code. 

## Motor: First time ESC calibration 

When you plug the ESC in for the first time it need to go via a calibration process. 
1) You put it to full throttle  
2) Connect motor to power 
3) Move to zero throttle

You can see the motor first run 

<iframe width="560" height="315" src=../../images/Finalproject/ESCcalib.mp4 frameborder="0" allowfullscreen></iframe>  


## Motor: speed test 

I mounted the plate on the motor and ran the motor

<iframe width="560" height="315" src=../../images/Finalproject/spiningplate.mp4 frameborder="0" allowfullscreen></iframe>  


I started moving the potentiometer while look at the serial monitor to see the speed. 

<iframe width="560" height="315" src=../../images/Finalproject/speed.mp4 frameborder="0" allowfullscreen></iframe>  

Answer is pretty straight forward. 

The lowest speed that will run is with the Servo Angle value of 24. 

A good increased speed for drying is 40. 

These will be the two value I will use in the cycles





## Electronics: New board - Moving to RO2040

After a while I decided to move to a working iwht th eRP2040 

I am going to follow the same break out board design and so I started to work on a schematic. I am planning to use 
4 pin wire to board connectors and 2 pin for the power as an alternative to the USBC.

![](../projects/Board/Newboard1.jpg)

I have the 2D Board set up 

![](../projects/Board/Newboard2.jpg)

Now we are ready to mill 

![](../projects/Board/Newboard3.jpg)

Here we are in action 

![](../projects/Board/Newboard4.jpg)


Board is ready 

![](../projects/Board/Newboard5.jpg)

The pad I was using were too big for the connector sockets I had

![](../projects/Board/Newboard6.jpg)

I replaced the connectors 

![](../projects/Board/Newboard61.jpg)

realigned the groupings by breakout board 

![](../projects/Board/Newboard62.jpg)

Layout is ready for tool path 

![](../projects/Board/Newboard63.jpg)

Looks good 

![](../projects/Board/Newboard64.jpg)


ready to mill 

![](../projects/Board/Newboard66.jpg)

A good pinout type map 

![](../projects/Board/Newboard7.jpg)



After working on the other breakout boards I had to comeback and redesign this main control board for 2 reasons:

1. connectors - I was committed to clean wiring and use off wire to board sockets. I had a much better map of the breakout board needs and connection and so I need a new foot print to set the sockets up correctly 

2. Shape - I started with the vegetable shapes and wanted to come back with a pepper shape 

I used the systems map at the top as a guide to which pins need to connect to each board. 

I created a new schematic 

![](../projects/Board/CBoard1.jpg)

Layout was pretty straight forward but had to use a jumper for GND to one of the sockets 

![](../projects/Board/CBoard2.jpg)

3D board ready to mill 

![](../projects/Board/CBoard3.jpg)

I had to adjust to spacing betweek the pads for the 0.5mm milling bit I have. 

![](../projects/Board/CBoard4.jpg)

I made the same mistake using the pads that are too big for the sockets 

![](../projects/Board/CBoard5.jpg)

A quick replacement to fit the sockets 

![](../projects/Board/CBoard6.jpg)

And we are ready to mill 

![](../projects/Board/CBoard61.jpg)

Here we go 

![](../projects/Board/CBoard62.jpg)

And we are ready to stuff and solder 

![](../projects/Board/CBoard63.jpg)

Board ready to go 

![](../projects/Board/CBoard64.jpg)

Sockets are working well 

![](../projects/Board/CBoard65.jpg)

## Electronics: Button/sensor breakout board 

To connected the control button, lid sensor and water level sensor I created a break out board. 

I started with a basic schematic 

![](../images/Finalproject/BB1.jpg)

I think routed the board and decided to make the board the shape of a carrot. 

![](../images/Finalproject/BB2.jpg)

I had to shorten the carrot so it fit on the PCB I had.

![](../images/Finalproject/BB3.jpg)

And now it is ready to mill 

![](../images/Finalproject/BB4.jpg)

Here we go 

![](../images/Finalproject/BB5.jpg)

No we just have to clean it up 

![](../images/Finalproject/BB6.jpg)


I got that parts soldered in and set up with the motor.  


I soldered the wire for the button as well as the 4 pin connector to the button board 

![](../images/Finalproject/BB7.jpg)


Now I needed to redesign this board for 2 reasons 

1. Add I2C connections for the water level sensor 

2. Added 2 sockets to connect to the main board for the buttons and lid and water sensor. 

Here is the new schematics 

![](../projects/Board/newbutton1.jpg)

New board layout and tracing 

![](../projects/Board/newbutton2.jpg)

Ready to mill 

![](../projects/Board/newbutton3.jpg)

Set up done 

![](../projects/Board/newbutton4.jpg)

New board ready to stuff and solder 

![](../projects/Board/newbutton5.jpg)

Here it is mounted in the box with all the sockets soldered in place 

![](../projects/Board/newbutton6.jpg)

## Electronics: Pump breakout board 

I initialy toughts this should be pretty traight forward. 

Breakout board would drive a relay with a GPIO from the main board that would be activated but the button push similar to the motor. The relay would connect the pump to the 12V power supply. 

![](../projects/pumpboard/P1.jpg)

I decided to use a mushroom design 

![](../projects/pumpboard/P2.jpg)

got it ready to cut 

![](../projects/pumpboard/P3.jpg)

![](../projects/pumpboard/P4.jpg)


I misjudged the size and so after overshotting 

![](../projects/pumpboard/P61.jpg)

I redesigned the board 

![](../projects/pumpboard/P5.jpg)


![](../projects/pumpboard/P6.jpg)

Got it cut 

![](../projects/pumpboard/P7.jpg)

Now it fit 

![](../projects/pumpboard/P71.jpg)

Got it stuffed and soldered 

![](../projects/pumpboard/P72.jpg)



When I pressed the button the motor turned byut instead of the rely switching to turn on the pump nothing happened.

I got out the multimeter and saw that when not connected to the relay the D1 pin  went up to 3.3V when I pressed the button but when connected to the relay it only went to 1.8V and the relay did not activate. 
 
I researched this I found out the RP2040 GPIO do not have enough current to drive  the relay so I needed to make a driver.

I found this basic driver schematic on the [raspberrypi forum](https://forums.raspberrypi.com//viewtopic.php?t=63578&p=470362#p470625)

![](../projects/pumpboard/Relaydriver1.jpg)

I only had through hole components to make this and so decided to make a through hole board for this. I never made one and so was interested to see how it worked.  

First I tested it on a breadboard to make sure it worked 

![](../projects/pumpboard/P73.jpg)


Updated the schematic to include the driver. 

![](../projects/pumpboard/P8.jpg)

Retraced everything 

![](../projects/pumpboard/P81.jpg)

Got it ready to mill 

![](../projects/pumpboard/P84.jpg)

Milling took a few attempts  as this was the first time I was using the drilling function and I kept setting the Z too low (this is a manual process on my mill) and the drill would break the trace 

![](../projects/pumpboard/P85.jpg)


I got a hang of the calibration needed and we have a board

![](../projects/pumpboard/P851.jpg)

Added components 

![](../projects/pumpboard/P852.jpg)

Soldered 

![](../projects/pumpboard/P853.jpg)

And we are ready to test

![](../projects/pumpboard/P854.jpg)

The test showed me that I ended up connected to the Normally open legs of the relay vs. the Normally closed and so the pump ran contently.  The mistake was due to my not flipping the components to the other side of the board for the drill through layout. 

I ended up cutting that trace with a knife and added a jumper which worked well. 

![](../projects/pumpboard/P855.jpg)

I also redesigned the board and will remill once if needed later 

![](../projects/pumpboard/P83.jpg)

![](../projects/pumpboard/P82.jpg)


Now we are ready to test it .... we have water flow!


<iframe width="560" height="315" src=../../projects/pumpboard/pumptest.mp4 frameborder="0" allowfullscreen></iframe>  

## Power supply 

I got this power supply from [amazon](https://www.amazon.com/gp/product/B08GFSVHLS/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1_) as I was not sure which motor pump i was going ot use initially the variable aspect of this power supply was useful. 

![](../projects/pumpboard/power1.jpg)

I then cut a box cover for it and added a power switch. 

![](../projects/Frame/powerbox1.jpg)


The power supply had not power switch so I added one which will be the on/off switch for the whole machine 

![](../projects/Frame/powerbox2.jpg)

And here it is assembled 

![](../projects/Frame/powerbox3.jpg)


## Electronics: System integration 

I decided to make a box that will mount on to the side of the machines and will have the control board and breakout board in it. 

![](../projects/Board/Box1.jpg)

I added screw holds for mounting the board / ESC and some holes for wires to come in and out 

![](../projects/Board/BOARDBOX1.jpg)

Ready to print 

![](../projects/Board/BOARDBOX2.jpg)

Added some M3 bolts to secure the boards 

![](../projects/Board/Box3.jpg)

It fits onto the side nicely 

![](../projects/Board/Box4.jpg)

This ended up a little too small and so I had to redo a bigger version. I also added slots to secure wires and screw holes for the cover 

![](../projects/Board/Box61.jpg)

Then cut the cover from plexiglass 

![](../projects/Board/Box62.jpg)

I then used a vinyl cutter to make labels 

![](../projects/Board/lables1.jpg)


![](../projects/Board/lables2.jpg)

quick cut on the cutter

![](../projects/Board/lables21.jpg)

Cut out the labels 

![](../projects/Board/lables3.jpg)

Some clean up 

![](../projects/Board/lables4.jpg)

Transfer tape 

![](../projects/Board/lables5.jpg)


![](../projects/Board/lables6.jpg)

Lable in place 


![](../projects/Board/lables7.jpg)


and here it is all integrated into one box

![](../projects/Board/integrated.jpg)


## Electronics: Sensors 

**Lid Sensor**

The open lid sensor is a simple mounted switch 

I used the M3 T nuts I had to mount the switch directly onto the frame. 

![](../projects/pumpboard/S1.jpg)

I used the casted plastic mushroom I casted from Molding and Casting week as the counter edge on the LID 

![](../projects/pumpboard/S12.jpg)

![](../projects/pumpboard/S13.jpg)

The wiring is run through the button break out board 

![](../projects/pumpboard/S14.jpg)

And here you can see it in action 


<iframe width="560" height="315" src=../../projects/pumpboard/openlid.mp4 frameborder="0" allowfullscreen></iframe>  

## Electronics: Water level sensor

I got a few of the following sensors off [Amazon](https://www.amazon.com/Digital-Barometric-Pressure-Controller-0-40KPa/dp/B07KNV8MM6/ref=asc_df_B07KNV8MM6/?tag=hyprod-20&linkCode=df0&hvadid=652711367439&hvpos=&hvnetw=g&hvrand=14152749531030453154&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9060248&hvtargid=pla-2064138829849&psc=1&gclid=CjwKCAjw1MajBhAcEiwAagW9MZCg0d33zEdap16ME273bfZya4pu-qdxR3aOl-s-AuyUNDDcdfNLiRoC2HEQAvD_BwE): 

![](../projects/pumpboard/S21.jpg)

Unfortunately there was not documentation or links on amazon to documentation. I used google lens to search for the picture of the sensor and found a good [tutorial](https://www.youtube.com/watch?v=NOTMb165jMU)

Turns out this is a HX710 

I got it wired into the I2C on the board and used the following test code to read the measurements.

```c
const int HX_OUT_PIN = D4;
const int HX_SCK_PIN = D5;

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);
  Serial.begin(9600);
}

void loop() {
  Serial.println(readHX());
}

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;
}
```

I then got it wired up 

![](../projects/pumpboard/S22.jpg)

I used some heat shrink to connect a air pump hose to the sensor tip 

![](../projects/pumpboard/S25.jpg)

![](../projects/pumpboard/S23.jpg)

And here it is ready to go into water reservoir 
![](../projects/pumpboard/S24.jpg)



and here it is in action as I drain the water reservoir


<iframe width="560" height="315" src=../../projects/pumpboard/S3.mp4 frameborder="0" allowfullscreen></iframe>  


## Code basic set up 

To keep this week in sync with my final project I decided to test a set up for the basic VMS functionality 
replacing the water pump and motor with LED and the sensors with buttons. 

Here is the functionality I was aiming for:



|  Button |  Label | FUnctionality  |
|---|---|---|
| Button 1  | Wash cycle  |   1. Check Lid / Water sensor -> 2. Turn on Water pump and motor for a set time | 
| Button 2  | Dry cycle  |  1. Check Lid -> 2. Turn on motor for a set time |   
|  Button 3 |   Total cycle |  1. Run Wash cycle -> 2. Run Dry cycle | 
|  Sensors |  If either sensor is triggered then stop and turn on error LED |   | 

Here is my updated code:

```c
// Define the pin numbers for the sensors and actuators
const int LED_PIN = 7;
const int WASH_BUTTON_PIN = 11;
const int DRY_BUTTON_PIN = 10;
const int FULL_BUTTON_PIN = 9;
const int WATER_SENSOR_PIN = 2;
const int LID_SENSOR_PIN = 3;
const int DRUM_PIN = 4;
const int WATER_PUMP_PIN = 5;

void setup() {
    Serial.begin(9600);
    pinMode(LED_PIN, OUTPUT);
    pinMode(WASH_BUTTON_PIN, INPUT);
    pinMode(DRY_BUTTON_PIN, INPUT);
    pinMode(FULL_BUTTON_PIN, INPUT);
    pinMode(WATER_SENSOR_PIN, INPUT);
    pinMode(LID_SENSOR_PIN, INPUT);
    pinMode(DRUM_PIN, OUTPUT);
    pinMode(WATER_PUMP_PIN, OUTPUT);
}

void loop() {
    // Wait for the wash button press
    if (digitalRead(WASH_BUTTON_PIN) == HIGH) {
        // Check the water level and lid status
        if (digitalRead(WATER_SENSOR_PIN) == LOW && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            digitalWrite(DRUM_PIN, HIGH);
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(600);
            digitalWrite(DRUM_PIN, LOW);
            digitalWrite(WATER_PUMP_PIN, LOW);
              delay(400);
              digitalWrite(WATER_PUMP_PIN, HIGH);
           delay(400);
            digitalWrite(WATER_PUMP_PIN, LOW);
        } else {
            Serial.println("Not enough water or lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

    // Wait for the dry button press
    if (digitalRead(DRY_BUTTON_PIN) == HIGH) {
        // Start the slow spin
                if (digitalRead(LID_SENSOR_PIN) == LOW) {

        digitalWrite(DRUM_PIN, HIGH);
        delay(600);

        // Start the fast spin
        digitalWrite(DRUM_PIN, LOW);
        delay(300);
        digitalWrite(DRUM_PIN, HIGH);
        delay(300);
        digitalWrite(DRUM_PIN, LOW);
                }     else {
            Serial.println("lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

    // Wait for the full cycle button press
    if (digitalRead(FULL_BUTTON_PIN) == HIGH) {
        // Perform the wash cycle
        if (digitalRead(WATER_SENSOR_PIN) == LOW && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            digitalWrite(DRUM_PIN, HIGH);
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(600);
            digitalWrite(DRUM_PIN, LOW);
            digitalWrite(WATER_PUMP_PIN, LOW);
                delay(400);
            digitalWrite(WATER_PUMP_PIN, HIGH);
           delay(400);
            digitalWrite(WATER_PUMP_PIN, LOW);
        } else {
            Serial.println("Not enough water or lid is open.");
             digitalWrite(LED_PIN, HIGH);
            return;
        }

        // Perform the dry cycle
        // Start the slow spin
        if (digitalRead(LID_SENSOR_PIN) == LOW) {
        digitalWrite(DRUM_PIN, HIGH);
        delay(200);

        // Start the fast spin
        digitalWrite(DRUM_PIN, HIGH);
        delay(200);
        digitalWrite(DRUM_PIN, LOW);
        delay(200);
        digitalWrite(DRUM_PIN, HIGH);
        delay(100);
        digitalWrite(DRUM_PIN, LOW);
    
       } else {
            Serial.println("Not enough water or lid is open.");
             digitalWrite(LED_PIN, HIGH);
            return;
        }

    }}
```


Here is the basic circuit I am planning 

![Circuit](../images/ImagW4/Arduino1circuit.jpg)


I followed this diagram (except for the different colored wires) and it went pretty smoothly

Here is the one I built in action:



<iframe width="560" height="315" src=../../images/Finalproject/VMS.mp4 frameborder="0" allowfullscreen></iframe>  


## Final code

Here is the final code once I got all the wiring,  pins and sensors locked in.

```c
# include <Servo.h>

// Define the pin numbers for the sensors and actuators
const int LED_PIN = D4;
const int WASH_BUTTON_PIN = D8;
const int DRY_BUTTON_PIN = D6;
const int FULL_BUTTON_PIN = D7;
const int WATER_SENSOR_PIN = D2;
const int LID_SENSOR_PIN = D1;
const int DRUM_PIN = D0;
const int WATER_PUMP_PIN = D3;
const int DRUM_SLOW = 28;
const int DRUM_FAST = 29;
const int DRUM_STOP = 0;
int potVal;
Servo esc;
const int HX_OUT_PIN = D4;
const int HX_SCK_PIN = D5;
const int washdelay = 1500;
const int drydelay = 1000;
const int waterlevel = 1234000;
int waterSensorState = HIGH;

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);
  pinMode(FULL_BUTTON_PIN, INPUT_PULLUP);
  pinMode(WATER_SENSOR_PIN, INPUT_PULLUP);
  pinMode(LID_SENSOR_PIN, INPUT_PULLUP);
  pinMode(DRUM_PIN, OUTPUT);
  pinMode(WATER_PUMP_PIN, OUTPUT);
  Serial.begin(9600);
  esc.attach(DRUM_PIN, 1000, 2000);    
  esc.write(DRUM_STOP);  
  delay(1000);
  
}

void loop() {
    // Wait for the wash button press
    Serial.println(readHX());
 if (readHX() < waterlevel) {
    waterSensorState = LOW;
  } else {
    waterSensorState = HIGH;
  }

  digitalWrite(WATER_SENSOR_PIN, waterSensorState);



if (digitalRead(WASH_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(WATER_SENSOR_PIN) == HIGH && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            esc.write(DRUM_SLOW);
            Serial.println("wash");
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(washdelay);
            //esc.write(DRUM_STOP);
            digitalWrite(WATER_PUMP_PIN, LOW);
              delay(washdelay/3);
              digitalWrite(WATER_PUMP_PIN, HIGH);
              esc.write(DRUM_FAST);

           delay(washdelay);
            digitalWrite(WATER_PUMP_PIN, LOW);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("Not enough water or lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

       // Wait for the dry button press
    if (digitalRead(DRY_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the dry cycle
            esc.write(DRUM_SLOW);
            Serial.println("Dry");
            delay(drydelay);

              esc.write(DRUM_FAST);

           delay(drydelay);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

  // Wait for the full button press
    if (digitalRead(FULL_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(WATER_SENSOR_PIN) == HIGH && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            esc.write(DRUM_SLOW);
            Serial.println("washfull");
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(washdelay);
            //esc.write(DRUM_STOP);
            digitalWrite(WATER_PUMP_PIN, LOW);
              delay(washdelay/3);
              digitalWrite(WATER_PUMP_PIN, HIGH);
              esc.write(DRUM_FAST);

           delay(washdelay);
            digitalWrite(WATER_PUMP_PIN, LOW);
            esc.write(DRUM_STOP);
           delay(washdelay/3);
            esc.write(DRUM_SLOW);
            Serial.println("Dryfull");
            delay(drydelay);

              esc.write(DRUM_FAST);

           delay(drydelay);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("Not enough water or lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

            
    if (digitalRead(WASH_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(WATER_SENSOR_PIN) == HIGH && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            esc.write(DRUM_SLOW);
            Serial.println("wash");
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(washdelay);
            esc.write(DRUM_STOP);
            digitalWrite(WATER_PUMP_PIN, LOW);
              delay(washdelay/3);
              digitalWrite(WATER_PUMP_PIN, HIGH);
              esc.write(DRUM_FAST);

           delay(washdelay);
            digitalWrite(WATER_PUMP_PIN, LOW);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("Not enough water or lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

       // Wait for the dry button press
    if (digitalRead(DRY_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the dry cycle
            esc.write(DRUM_SLOW);
            Serial.println("Dry");
            delay(drydelay);
           
              esc.write(DRUM_FAST);

           delay(drydelay);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }

  // Wait for the full button press
    if (digitalRead(FULL_BUTTON_PIN) == LOW) {
        // Check the water level and lid status
        if (digitalRead(WATER_SENSOR_PIN) == HIGH && digitalRead(LID_SENSOR_PIN) == LOW) {
            // Start the wash cycle
            esc.write(DRUM_SLOW);
            Serial.println("washfull");
            digitalWrite(WATER_PUMP_PIN, HIGH);
            delay(washdelay);
            esc.write(DRUM_STOP);
            digitalWrite(WATER_PUMP_PIN, LOW);
              delay(washdelay/3);
              digitalWrite(WATER_PUMP_PIN, HIGH);
              esc.write(DRUM_FAST);

           delay(washdelay);
            digitalWrite(WATER_PUMP_PIN, LOW);
            esc.write(DRUM_STOP);
           delay(washdelay/3);
            esc.write(DRUM_SLOW);
            Serial.println("Dryfull");
            delay(drydelay);
           
              esc.write(DRUM_FAST);

           delay(drydelay);
            esc.write(DRUM_STOP);

        } else {
            Serial.println("Not enough water or lid is open.");
                        digitalWrite(LED_PIN, HIGH);

        }
    }
 
    }

    
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;
}


```


Files for the project can be found [here](../files/finalproject/vegwashingmachinefiles.zip)