Fix indentation
This commit is contained in:
parent
a734728aac
commit
c56c0978e6
@ -58,22 +58,22 @@ void setup(void)
|
|||||||
|
|
||||||
carrier.display.fillScreen(0x000);
|
carrier.display.fillScreen(0x000);
|
||||||
|
|
||||||
//pinouts til motor
|
// Pinouts for motor
|
||||||
pinMode(motor_pin1, OUTPUT);
|
pinMode(motor_pin1, OUTPUT);
|
||||||
pinMode(motor_pin2, OUTPUT);
|
pinMode(motor_pin2, OUTPUT);
|
||||||
pinMode(motor_pin3, OUTPUT);
|
pinMode(motor_pin3, OUTPUT);
|
||||||
pinMode(motor_pin4, OUTPUT);
|
pinMode(motor_pin4, OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void)
|
void loop(void)
|
||||||
{
|
{
|
||||||
// Rotate motor if needed
|
// Rotate motor if needed
|
||||||
if (motor_count) {
|
if (motor_count) {
|
||||||
motor_clockwise();
|
motor_clockwise();
|
||||||
motor_count--;
|
motor_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive MQTT messages
|
// Receive MQTT messages
|
||||||
int message_size = mqtt_client.parseMessage();
|
int message_size = mqtt_client.parseMessage();
|
||||||
if (message_size) {
|
if (message_size) {
|
||||||
Serial.print("Got message with topic: ");
|
Serial.print("Got message with topic: ");
|
||||||
@ -83,30 +83,30 @@ void loop(void)
|
|||||||
Serial.println("Dispensing...");
|
Serial.println("Dispensing...");
|
||||||
|
|
||||||
// Start rotating motor
|
// Start rotating motor
|
||||||
motor_count = motor_count_max;
|
motor_count = motor_count_max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void motor_clockwise()
|
void motor_clockwise()
|
||||||
{
|
{
|
||||||
for (int i = 7; i >= 0; i--) {
|
for (int i = 7; i >= 0; i--) {
|
||||||
motor_set_output(i);
|
motor_set_output(i);
|
||||||
delayMicroseconds(motor_speed);
|
delayMicroseconds(motor_speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void motor_anticlockwise()
|
void motor_anticlockwise()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
motor_set_output(i);
|
motor_set_output(i);
|
||||||
delayMicroseconds(motor_speed);
|
delayMicroseconds(motor_speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void motor_set_output(int out)
|
void motor_set_output(int out)
|
||||||
{
|
{
|
||||||
digitalWrite(motor_pin1, bitRead(motor_lookup[out], 0));
|
digitalWrite(motor_pin1, bitRead(motor_lookup[out], 0));
|
||||||
digitalWrite(motor_pin2, bitRead(motor_lookup[out], 1));
|
digitalWrite(motor_pin2, bitRead(motor_lookup[out], 1));
|
||||||
digitalWrite(motor_pin3, bitRead(motor_lookup[out], 2));
|
digitalWrite(motor_pin3, bitRead(motor_lookup[out], 2));
|
||||||
digitalWrite(motor_pin4, bitRead(motor_lookup[out], 3));
|
digitalWrite(motor_pin4, bitRead(motor_lookup[out], 3));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user