Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Give lines and placement for following code to be able to move motor to 45 degrees and then back to original position. // This Code

Give lines and placement for following code to be able to move motor to 45 degrees and then back to original position.

// This Code if for tb6600 stepper driver

// defines pins numbers const int stepPin = 5; const int dirPin = 4; const int enPin = 3; int T=50; // Motor speed

void setup() { void rotateDegrees(float degrees); Serial.begin(500000); // Sets the two pins as Outputs pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); pinMode(enPin,OUTPUT); digitalWrite(enPin,LOW); //float degrees(45);

} void loop() { //float spd=Serial.parseFloat(); if(spd==1.0) { digitalWrite(enPin,HIGH); T=50; } else if(spd==2) { digitalWrite(enPin,HIGH); T=100; } else if(spd==3) { digitalWrite(enPin,HIGH); T=150; } else if(spd==4) { digitalWrite(enPin,HIGH); T=200; } else if(spd==5) { digitalWrite(enPin,HIGH); T=250; } else if(spd==6) { digitalWrite(enPin,HIGH); T=300; } else if(spd==7) { digitalWrite(enPin,HIGH); T=350; } else if(spd==8) { digitalWrite(enPin,HIGH); T=400; } else digitalWrite(enPin,LOW);

Serial.write(T); digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction // Makes 200 pulses for making one full cycle rotation for(int x = 0; x <=200*47; x++) { //gear revolution digitalWrite(stepPin,HIGH); delayMicroseconds(T); //delay(T/100); // One second delay digitalWrite(stepPin,LOW); //delay(T/100); // One second delay delayMicroseconds(T); } //delay(1000); // One second delay

digitalWrite(dirPin,LOW); //Changes the rotations direction // Makes 400 pulses for making two full cycle rotation for(int x = 0; x <=200*47; x++) { //one full gear revolution digitalWrite(stepPin,HIGH); delayMicroseconds(T); //delay(100/T); // One second delay digitalWrite(stepPin,LOW); //delay(T/100); // One second delay delayMicroseconds(T); } // delay(1000); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago