Week 9 - Outputs
Programming the servo
The main purpose of the board I made last week was to learn how to use a servo. The first thing IO tried to do was go to chat GPT to get it to tell me what I should do. I asked it ot program a servo to move when I pressed down a button. I inputed the code into the board, but it didn't work. I scrapped the button for now, as the servo was more important to me, so I asked chat GPT to just give me a program for a servo. The code it gave me again didn't work, even when I modified the pinouts. I thought there was something wrong with my board, but I couldn't find anything. Later that day, Adam told me that when he was using his rp2040, his pins were slightly offset from what the pinout diagram said, so I decided to test each pin number to make sure that nothing was wrong with the board before I redid it. When I tried pin 1 it worked! I used code derived from chat GPT, but it was mostly just for reference.
The servo functions by telling it what angle it should become set to. This way, you have exact control over eveything you do, and can easily set things to where they need to be.
Using a stepper motor (NEMA-17)
Initially, I followed Mrs. Morrow's documentation to see how to use a stepper motor using the arduino cnc shield. When following this tutorial in it's entirety, it didn't work. I then searched for a bunch of different videos on how to use the NEMA-17. The video I settled on actually worked when using it with arduino, but it didn't work when I tried to do this with the Xiao RP2040. Essentially when using the stepper motor, you set the steps to the number of steps your motor is designed to do, then you can change how long the motor turns for (how many steps) and the direction as well.
Controlling 4 servos
Within my final project, I need to controll 4 servos to allow for the seeds to drop. I wanted to controll these servos using a pico and micropython because that was what I need for my project. The 4 servos are connected to pins 3, 4, 5, and 6 respectively. What the servos need to do is to alternate between droppping the seeds, but as a temporary test, if the servos are even able to move, I just want them to each move individually between two points. The board I used will be the final board for my final project, and will also include networking and an input from an accelerometer.
This is the board I will be using
This is a video of the code working!
This was accomplished using the micropython-servo
pluggin, which I downloaded to my board. This is running off of the mpu6050 accelerometer, to dictate when to move the servo. The files for this can be found on my final project page
Group project
Since I was the only one in our group to try to use the NEMA-17, I set the circuit up to be able to test the draw the motor had. I learned how I need to provide a fairly large amount of power to run these motors. Link to group site