Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

MOTOZERO control code

Sat May 25, 2019 2:12 pm

I'm a total novice trying to get my RP Zero to control a MOTOZERO for controlling 4 small engines which is a part of a sculture :(
I would like the code to:

- Autostart when powering up the RP.
- Rund the code continously in a loupe
- Control the speed of the enginese possibly with PWM.

My code looks like this for the first two engines:

Code: Select all


import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)

# Motor 1
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1Enable,GPIO.HIGH)

# HOW DO I GET THE FOLLOWING TO STOP

p=GPIO.PWM(Motor1A,50):
p.start(0)
while 1:
      for x in range(50):
             p.ChangeDutyCycle(20)
             sleep(0.1)

     for x in range(50):
             p.ChangeDutyCycle(50-x)
             sleep(0.1)

#HOW DO I GET MOTOR 2 TO START UP 

sleep(15)
GPIO.output(Motor1Enable,GPIO.LOW)

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)

# Motor 2
GPIO.output(Motor2A,GPIO.HIGH)
GPIO.output(Motor2B,GPIO.LOW)
GPIO.output(Motor2Enable,GPIO.HIGH)

sleep(5)

GPIO.cleanup()
I need help with making the code start up automatically, the continus loupe and how to get te PWM code to stop so that the second motor can start and finish the code.

I hope somone of you can give me some clues to how this should be handled.
Last edited by Ixtland on Sat May 25, 2019 2:46 pm, edited 1 time in total.

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sat May 25, 2019 2:40 pm

Hi.

So first when posting code please use code tags to preserve indentation.

Add [code] at the top

code goes here

and [/code] at the bottom.


looking at your code you have set up for motors 1 & 2 but you apear to be attempting to start the pwm on motor 4 for which you have no setup , So do you actually want to use pwm on motor 4 , if so then you need to do the setup for motor for as you have for motors 1 & 2.

It might also help if you explained when you want the pwm to do because at the moment you start it at 0, then you start a never ending loop , then you have a for next loop then executes 50 times but only ever sets the pwm dutycycle to the same value, the you have a second fox next loop that changes the dutycycle for 0 to from 50 to 0 vert quickly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sat May 25, 2019 2:54 pm

Hi Pcmanbob,

Thank you for a very quick answer.

Ok! code is corrected, and no, the enine 4 was a mistake, its corrected in the code.

As I'm working with an artwork and not something of exact science its not important when, but rater how much.... I need to be able to lower the speed of the engines involved, and have a sequence on when which one is going to be activated. the code as is, actaully works for me, in terms of adjusting the speed of engine no.1 but my problem is, that enine no.1 does not stop and engine no.2 does not start.


pcmanbob wrote:
Sat May 25, 2019 2:40 pm
Hi.

So first when posting code please use code tags to preserve indentation.

Add [code] at the top

code goes here

and [/code] at the bottom.


looking at your code you have set up for motors 1 & 2 but you apear to be attempting to start the pwm on motor 4 for which you have no setup , So do you actually want to use pwm on motor 4 , if so then you need to do the setup for motor for as you have for motors 1 & 2.

It might also help if you explained when you want the pwm to do because at the moment you start it at 0, then you start a never ending loop , then you have a for next loop then executes 50 times but only ever sets the pwm dutycycle to the same value, the you have a second fox next loop that changes the dutycycle for 0 to from 50 to 0 vert quickly.

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sat May 25, 2019 3:00 pm

Then you need to repost your code so I can what you changed.

As for the pwm does it only need to run through your 2 for loops and then start motor 2 and then once the time is up stop motor 2 and restart motor 1 ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sat May 25, 2019 3:07 pm

Ok! Heres the code...

I have 4 engines all together which will have to be adjusted in terms of speed, but I only put the two first into the code, for convenience...

Code: Select all

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)

# Motor 1
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1Enable,GPIO.HIGH)

# HOW DO I GET THE FOLLOWING TO STOP

p=GPIO.PWM(Motor1A,50):
p.start(0)
while 1:
      for x in range(50):
             p.ChangeDutyCycle(20)
             sleep(0.1)

     for x in range(50):
             p.ChangeDutyCycle(50-x)
             sleep(0.1)

#HOW DO I GET MOTOR 2 TO START UP 

sleep(15)
GPIO.output(Motor1Enable,GPIO.LOW)

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)

# Motor 2
GPIO.output(Motor2A,GPIO.HIGH)
GPIO.output(Motor2B,GPIO.LOW)
GPIO.output(Motor2Enable,GPIO.HIGH)

sleep(5)

GPIO.cleanup()
pcmanbob wrote:
Sat May 25, 2019 3:00 pm
Then you need to repost your code so I can what you changed.

As for the pwm does it only need to run through your 2 for loops and then start motor 2 and then once the time is up stop motor 2 and restart motor 1 ?

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sat May 25, 2019 3:22 pm

So you did not say which part of your code you want to loop or how many times each part of it is to run.

So I adjusted your code to just work the once running both motors

all the set up is done at the start
then start motor 1 and run pwm loops
stop motor 1
start motor 2
wait 5 seconds
stop motor 2
exit program.

Code: Select all


import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

# here we do all the motor gpio pin set up.
# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)
p=GPIO.PWM(Motor1Enable,50)

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)

# Motor 1
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
# GPIO.output(Motor1Enable,GPIO.HIGH) not needed if you are using pwm on this gpio pin

# start motor 1 and run for loops with pwm


p.start(0)

for x in range(50):
    p.ChangeDutyCycle(20)
    sleep(0.1)

for x in range(50):
    p.ChangeDutyCycle(50-x)
    sleep(0.1)

sleep(15)

# stop pwm and motor 1
p.ChangeDutyCycle(0)
# GPIO.output(Motor1Enable,GPIO.LOW) not needed if you are using pwm

# start motor2

# Motor 2
GPIO.output(Motor2A,GPIO.HIGH)
GPIO.output(Motor2B,GPIO.LOW)
GPIO.output(Motor2Enable,GPIO.HIGH)

sleep(5)

# stop motor 2
GPIO.output(Motor2Enable,GPIO.LOW)

GPIO.cleanup()
test code working using python 3

now I know you said you want this to loop but you have not said what part you want to loop or for how long
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 10:47 am

Dear PCMANBOB,

I´m overly exited! The following code is working, the engines are doing exactly what I want them to do..... I´ll send you a Youtube link when its all done, so that you can see out creation at work!... Its goning to be exhibited at the Danish Foreign Ministry in September :D

OK! ... Thanks, now... I need the following code to be repeated on start-up and run indefinately until the power to is cut off... and when this happens, and the power is back on... I need it to load automatically, and run for eons to come, untill there are no more power on the planet....

Can you help me make this happen?


Code: Select all

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 3
Motor1A = 23
Motor1B = 16
Motor1Enable = 12

# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)

# Motor 3
GPIO.setup(Motor3A,GPIO.OUT)
GPIO.setup(Motor3B,GPIO.OUT)
GPIO.setup(Motor31Enable,GPIO.OUT)

# Motor 1
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1Enable,GPIO.HIGH)

sleep(15)

GPIO.output(Motor1Enable,GPIO.LOW)

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)

# Motor 2
GPIO.output(Motor2A,GPIO.HIGH)
GPIO.output(Motor2B,GPIO.LOW)
GPIO.output(Motor2Enable,GPIO.HIGH)

sleep(10)

GPIO.output(Motor2Enable,GPIO.LOW)

# Motor 4
Motor4A = 13
Motor4B = 18
Motor4Enable = 25

# Motor 4
GPIO.Setup(Motor4A,GPIO.OUT)
GPIO.setup(Motor4B,GPIO.OUT)
GPIO.setup(Motor4Enable,GPIO.OUT)

# Motor 4
GPIO.output(Motor4A,GPIO.HIGH)
GPIO.output(Motor4B,GPIO.LOW)
GPIO.output(Motor4Enable,GPIO.HIGH)


