10. Mechanical design, machine design¶
Group assignment:¶
-
Design a machine that includes mechanism + actuation + automation + application
-
Build the mechanical parts and operate it manually.
-
Actuate and automate your machine.
-
Document the group project
To see our group assignment click here
Individual assignment:¶
- Document your individual contribution.
For this week we’ve built a machine that is a kibble dispenser for animals. Everyone has to document their contrubition to the project. I worked on the code, so follow me for more details.
Section 1: Header¶
/**
* -->DATE : 15/04/2024
*
* -->AUTEURS : DROH ET ANNICK
*
******************-->CAT FEEDER<--*********************
*
**/
Section 2: Inclusion of libraries¶
This section includes the libraries needed for the project. The Wire library is used for I2C communication, while LiquidCrystal_I2C is used to control the LCD screen in I2C mode.Section 3: Declaration of variables and constants¶
int latency_time, Dispenser, j;
int screenMessage = 0;
boolean system_activated = false;
boolean activate_system = false;
Section 4: Pins and Constants Definition¶
#define LCD_ADDR 0x27
#define COL 16
#define ROW 2
#define MOTOR_ENA 12
#define MOTOR_IN1 11
#define MOTOR_IN2 10
#define PIN_BUZZER 9
#define DelPin 4
const int buttonPins[] = {2, 3};
const char buttonChars[] = {'A', 'B'};
This section defines the I2C addresses of the LCD screen, as well as the pins used to control the motor, buzzer, LED, and buttons. Constants are also defined for the button pins and the characters associated with each button.
Section 5: Initialization in the setup() function¶
void setup() {
Serial.begin(115200);
lcd.init();
lcd.begin(16, 2);
pinMode(MOTOR_ENA, OUTPUT);
pinMode(MOTOR_IN1, OUTPUT);
pinMode(MOTOR_IN2, OUTPUT);
pinMode(PIN_BUZZER, OUTPUT);
pinMode(DelPin, OUTPUT);
for (int j = 0; j < 2; j++) {
pinMode(buttonPins[j], INPUT_PULLUP);
}
}
Section 6: Main loop function in the loop() function¶
void loop() {
if (activate_system) {
//...
}
if (system_activated == true) {
//...
}
if (!system_activated) {
//...
}
}
Each if(){} else if(){} else if(){} block contains different logic based on flags and button inputs.
Section 7: Additional Functions¶
void getTime() {
//...
}
void actionA() {
//...
}
void actionB() {
//...
}
void flashLED() {
//...
}
This section contains definitions of functions used in the main loop to perform specific tasks, such as food distribution, button management, and LED blinking.