Tweet-o-meter

Tweet-o-meter

Keeping up to date with Twitter can be very time-consuming, especially if there are lots of tweets. What if you could see at a glance what the Twittersphere thinks about a certain topic? In this tutorial we’re going to build a simple RGB LED circuit, and program it to change colour to indicate whether the tweets that include a given hashtag or keyword are using positive, negative or generally neutral language. You’ll need RGB LED Breadboard Jumper wires 3× 100 ohm resistors Twitter developer account TextBlob Python library Twython Python library STEP-01 Install Python libraries Update your Pi to the latest version of Raspbian and download and install the additional software you’ll need.sudo pip3 install twython textblobThere are two libraries that make our project really easy. Twython allows you to contact Twitter using Python and collect tweets (you’ll need to register for a Python developer account – see step 5). Then, to read the tweets in the code, we’re going to use TextBlob; there are other libraries available, but this is one of the simplest. STEP-02 Do you like sausages? Let’s take a look at a simple example. Open a Python 3 interpreter (either use the command line or IDLE) and type:>>> from textblob import TextBlob >>> sentence = TextBlob(‘I really like sausages, they are great’) >>> sentence.sentiment.polarity 0.5Any value for polarity greater than 1 indicates a positive sentiment (like); a value less than 1 suggests negative sentiment (dislike). Try changing the sentence and see how a different phrase will give a different result. Results will be more accurate if you have more text, although a 140-character tweet is normally good enough. STEP-03 Select your RGB LED Light-emitting diodes (LEDs) are cool. Literally. Unlike a normal incandescent bulb which has a hot filament, LEDs produce light solely by the movement of electrons in a semiconductor material. An RGB LED has three single-colour LEDs combined in one package. By varying the brightness of each component, you can produce a range of colours, just like mixing paint. There are two main types of RGB LEDs: common anode and common cathode. We’re going to use common cathode. STEP-04 Connect up the RGB LED LEDs need to be connected the correct way round. For a common cathode RGB LED, you have a single ground wire and three anodes, one for each colour. To drive these from a Raspberry Pi, connect each anode to a GPIO…
Source: Tweet-o-meter

Zero4U review

Zero4U review

While the Raspberry Pi Zero’s compact nature makes it ideal for many projects, the downside is that it only offers a single micro USB port for connecting peripherals. So, to use it with a keyboard and mouse, for instance, you’ll need a USB adapter and a standard USB hub. Well, not any more… The full article can be found in The MagPi 49 and was written by Phil King Designed by UUGear in the Czech Republic, the Zero4U is a four-port USB hub that’s mounted on the rear of the Pi Zero. Its four pogo pins connect to the tiny PP1 (+5V), PP6 (GND), PP22 (USB D+), and PP23 (USB D-) testing pads on the Pi Zero. This enables it to take its power from the latter, in which case it can output up to 2A current to all four USB ports. Since the pogo pins are only in surface contact with the pads, they need to be kept firmly in place by securing the Zero4U to the Pi Zero using the plastic standoff screws and spacers supplied. We were slightly concerned about the pins maintaining a reliable contact, but didn’t experience any problems. One detail to note is that since the testing pad positions are slightly different on the two Pi Zero models – the original v1.2 and new v1.3 with camera connector – there are two versions of the Zero4U to suit, so you need to ensure you order the correct one. Either way, the Zero4U can also be used with any other Raspberry Pi model via its mini USB input, although the power output is reduced in this case unless you power it independently via its JST XH2.54 port. Once the Zero4U is piggybacking the Pi Zero and powered on, a blue LED lights up to show that it’s operating. In addition, each port has a white status LED that’s lit whenever a device is connected to it, which is a nice touch. All four ports operate at standard USB 2.0 speed (480Mbps). The only caveat is that if you insert a USB 1.1 device, they’ll all be slowed down to 12Mbps, since the hub has a single transaction translator, but it’s not a major problem. The Zero4U is extremely small Last word 4/5 The Zero4U is an ingenious solution to the lack of standard USB ports on the Pi Zero. There’s no soldering required and it’s…
Source: Zero4U review

The Internet of LEGO

The Internet of LEGO