p=GPIO.PWM(Motor1A,50):
p.start(0)
for x in range(50):
           p.ChangeDutyCycle(20)
           sleep(0.1)

for x in range(50):
           p.ChangeDutyCycle(50-x)
           sleep(0.1)

p.ChangeDutyCycle(0)

sleep(10)

# Motor 3
GPIO.output(Motor3A,GPIO.HIGH)
GPIO.output(Motor3B,GPIO.LOW)
GPIO.output(Motor3Enable,GPIO.HIGH)

sleep(5)

GPIO.output(Motor3Enable,GPIO.LOW)

GPIO.cleanup()



pcmanbob wrote:
Sat May 25, 2019 3:22 pm
So you did not say which part of your code you want to loop or how many times each part of it is to run.

So I adjusted your code to just work the once running both motors

all the set up is done at the start
then start motor 1 and run pwm loops
stop motor 1
start motor 2
wait 5 seconds
stop motor 2
exit program.

Code: Select all


import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

# here we do all the motor gpio pin set up.
# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)
p=GPIO.PWM(Motor1Enable,50)

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)

# Motor 1
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
# GPIO.output(Motor1Enable,GPIO.HIGH) not needed if you are using pwm on this gpio pin

# start motor 1 and run for loops with pwm


p.start(0)

for x in range(50):
    p.ChangeDutyCycle(20)
    sleep(0.1)

for x in range(50):
    p.ChangeDutyCycle(50-x)
    sleep(0.1)

sleep(15)

# stop pwm and motor 1
p.ChangeDutyCycle(0)
# GPIO.output(Motor1Enable,GPIO.LOW) not needed if you are using pwm

# start motor2

# Motor 2
GPIO.output(Motor2A,GPIO.HIGH)
GPIO.output(Motor2B,GPIO.LOW)
GPIO.output(Motor2Enable,GPIO.HIGH)

sleep(5)

# stop motor 2
GPIO.output(Motor2Enable,GPIO.LOW)

GPIO.cleanup()
test code working using python 3

now I know you said you want this to loop but you have not said what part you want to loop or for how long

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sun May 26, 2019 11:25 am

Yes but I need to tidy your code up again because you have setups scattered in the areas that need looping , so give me a while to work through it.

and you seem to have the pwm enabled on motor 1, but you are trying to use the enable pin to switch it on and off. ?

so what motor should have pwm set up on it. ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 11:45 am

I need to be able to control the speed on motor 2 and 4.

Its the entire sequence of coding which need to run over and over again.

Looking forward to see your solution.... I’m learning a lot , thanks for that!
pcmanbob wrote:
Sun May 26, 2019 11:25 am
Yes but I need to tidy your code up again because you have setups scattered in the areas that need looping , so give me a while to work through it.

and you seem to have the pwm enabled on motor 1, but you are trying to use the enable pin to switch it on and off. ?

so what motor should have pwm set up on it. ?

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sun May 26, 2019 11:48 am

but in your code you only have speed control set for motor1

Code: Select all

 p=GPIO.PWM(Motor1A,50):
    p.start(0)
    for x in range(50):
               p.ChangeDutyCycle(20)
               sleep(0.1)

    for x in range(50):
               p.ChangeDutyCycle(50-x)
               sleep(0.1)

    p.ChangeDutyCycle(0)
    
so do you want to use the same speed control sequence for both motors 2 and 4 ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 11:52 am

Ah... OK! yes the sequence could be the same for a start, and then I can change it later, when its up an running... I need to see the action to determin the speed and the pauses.

pcmanbob wrote:
Sun May 26, 2019 11:48 am
but in your code you only have speed control set for motor1

Code: Select all

 p=GPIO.PWM(Motor1A,50):
    p.start(0)
    for x in range(50):
               p.ChangeDutyCycle(20)
               sleep(0.1)

    for x in range(50):
               p.ChangeDutyCycle(50-x)
               sleep(0.1)

    p.ChangeDutyCycle(0)
    
