To drive the motor, a Soft Potentiometer, a Flex Sensor are used. The Soft Potentiometer is used to set the speed/pwm of the motor whereas the Flex Sensor is used to change the direction of the motor, either forward or bacward. There are two leds, RED is indicating that the motor is being drive FORWARD whereas GREEN is indicating BACKWARD.
The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:
Digital Drawed Circuit
Implemented Circuit
Here is a video available to see the outputs and how the system works:
Arduino Code :
/* Can KAVALOĞLU */ int softPin = 0; int flexPin = 1; int motorPin = 9; int redPin = 12; int greenPin = 13; int softValue, flexValue, motorPwm; void setup(){ pinMode(softPin, INPUT); pinMode(flexPin, INPUT); pinMode(motorPin, OUTPUT); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); Serial.begin(9600); } void loop(){ softValue = analogRead(softPin); motorPwm = map(softValue, 0, 1023, 0, 255); flexValue = analogRead(flexPin); flexValue = constrain(flexValue, 710, 950); if(flexValue > 830){ motorPwm *= -1; digitalWrite(redPin, HIGH); digitalWrite(greenPin, LOW); } else{ digitalWrite(redPin, LOW); digitalWrite(greenPin, HIGH); } analogWrite(motorPin, motorPwm); Serial.print("PWM : "); Serial.print(motorPwm); Serial.print(" direc: "); Serial.println(flexValue); }
Hiç yorum yok:
Yorum Gönder