We love LEGO and the internet, so what could be finer than this ‘Internet of LEGO’ project? Well, discovering the Raspberry Pi serving as its brain, and catching up with its maker to learn all about this amazing connected city. “The Internet of LEGO is a living project where I set out to learn everything about the Internet of Things,” says Cory Guynn. Packed with sensors, the city reports to a Raspberry Pi that acts as its brain. Cory has used this to create the Internet of LEGO blog. The full article can be found in The MagPi 48 and was written by Lucy Hattersley “I grew up playing with LEGO bricks and model trains, which taught me about construction and electronics, and allowed me to be creative. The use of LEGO also allows me to represent a city or build prototype systems easily. Plus, it gives me an excuse to buy a bunch of LEGO bricks in my thirties,” laughs Cory. “A Raspberry Pi Model B+ is the heart of my city,” he reveals, “and that was the starting point of the project.” The Raspberry Pi is attached to Arduino boards that control most of the GPIO operations. Cory also uses Cactus Micro Rev2, BlueDuino, WeMos and NodeMCU boards, along with a Wio Link and BeagleBone Green. Be careful of the roadworks in the LEGO city The city itself is complex, with many structures and buildings hooked up to a huge range of sensors: RFID, ultrasonic proximity, infrared, and magnetic reed switches are used to keep track of the city environment. The train system is Cory’s favourite part of the city. “I love seeing things in motion,” he reveals. “There are several things that I’ve been able to do that make for a dynamic environment.” Cory has built a train scheduling system using the Transport for London API. This system displays the schedule on an OLED screen and switches to the train track to match the destination. The trains are controlled by WiFi and an infrared transmitter attached to a tower. Infrared sensors are used to detect incoming trains and trigger a crossing signal (with a servo controlling the arm, and LEDs for lights). “Everything is connected to an Arduino Mega, which is then USB‑tethered to the Raspberry Pi,” explains Cory. The full city is an IoT metropolis He has developed a huge amount of software to control all the…
Source: The Internet of LEGO

Begin your journey with Raspberry Pi in issue 49 of The MagPi

Begin your journey with Raspberry Pi in issue 49 of The MagPi

We’ve all seen the numbers. The Raspberry Pi is selling faster and faster every year, which means there are new people getting Raspberry Pis every day. With this in mind we decided to make a brand new beginner’s guide in issue 49 of The MagPi, out now. The Raspberry Pi beginners guide takes you from selecting your Raspberry Pi all the way through setting it up and getting to know the Raspbian OS that powers it. We’re also using it to jump start a beginners tutorial series that will be a monthly feature in The MagPi from now on. Set up your Pi so it can take you to the moon! (Moon rocket not included) As well as the cover feature, we also have a feature on the recently released Apollo 11 source code and how you can emulate a virtual Apollo computer on your Raspberry Pi (along with some historical factoids about making and programming a computer to take people to the moon). There’s also our usual range of amazing tutorials, projects, and product reviews for you to read about as well! You can grab the latest issue of The MagPi in stores today from WH Smith, Tesco, Asda, and Sainsburys. It’s also available in print online from our store, and digitally on our Android and iOS app. Don’t forget – we’re running a poll to find out what you, the community, thinks are the top 20 Raspberry Pi projects to be included in our 50th issue spectacular. Get voting! The post Begin your journey with Raspberry Pi in issue 49 of The MagPi appeared first on The MagPi Magazine.
Source: Begin your journey with Raspberry Pi in issue 49 of The MagPi

Make a motion-controlled Egg Drop game

Make a motion-controlled Egg Drop game

Some of the most basic and repetitive games can be the most fun. Consider Flappy Bird, noughts and crosses, or even catch. With this in mind, a simple drop-and-catch game makes excellent use of the Sense HAT. Code a yellow LED to drop each second, and a basket on the bottom row of LEDs. Use code to record the accelerometer reading and utilise this so that when you tilt your Sense HAT left or right, you can move the basket to catch the egg. Catch it and you play again, but if you miss one, then it breaks and it’s game over. The full article can be found in The MagPi 47 and was written by Dan Aldred Getting set up Ensuring that your Raspberry Pi is turned off, attach your Sense HAT to the GPIO pins. Use the supports and screws to secure the HAT into position. Plug in the power and boot up your Pi. The Sense HAT Python library is included with the current OS image and requires no installation. Load your preferred Python editor and download the code to your Raspberry Pi, saving it into your home folder. To run the code, press F5; after a short introduction screen and a countdown, the game will begin. If you open the code in a text editor, you can customise some features of the program such as the messages, the colours used, and the splash screen. To edit or use your own message, find the code line which begins sense.show_message – for example, on line 32. Change the text within the speech marks and add your own message. Editing the colour of the message is possible and achieved by changing the red, green, and blue (RGB) values. The maximum value for each is 255, which is the full amount of colour. These can be combined to create a wide range of colours. For example, the colour blue is [0, 0, 255]. Like the text, you can also change the colour of the egg or basket by editing the RGB values within the square brackets. These are set using the code sense.set_pixel, found on line 46. You could change the values to [0, 255, 0] to create a pea drop game! Editing and using images When the game begins, an image of a chicken is displayed. This is loaded from a file called chick.png, which is stored in the…
Source: Make a motion-controlled Egg Drop game

Vote for our top 20 projects

Vote for our top 20 projects

This Thursday will see the release of issue 49 but we’re not resting on our laurels. We’ve already got stuck into making the next issue of The MagPi and as it’s our 50th issue we thought we’d do something special. We’re putting together a feature with 50 of the very best Raspberry Pi projects and we’ve decided that we can only do this properly if we get your input. We want the community to vote for our top 20 projects so we’ve created a poll with 30 of the very best projects for you to vote on. The list has everything from boats, to cars, to art, and arcade machines Head over to the Raspberry Pi blog now to vote in the poll and help us decide what the top 20 is. The results will be in issue 50 of the magazine, along with several other categories of other fantastic Pi projects. We’ll see you again on Thursday for issue 49 – it’s a good one! The post Vote for our top 20 projects appeared first on The MagPi Magazine.
Source: Vote for our top 20 projects

Naturebytes Wildlife Cam Kit review

Naturebytes Wildlife Cam Kit review

Ever wondered what kind of critters visit your garden whenever you’re not around to scare them off? With the Wildlife Cam Kit, you can find out. Its PIR sensor will sense any movement in the vicinity and trigger its Pi Camera Module to take a stealthy snap of whatever’s passing by. The full article can be found in The MagPi 48 and was written by Phil King You may recall that we’ve followed the progress of this Kickstarter-funded project in previous issues of The MagPi, but now it’s finally out in the wild. Designed by Naturebytes, a trio of digital makers and wildlife enthusiasts, its aim is to give users a fascinating insight into the natural world while also enhancing their digital making skills. To this end, it comes in kit form, although no soldering is required. It takes an hour or so to put together, following the detailed online PDF instructions. The latter are well-illustrated with plenty of photos, even if a couple were slightly misleading. Constructing your camera A laser-cut plastic insert is provided to suit whichever Raspberry Pi model you’re using; the standard kit comes with an A+ due to its lower power usage, but it could even be used with a new Pi Zero v1.3. Screws and plastic spacers are supplied to fit most of the components – including PIR sensor, Camera Module, and Pi – to the insert, threading jumper wires through its strategically placed holes. It’s clear that much thought has gone into its design; you even get bendy ties to push through pairs of holes to secure the wires tidily. Still, it wasn’t so easy to fit the jumper wires to the Pi’s GPIO pins through the large cut-out, requiring a small screwdriver to push them into place. A real-time clock module is also fitted to five of the pins (since the Pi doesn’t have one built-in), to enable accurate date/time-stamping of photos without an internet connection. Everything fits snugly into the casing Finally, an Adafruit Powerboost is fitted to the insert and connected to a LiPo battery. This is to boost the latter’s 3.7V output to the 5.2V needed to power the Pi and other components. A power switch has been added to the Powerboost to make it easier to switch the camera on and off when outdoors. Before you can use it, however, you’ll need to charge up the battery, which…
Source: Naturebytes Wildlife Cam Kit review

Raspberry Pi Self-Playing Piano

Raspberry Pi Self-Playing Piano

Lloyd Bayley is the proud owner of a Yamaha Disklavier pianola (a self-playing piano, or “player-piano” as it’s often known). When Lloyd’s Disklavier broke down, he decided to improve it with a Raspberry Pi. Pianolas don’t just make the sound of piano notes, they move the keys to self-play the piano. They’re quite spectacular to watch, and classic pianolas worked using a roll of paper with holes cut into it (the holes determine which keys the piano plays). More modern version, like the Yamaha Disklavier, use a floppy disk drive. The disks contain songs in MIDI format. Insert the disk and select the track, then the piano starts playing.

Pianola Pi: building a self-playing piano When the floppy drive on Lloyds’ Disklavier broke, he decided on a radical solution. Instead of fitting a new floppy drive, he attached a Raspberry Pi with a Touchscreen Display. The Raspberry Pi sends midi data direct to the Yamaha Disklavier and it plays any song you choose. “I thought, ‘this is going to get more and more common as time goes on’,” says Lloyd in his video. “With the discs failing for the older technology.” Rather than shell out for an expensive replacement, Lloyd decided to see if a Raspberry Pi could be used instead. “I thought to myself ‘all I need to do is be able to get the things in there’,” says Lloyd. “I wonder if the Raspberry Pi can play MIDI?” It turns out some MIDI to USB extensions are all that’s required, and Lloyd screwed a Touchscreen display and Raspberry Pi together to create a touch controller for his pianola. “All we need to do is put a little piece of software on here called XP MIDI,” says Lloyd, “and you then fill the directories with your MIDI files of choice and it’s very easy to navigate.” Lloyd spends a lot of time going over the build, and his wonderful looking Yamaha Disklavier so the video starts some way in (where the Raspberry Pi starts to play the piano). Skip back to the start if you want to view the build process. The post Raspberry Pi Self-Playing Piano appeared first on The MagPi Magazine.
Source: Raspberry Pi Self-Playing Piano

Sonic Pi – Code A Probabilistic Sequencer

Sonic Pi – Code A Probabilistic Sequencer

In a previous episode of this Sonic Pi series, we explored the power of randomisation to introduce variety, surprise, and change into our live-coded tracks and performances. For example, we randomly picked notes from a scale to create never-ending melodies. Today we’re going to learn a new technique which uses randomisation for rhythm – probabilistic beats! The full article can be found in The MagPi 47 and was written by Sam Aaron, the creator of Sonic Pi You’ll need Raspberry Pi running Raspbian Sonic Pi v2.7+ (update with: sudo apt-get update && sudo apt-get install sonic-pi) Speakers or headphones with a 3.5mm jack Probability Before we can start making new beats and synth rhythms, we need to take a quick dive into the basics of probability. This might sound daunting, but really it’s just as simple as rolling a dice!  When you take a regular six-sided board game dice and roll it, what’s actually happening? Well, firstly you’ll roll a 1, 2, 3, 4, 5 or 6, with exactly the same chance of getting any of the numbers. In fact, given that it’s a six-sided dice, on average (if you roll lots and lots of times) you’ll throw a 1 every six throws. This means you have a 1 in 6 chance of throwing a 1. We can emulate dice rolls in Sonic Pi with the dice function. Let’s roll one eight times:8.times do puts dice sleep 1 endNotice how the log prints values between 1 and 6, just as if we’d rolled a real dice ourselves. Random beats Now imagine you had a drum and before you hit it you rolled the dice – if you got a 1, you hit the drum (otherwise you didn’t). You now have a probabilistic drum machine working with a probability of 1/6! Let’s hear it:live_loop :random_beat do sample :drum_snare_hard if dice == 1 sleep 0.125 endLet’s quickly go over each line to make sure everything is clear. First, we create a new live_loop called :random_beat, which will continually repeat the two lines between do and end. The first of these lines is a call to sample, which will play a pre-recorded sound (the :drum_snare_hard sound in this case). However, this line has a special conditional if ending. This means that the line will only be executed if the statement on the right-hand side of the if is true. The statement in this…
Source: Sonic Pi – Code A Probabilistic Sequencer

Pokémon Finder built from Raspberry Pi

Pokémon Finder built from Raspberry Pi

This unassuming Raspberry Pi case looks like a Lure module from Pokémon Go, but it lets you know when Pokémon are nearby. Inside is a Pi Zero, which is linked up to an unofficial Pokémon Go API. As you walk around it detects when Rare and Legendary Pokémon are nearby. The LED lights on the side of the Pokémon Finder light up to indicate nearby creatures. The first LED shows you common Pokémon, if Rare critters are nearby the second LED is lit up. The third LED turns on when Legendary creatures are nearby.

Pokémon Finder: find the rarest Pokémon The design for the Lure Module can be downloaded from Thingiverse, and looks just like a Lure item from the game. The Pi Zero fits inside. There’s a full tutorial over on the Adafruit blog. After building the Lure case you load some Python code onto the Pi Zero inside. This connects to an unofficial Niantic API and gets a request when a Pokémon spawns in your area. In the JSON configuration file you can specify any location. The project comes with a big warning though. It is completely against Niantic’s terms of service. It’s a proof-of-concept device that you build at your own risk. Niantic will probably shut down access to the project, and could block any accounts they suspect of cheating. So don’t use it on your main account. Adafruit doesn’t guarantee it’ll work at all, but we think it’s a pretty cool project for the weekend. The post Pokémon Finder built from Raspberry Pi appeared first on The MagPi Magazine.
Source: Pokémon Finder built from Raspberry Pi