so do you want to use the same speed control sequence for both motors 2 and 4 ?

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 12:24 pm

Dear Pcmanbob..... here’s the result!...

https://youtu.be/xBiHZcvngn4

Ixtland wrote:
Sun May 26, 2019 11:52 am
Ah... OK! yes the sequence could be the same for a start, and then I can change it later, when its up an running... I need to see the action to determin the speed and the pauses.

pcmanbob wrote:
Sun May 26, 2019 11:48 am
but in your code you only have speed control set for motor1

Code: Select all

 p=GPIO.PWM(Motor1A,50):
    p.start(0)
    for x in range(50):
               p.ChangeDutyCycle(20)
               sleep(0.1)

    for x in range(50):
               p.ChangeDutyCycle(50-x)
               sleep(0.1)

    p.ChangeDutyCycle(0)
    
so do you want to use the same speed control sequence for both motors 2 and 4 ?

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sun May 26, 2019 12:24 pm

Right I have corrected your setup for all the motors and move it to the start of the program were it needs to be because it should only be run once on program start.

set motor 2 & 4 for pwm and removed the high low enable commands, add comments were changes to lines or line not required, fixed your indentation again to keep it to a standard 4 spaces per indentation, added try/except to catch ctrl,c and switch all motors off.

it now runs as an endless loop to exit while you are running it at the command line you press Ctrl ,c and it will stop all the motors and exit.

Code: Select all

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# list gpio pin variables
# Motor 1
Motor1A = 27
Motor1B = 24
Motor1Enable = 5

# Motor 2
Motor2A = 6
Motor2B = 22
Motor2Enable = 17

# Motor 3
Motor3A = 23
Motor3B = 16
Motor3Enable = 12

# Motor 4
Motor4A = 13
Motor4B = 18
Motor4Enable = 25

# set up gpio pins
# Motor 1
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1Enable,GPIO.OUT)

# Motor 2
GPIO.setup(Motor2A,GPIO.OUT)
GPIO.setup(Motor2B,GPIO.OUT)
GPIO.setup(Motor2Enable,GPIO.OUT)
p2=GPIO.PWM(Motor2Enable,50)
p2.start(0)

# Motor 3
GPIO.setup(Motor3A,GPIO.OUT)
GPIO.setup(Motor3B,GPIO.OUT)
GPIO.setup(Motor3Enable,GPIO.OUT)

# Motor 4
GPIO.setup(Motor4A,GPIO.OUT)
GPIO.setup(Motor4B,GPIO.OUT)
GPIO.setup(Motor4Enable,GPIO.OUT)
p4=GPIO.PWM(Motor4Enable,50)
p4.start(0)


# main loop to run motors
try:
    while True:
        # Motor 1
        GPIO.output(Motor1A,GPIO.HIGH)
        GPIO.output(Motor1B,GPIO.LOW)
        GPIO.output(Motor1Enable,GPIO.HIGH)

        sleep(15)

        GPIO.output(Motor1Enable,GPIO.LOW)


        # Motor 2
        GPIO.output(Motor2A,GPIO.HIGH)
        GPIO.output(Motor2B,GPIO.LOW)
        #GPIO.output(Motor2Enable,GPIO.HIGH) not required as you are using pwm on this pin.
        
        for x in range(50):
            p2.ChangeDutyCycle(20)
            sleep(0.1)

        for x in range(50):
            p2.ChangeDutyCycle(50-x)
            sleep(0.1)

        sleep(10)
        #GPIO.output(Motor2Enable,GPIO.LOW) not required as you are using pwm on this pin.
        p2.ChangeDutyCycle(0)

        # Motor 4
        GPIO.output(Motor4A,GPIO.HIGH)
        GPIO.output(Motor4B,GPIO.LOW)
        #GPIO.output(Motor4Enable,GPIO.HIGH) not required as you are using pwm on this pin.

        for x in range(50):
            p4.ChangeDutyCycle(20)
            sleep(0.1)

        for x in range(50):
            p4.ChangeDutyCycle(50-x)
            sleep(0.1)

        sleep(10)
        p4.ChangeDutyCycle(0)

        # Motor 3
        GPIO.output(Motor3A,GPIO.HIGH)
        GPIO.output(Motor3B,GPIO.LOW)
        GPIO.output(Motor3Enable,GPIO.HIGH)

        sleep(5)

        GPIO.output(Motor3Enable,GPIO.LOW)


except KeyboardInterrupt:
    p2.ChangeDutyCycle(0)
    p4.ChangeDutyCycle(0)
    GPIO.output(Motor1Enable,GPIO.LOW)
    GPIO.output(Motor3Enable,GPIO.LOW)
    print("   clean exit")

I have only test the code to see if it runs without error , can't test motor function as I don't have 2 motor driver chips or 4 motors.

when you have finalised the code so it runs the motors as you require then you can look to running it at pi start up, but while you are testing it , it would not be wise to run the code at start up as you would have to reboot your pi on every code change.

I will make another post to explain starting it on pi boot.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sun May 26, 2019 12:56 pm

Making code run on pi boot.

As a safe method I would suggest you use cron to start your program as even if you make an error with the setup you won't lock yourself out of your pi which you can do using other methods.


So first some prerequisites.
program will be called test.py ( you can change this to what ever you have called it. )
its saved in the /home/pi directory which is your default directory and I recommend you use this location.
you are running your program with python 3

So we need to make a cron entry for the pi user which we do using crontab which well call from a command line like this

Code: Select all

crontab -e
if you have not does this before you will need to select an editor just accept the default which is nano

now you need to move to the last line in the file using the keyboard arrow keys.

and you need to enter this line exactly as shown here.

Code: Select all

@reboot sleep 30 && python3 /home/pi/test.py  >/dev/null 2>&1
then you need to press "Return" to create a new line after this line

now you need to save this entry by entering “CTRL-X”, then “Y” and finally “Return”.

if all is well you will get a message saying new cron installed.

now if you do a sudo reboot your program will run , but the will be a 30 second delay before your program starts this is to allow the pi to finish booting when being started from cold.

this link will show you some images of the crontab pages but do not follow the instructions as they are out of date and incorrect.
https://www.raspberrypi-spy.co.uk/2013/ ... rettyPhoto

one final point if you are going to be running your pi headless you will need a way to execute a controlled shutdown to turn it off, as just pulling the power will eventually lead to a corrupt SD card.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 1:11 pm

Dear pcmanbob,

Thanks a lot! It runs perfectly... now I will expand the movements to several different sequences before making the final loupe.

How do I know if I'm running Python 3?

I installed the lates version of Noobs on my Raspberry Pi Zero.

I´m wondering... maybe it will it be possible to use a timer, which will start and close the process within a certain time of the day instead of having it run in a continuous loupe?... For instance, start at 9 a.m. and colose down at 5 p.m. every day?

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: MOTOZERO control code

Sun May 26, 2019 1:22 pm

Glad it works , if you are going to expand the motor functions just remember to keep them in the loop and add any setup for new motors to the start of the program.

noobs is just an installer not an operating system.
If you are using raspbian stretch desktop then I believe the python editors default to python 3, if you are using raspbian stretch lite then you are calling the program from the command line so you should know what command you are using, python or python3

Even if you use a time to turn you pi on and off via the power supply you still need to close it down correctly before removing the power,
one option is to set up cron to run a shutdown command before your time switches the power off.

So timer turns power on at 9am pi will boot program runs.
At 5pm cron runs shutdown and turns pi off safely
At 5:05pm timer turns power off.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Ixtland
Posts: 9
Joined: Sat May 25, 2019 1:31 pm

Re: MOTOZERO control code

Sun May 26, 2019 1:32 pm

Dear pcemanbob,

Thanks again, I think I will be able to manage from here! :D

Return to “Python”