![]() ![]() For example we import a library called GPIO Zero, used to easily interact with the GPIO of the Raspberry Pi. Our first few lines of Python are called “imports” and they import pre-written libraries of code into our project. Once it is open, click on File > Save and call the project “sorting.py”, then click Save / Ok. But for this project we shall click on File > New to open a new blank document. The editor is called IDLE and it will open to a screen called “the shell”, here we can interact with Python in real time. We’ll start coding using the Python 3 editor, which can be found in the Programming section of the main menu. When the wiring is complete, power up your Raspberry Pi and go to the Raspbian / Pixel desktop. Refer to the table diagram above to see where each color physically connects to the Raspberry Pi. The resistors reduces the current and ensure our LED has a long life.įor each color we connect the long leg to the corresponding GPIO pin. Resistors are used to reduce the current that flows in the LED circuit, if there is too much then the LED will shine very bright, and then fizzle out. The shorter leg, the Cathode, is connected to our Ground rail (-) via the resistor. The longer leg is called the Anode and it receives current from the Raspberry Pi GPIO. Our LEDs, short for Light Emitting Diodes which are components that light up when current is supplied in the correct direction, have two legs. Now our button is fully connected to the Raspberry Pi. Then connect the female end to any of the Raspberry Pi GPIO Ground pins. Now grab another female to male connector and place the male end into the – rail of the breadboard, the same rail that we have connected our button to. The other leg next to that we have just connected is linked to GPIO22 of our Raspberry Pi using a female to male connector. This means that the leg of the button is now grounded. On one side of the breadboard connect the male to male connector in the same line as one of the legs of the button, and connect it to the – rail of the breadboard. The button sits over the central channel that is cut into the breadboard and is pressed firmly into the holes, creating an electrical connection. This means that the circuit is “normally open” until the button is pressed, and then it is closed. The push button, sometimes called an momentary switch is a button that closes an electrical circuit when it is pushed. Using two lists to store messages and the housesĪsking the user to play the game by pressing a button We shall be covering the following conceptsĬonditional test based on answer to a question One thing that children always want to know is “Which house would the Sorting Hat sort me into?” Well wonder no more aspiring witches and wizards, we shall make our own electronic Sorting Hat using a Raspberry Pi, some cheap electronic components and a little Python code. The wonderful world of witchcraft and wizardry was opened up to the world thanks to JK Rowling’s series of Harry Potter novels. ![]() 4 x 220 Ohm resistors (or 330 Ohm, the LEDs will just be a little dimmer)Īll of the code for this project can be found at Introduction.1 each of Red, Green, Yellow and Blue LEDs.Twitter Lists for Programming and Computer ScienceĪ fun way to learn basic electronics and coding with Python but minus the old rotting hat.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |