Raspberry Pi timer controller

Moderators: b1o, jkerr82508

User avatar
R_Head
Berserk
Posts: 2819
Joined: 17 Mar 2010, 15:40

Raspberry Pi timer controller

Postby R_Head » 19 Feb 2014, 21:09

At work we want to use a Raspberry Pi to control a series of air bladders.

They have to work in sequence.

For example. Turn one on, wait 1 min and turn the next one and so on.

How can you program the Pi to do it.

I am thinking on a cron job but command line is not my thing.

Can someone point me to the right direction or tell me how?

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Raspberry Pi timer controller

Postby viking60 » 20 Feb 2014, 15:45

Well you could do something like this:
#!/bin/bash
COUNTER=0
while [ $COUNTER -eq 0 ]; do
sleep 60
echo valhalla!!!
done


This one is going to write valhalla!!! every minute - forever (as long as the counter is 0)

You can change sleep 60 to sleep 5 to test it a bit faster.

Save it as berserk.sh and chmod it to 777 and start the script with ./berserk.sh

But this is b1o stuff...
:S b1o !!!
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
R_Head
Berserk
Posts: 2819
Joined: 17 Mar 2010, 15:40

Re: Raspberry Pi timer controller

Postby R_Head » 21 Feb 2014, 12:59

Thanks.

How do I start it with a push of a single button?

My other idea was a pressure cascade system.

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Raspberry Pi timer controller

Postby viking60 » 21 Feb 2014, 13:52

Have a look here:

Here I have made a sequence script:

Code: Select all

#!/bin/bash
for (( ;; ))#starts infinite loop
do
COUNTER=0
COUNTER2=0
COUNTER3=0

while [  $COUNTER -lt 6 ]; do #pumps continuously into bladder one for 6 sec
sleep 1
echo Pumping bladder one... $COUNTER
let COUNTER=COUNTER+1;

done

while [  $COUNTER2 -lt 6 ]; do #pumps continuously into bladder two for 6 sec
sleep 1
echo $COUNTER2
echo Pumping bladder two!
let COUNTER2=COUNTER2+1
done

while [  $COUNTER3 -lt 6 ]; do #pumps continuously into bladder three for 6 sec
sleep 1

echo Pumping bladder three! $COUNTER3
let COUNTER3=COUNTER3+1
done
done #"End" of infinite loop


It will pump on bladder one for 6 sec then two for 6 sec then bladder three for 6 sec before starting with bladder one again ...
Just change 6 to 60 and you will have your one minute sequences.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"


Return to “Linux education”