![]() So initially we are waiting for the data from the serial, which is transmitted from python once recognized that there is a more than zero characters. All the connecting ports are set to output and were using the pin, mod and its set to output because were sending data through them to the motor in our void loop. So, for example, weve got indices a to d here that separate the data sets and in string format we have the variables used to control the motor, but these are converted into these variables, one below which are here in order to capture the right data format, which Is used in our step motor, so in the void setup we have our serial open and the voltage is set to 9600. Port weve got the temporary variables that is used to control the script, as well as the variables to capture the parameters. First, we are defining the global variables here same as before that are used in our program. Then separated once we do the parsing we again separate the sets of data to 1 580 and anti clockwise and wed use that data to control the motion of the stepper motor okay, guys so lets run through the script on arduino ide. Then we have the third set of data, which is the angle that we weve set earlier and then separator c and anti clockwise direction is being applied. Then we have the second set of data, which is the speed of the arduino, and we have separator b. So we have the first set of data, which is one, and then we have the separator a. So this is the the first line indicate the data thats been transmitted from arduino from python to arduino uh. On the right hand of the screen, we have the outputs. We can reduce the speed to 5 rpm if you want to and set the angle to 180 degrees and let the stepper motor rotate in clockwise direction by 180 degrees same applies to anti clockwise direction. If we press clockwise, the data is sent and the stepper motor rotates by 90 degrees lets have a look again here and we can also run the stepper motor in anti clockwise direction. Okay, now, if we run the gui lets set on the interface gu interface, we have the image of the stepper motor itself, the speed and the slider, which controls the speed in rpm and the angle which is measured in degrees, so lets set the speed to 8 Rpm and angle lets make it 90 degrees if we rotate. ![]() The script gui should appear, as illustrated in the middle of the screen, and we should have the arduino output. First of all, let me run through a little demonstration here. Using parameters defined in python script well be using some of the concepts we learned in our earlier series, such as transmitting data from python to arduino parsing data, once its received and using functions to control the speed direction and angle of the stepper motor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |