Tech-Byteshttp://tech-bytes.co.uk
Taking a byte out of the Raspberry PiSat, 18 Apr 2015 20:58:38 +0000en-UShourly1https://wordpress.org/?v=4.2.21TechBytes-rsshttps://feedburner.google.comRaspberry Pi Robot – Connecting the H-Bridge & Motorshttp://feedproxy.google.com/~r/TechBytes-rss/~3/BUEr1O7wYP0/
http://tech-bytes.co.uk/2015/04/18/raspberry-pi-robot-connecting-the-h-bridge-motors/#commentsSat, 18 Apr 2015 20:58:38 +0000http://tech-bytes.co.uk/?p=165It has been a while since I have posted anything so here we go with a quick post on how to get the motors and H-Bridge connected up to our Raspberry Pi.

Below is an image of how my Raspberry Pi is currently Connected:

For this project we will be using four of the Raspberry Pi’s GPIO pins, two per motor. In the diagram below you will see a diagram of a L298N (hopefully yours will look the same or very similar). Each motor will have two wires running from them, this will allow us to connect them to “output A” and “output B”.

We will be connecting our battery pack up to the +12v power terminal since we will be providing the H Bridge Motor Controller with 6v from the battery pack that is in our Zumo Chassis. We will also want to run the ground from the battery pack and also from the Raspberry Pi to the ground terminal on the H Bridge Motor Controller.

Finally we want to run our input cables from the Raspberry Pi GPIO ports to the four input pins of H Bridge Motor Controller. I have done them in the following order :

Pin 1: Yellow Cable should be GPIO 16

Pin 2: White Cable should be GPIO 18

Pin 3: Green Cable should be GPIO 21

Pin 4: Orange Cable should be GPIO 19

This is all there really is to connecting your motors and motor controller up ready for coding our Raspberry Pi robot to move!

If you have an questions or suggestions please leave a comment below.

Bookmark with:

]]>http://tech-bytes.co.uk/2015/04/18/raspberry-pi-robot-connecting-the-h-bridge-motors/feed/0http://tech-bytes.co.uk/2015/04/18/raspberry-pi-robot-connecting-the-h-bridge-motors/Raspberry Pi Robot – Flashing LEDs – The Codehttp://feedproxy.google.com/~r/TechBytes-rss/~3/grigEpygR6k/
http://tech-bytes.co.uk/2015/03/15/raspberry-pi-robot-flashing-leds-the-code/#commentsSun, 15 Mar 2015 13:02:08 +0000http://tech-bytes.co.uk/?p=141Below you will find the example Python code that we will be using to flash the two LEDs that we wired up in the previous post.

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)

GPIO.output (16, True)
time.sleep(1.5)
GPIO.output (16, False)

GPIO.output (18, True)
time.sleep(1.5)
GPIO.output (18, False)

GPIO.cleanup()

The first two lines of code are to import the Raspberry Pi module and the Time modules to enable us to use the Raspberry Pi and Time related specific functions.

The next line is to set the GPIO pinouts up. Since we are using the standard Raspberry Pi pinouts we just set this as BOARD.

After that we will define which of the Raspberry Pi GPIO pins we will be using as output pins. As you may remember from the previous post we will be using pins 16 and 18.

The next block of code will send power to pin 16, wait for one and a half seconds before turning the power off again. These few lines of code will therefore light our red LED for one and a half seconds before turning it off.

The final block of code is exactly as above but it will light our green LED for one and a half seconds before turning it off.

Finally we will run GPIO.cleanup() which will turn off the pins we have been using and return them back to the default state for next time we want to use them.

Once you have got your code typed up and saved as LEDs.py from within a terminal prompt run the following command and watch your LEDs light up in turn for one and a half seconds.

sudo python LEDs.py

That is all for this post if you have any issues with this code please leave a comment below.

Bookmark with:

]]>http://tech-bytes.co.uk/2015/03/15/raspberry-pi-robot-flashing-leds-the-code/feed/0http://tech-bytes.co.uk/2015/03/15/raspberry-pi-robot-flashing-leds-the-code/Raspberry Pi Robot – Flashing LEDs – The Circuithttp://feedproxy.google.com/~r/TechBytes-rss/~3/HaNfgIiU564/
http://tech-bytes.co.uk/2015/03/13/raspberry-pi-robot-flashing-leds-the-circuit/#commentsFri, 13 Mar 2015 20:26:13 +0000http://tech-bytes.co.uk/?p=96In this brief guide we will show you how to connect up two LEDs to the GPIO ports on your Raspberry Pi and control them via Python Script. From this point onwards I will assume that your Raspberry Pi has a fully working install of Raspbian and is connected to your WiFi or Wired Network. Rather than working directly on the Pi I will be connecting via SSH to create and execute our code.

You may be wondering why we are bothering tinkering around with LEDs rather than diving straight in and getting some motors up and running. There are two reasons for this the first is I am still waiting for my L298N motor Controller to arrive. The second reason is that the basic Python code we will be using to light a few simple LEDs will be pretty much the same code we will be using to turn a motor on and off.

Below is a diagram of how we will be connecting our components together on our breadboard (protoboard). Connect the Ground (Black cable) to the Ground connector on the Raspberry Pi GPIO, this is the third pin down on the side nearest your breadboard. Plug both LEDs and resistors into the breadboard as shown and the connect the live (or signal cables) to GPIO pins 16 (for the Red LED) and 18 (for the Green LED). Once that is complete connect the live cables into the slot below the longer leg (Positive) of each LED as shown. If everything looks exactly like it does in the diagram then it is time to move onto the coding part of this guide.

Later in the week I will post the code that we will be using to turn these LEDs on and off and explain what the code does and different ways we can improve it.

Bookmark with:

]]>http://tech-bytes.co.uk/2015/03/13/raspberry-pi-robot-flashing-leds-the-circuit/feed/0http://tech-bytes.co.uk/2015/03/13/raspberry-pi-robot-flashing-leds-the-circuit/Raspberry Pi Robot – Baking your Pihttp://feedproxy.google.com/~r/TechBytes-rss/~3/3YB0N9VwNnU/
http://tech-bytes.co.uk/2015/03/08/raspberry-pi-robot-baking-your-pi/#commentsSun, 08 Mar 2015 12:08:41 +0000http://tech-bytes.co.uk/?p=88I’m not going to cover setting up the Raspberry Pi from scratch as there are many sites available that already cover this subject in far more detail than I can provide.

For my project I am using Raspbian Debian Wheezy and an 8GB SD card. To learn how to install the image onto your SD card RaspberryPi.org have a very good install guide here.

To enable the Pi to be able to freely roam around we will have to install a USB WiFi adapter. I have used this rather generic slimline dongle from Amazon.

Setting up the WiFi access is pretty simple especially if you are using the GUI, if you do run into any issues the following guide on RaspberryPi.org has you covered.

Our Raspberry Pi should now be in a state where it can site wirelessly on the network ready for us to start creating and running our Python scripts.

In the next post we will cover wiring up two LEDs and creating a basic Python script that makes the LEDs flash.