Page 1 of 1

Raspberry Pi timer controller

Posted: 19 Feb 2014, 21:09
by R_Head
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?

Re: Raspberry Pi timer controller

Posted: 20 Feb 2014, 15:45
by viking60
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 !!!

Re: Raspberry Pi timer controller

Posted: 21 Feb 2014, 12:59
by R_Head
Thanks.

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

My other idea was a pressure cascade system.

Re: Raspberry Pi timer controller

Posted: 21 Feb 2014, 13:52
by viking60
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.