Pibrella Motor

Make sure Python 3 on the Raspberry Pi is updated and that you have the latest Pibrella library first.
Open idle3 for python as an administrative user
You can access both these commands from the Pibrella Update Pi page.

Simple direct current motors of 3-6 volts can be controlled by the Pibrella board
This example uses the built in button on the board
import pibrella

while True:
    if pibrella.button.read() ==1:
        pibrella.output.e.write(1)
    elif pibrella.button.read() ==0:
        pibrella.output.e.write(0)
#Import the Pibrella library of code

#While True is similar to a forever loop in Scratch
#If the button is equal (==) to 1 it is making a circuit and is on
#Outputs are attached to E, F, G or H. This one is attached to e. 1 means it is on
#If the button is equal (==) to 0 it is not making a circuit and is off
#Outputs are attached to E, F, G or H. This one is attached to e. 0 means it is off
You can use
pibrella.output.e.on()
pibrella.output.e.off()
But if you wish to use a variable with your programs at a later stage the (1) or (0) is more useful

This example is the same as above but a button has been attached to input a
import pibrella

while True:
    if pibrella.input.a.read() ==1:
        pibrella.output.e.write(1)
    elif pibrella.input.a.read() ==0:
        pibrella.output.e.write(0)



#If the button attached to input a is equal (==) to 1 it is making a circuit and is on

#If the button attached to input a is equal (==) to 0 it is not making a circuit and is off

Comments