Difference between revisions of "Connecting a motor and 1602 LCD to a Raspberry Pi"

From BitWizard WIKI
Jump to: navigation, search
(Things we used)
(Things we used)
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
* [http://www.bitwizard.nl/shop/6-pin-idc-cable-15cm SPI cable]
 
* [http://www.bitwizard.nl/shop/6-pin-idc-cable-15cm SPI cable]
 
* [http://www.bitwizard.nl/shop/7fets SPI 7FETs]
 
* [http://www.bitwizard.nl/shop/7fets SPI 7FETs]
* [http://www.bitwizard.nl/shop/lcd-interface-16x2 ]
+
* [http://www.bitwizard.nl/shop/lcd-interface-16x2 SPI LCD interface]
 
* Small electric motor
 
* Small electric motor
  

Latest revision as of 16:58, 4 December 2015

This page describes the demo that can be found on the following youtube link: http://www.youtube.com/watch?v=zSQDuy-uu8I

Things we used

We chose a small DC motor which works on 5VDC, so we could power it directly from the RPi. It is, however, possible to connect an external power supply, to drive motors (or other stuff) which require a different voltage then the 5V provided by the Pi.

Steps to take

We split this up in two seperate scripts:

set_pwm

#!/bin/sh
pwmval=$1
bw_tool -C -t "BW spi 7fets PWM"
bw_tool -w 11:20
bw_tool -t "test: $pwmval"
bw_tool -a 88 -w 50:$pwmval

test_pwm

#!/bin/sh
./set_pwm 58
./set_pwm 48
sleep 4
for i in 50 60 70 80 90 a0 b0 c0 d0 e0 f0 ff ; do
  ./set_pwm $i
  sleep 0.5
done
sleep 1
for i in ff f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 0 ; do
  ./set_pwm $i
  sleep 0.5
done

Put both scripts in your homedir, and run the test_pwm script as root, and you're done!