What you will need:
Create your Spinning Flower
Take two male to male jumper wires and cut off the connectors at one end. Strip the wires and solder them to the two contact points on the motor. I also added some hot glue once the solder had dried over the top to make the joint more stable and less likely to break. You may need some help from an adult to do this.
Optional step: If you would like to use your motors later for a roving robot, or to help stick your flower to the motor, glue on a wheel like this one. I used some very strong glue, so make sure that you get the help of an adult to help you do this.
Design your flower by either cutting out a template like these, or by drawing and cutting out your own. Using blu tack and a drawing pin, add your flower to your wheel or motor.
Add a Pibrella
Plug your pibrella into your Raspberry Pi. It should fit over the first 26 GPIO pins. Ensure that there is a rubber foot underneath so that the metal parts of the pibrella board do not touch the HDMI port on your Raspberry Pi B+ (as this could short the Pi).
Look on the Pibrella board for whee it says 'Out'. Beneath are a number of ports that have been labelled. Look for the row marked 'E' and push the other end of the flower/motor jumper cable into the ports next to each other. (It doesn't matter which way round as long as they are both plugged in the row 'E').
Prepare your Raspberry Pi
Add your SD card with Raspbian on to your Raspberry Pi and connect it to a screen, keyboard, mouse and power. You can plug the micro usb power into the pibrella board and it will power your Pi too.
Log into your Pi and load the GUI by typing 'startx'. Once loaded, open an LXTerminal window and type in the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get upgrade
Once this process is completed (it may take a few minutes) you are ready to download and install the pibrella python 3 library to control your motor. In the same LXTerminal window type:
sudo apt-get install python3-pip
sudo pip-3.2 install pibrella
Now you can load the Python 3 programming environment IDLE3 by typing the following:
sudo idle3 &
Let's write some code!
Opening IDLE 3 as the super user allows you to control the GPIO pins with your code in IDLE 3.
Once the application has opened click on File and New Window. Then save the file as spin.py by clicking on File and Save As.
Begin your program by importing the libraries that you need to control both the Pibrella board and time.
Now we can add lines of code to turn on the motor, wait for a period of time in seconds, and then turn off the motor connected to output 'e' on the Pibrella board.
Save the file and run it by clicking on Run and Run Module. You should now have a spinning flower!
Follow the video tutorial to find out how you can use loops and functions to improve your creation!