Bruno P
Published © GPL3+

Automatic Cheese Grater

I needed something that would grate cheese for me at the press of a button.

BeginnerShowcase (no instructions)3 hours99
Automatic Cheese Grater

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Greartisan Worm Gear Motor JSX5300 370 DC 5V 0.5RPM
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Test Accessory, AC Power Adapter
Test Accessory, AC Power Adapter
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Photon wiring

D15/D16 send information to Motor driver on motor speed
D2 is power. GND is ground.

Motor Driver Wiring

OUT1, OUT2 goes to the motor.
GND goes to negative of external power. +5V goes to positive of the external power.

The whole thing

Code

Grating code

C/C++
Essentially what my code does is set up the motor/motor Controller.
Then in the loop I have the photon checking the button state (down or up) and if its pressed down I will change the state of the motor (on/off). It is very important to add a short delay so the photon doesn't loop through my code too fast and turn of f and turn on the motor within 1 button press.
int IN1 = D15;
int IN2 = D16;
int button=D2;
boolean motorState=false;

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(button, INPUT_PULLUP);
    digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  

}
void loop() {
  int btnState = digitalRead(button);
  if(btnState==LOW){
      if(motorState==false){
        digitalWrite(IN2, HIGH);
        motorState=true;}
      else{
          digitalWrite(IN2,LOW);
          motorState=false;
      }
      delay(250);
  }
  
}

Credits

Bruno P
1 project • 1 follower
Thanks to Ryan Chan.

Comments