“High-performance work of any modern enterprise is impossible without properly organized and working means of moving goods - lifting and transporting machines. By the principle of operation, these machines are divided into two groups: batch and continuous machines. The first includes cranes, etc., and the second includes conveyors of various types. ”
/* Conveyor control system */ // int S1Pin = 8; int S2Pin = 9; int S3Pin = 10; // int M1PWMPin = 5; int M1DIRPin = 4; // int motorSlowSpeed = 50; int motorNormSpeed = 130; int motroFastSpeed = 255; // int motorFwd = LOW; int motorRev = HIGH; int S1,S2,S3 = 0; // int M1PWM = 0; // 1 int M1DIR = 0; // 1 int State = 0; void M1Fwd() { M1PWM = motorNormSpeed; M1DIR = motorFwd; } void M1Rev() { M1PWM = motorNormSpeed; M1DIR = motorRev; } void M1Stop() { M1PWM = 0; } void readInputs() { S1 = digitalRead(S1Pin); S2 = digitalRead(S2Pin); S3 = digitalRead(S3Pin); } void writeOutputs() { analogWrite(M1PWMPin, M1PWM); digitalWrite(M1DIRPin, M1DIR); } void setup() { // 4 5 pinMode(M1PWMPin, OUTPUT); pinMode(M1DIRPin, OUTPUT); // 8,9 10 pullup pinMode(S1Pin, INPUT); // set pin to input digitalWrite(S1Pin, HIGH); // turn on pullup resistors pinMode(S2Pin, INPUT); digitalWrite(S2Pin, HIGH); pinMode(S3Pin, INPUT); digitalWrite(S3Pin, HIGH); Serial.begin(57600); } void loop() { readInputs(); if (S1 == LOW) { M1Rev(); } if (S2 == LOW) { M1Fwd(); } if (S3 == HIGH) { M1Stop(); } writeOutputs(); Serial.println(State, DEC); }
Source: https://habr.com/ru/post/134526/
All Articles