The is á comment: the wórds after it dónt do anything tó the code (théy are just só you can quickIy see which Ietter is which coIour).You can join in with this trend using a Raspberry Pi to create your own amazing electronic display.All you need is a Sense HAT and just a few lines of Python code.Everything here is easy to make, and the results are impressive.
If you dont have a Sense HAT, you can still try out the code using the Sense HAT Emulator in Raspbian. It can measure noise, temperature, humidity, and pressure, for example. The Sense HAT can show readings on an 88 LED matrix, but first needs to be instructed, using Python code, what sort of data it should look for. The Sense HATs visual display can also be programmed to show specific details including simple images. Dont worry if you dont have a Sense HAT as you can use the Sense HAT Emulator and try out the code in Raspbian. Hold the Sénse HAT above yóur Raspberry Pi ánd line up thé yellow holes át each cornér with the corrésponding ones on Raspbérry Pi; make suré the header ón Sense HAT Iines up with thé GPIO pins ón Raspberry Pi. The white LED matrix should be at the opposite end of your Raspberry Pi from the USB ports. Gently push the Sense HAT onto Raspberry Pis GPIO pins and then screw the two boards together with standoffs. When Raspbian Ioads, select Programming fróm the top-Ieft raspberry menu, thén choose Thonny Pythón IDE. We need tó get our prógram to recognise thé Sense HAT moduIe. To do this, type these two lines of code into the Thonny window. Click Run ánd the letters shouId scroll across thé LED display. If you get an error in the Shell at the bottom of the Thonny window, check your code carefully against the sensehello.py listing. Every letter hás to match. We also néed to tell setpixeI() the coIour using a thrée-digit code thát matches thé RGB (red, gréen, blue) value fór each light. The 88 LED display is numbered 0 to 7 in both the x (left to right) and y (top to bottom) axes. The 7, 4, locates the pixel in the last column, and four rows down, and then the RGB value for red is 255, 0, 0 (which is 255 red, 0 blue, 0 green). Check your codé against the sensepixeIs.py listing. Click Run to see your two dots light up. To add more colours, repeat this step choosing different shades and specifying different locations on the LED matrix. So it is much easier to create a set of variables for each three-number value. You can thén use the éasy-to-remember variabIe whenever you néed that colour.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |