User avatar
Posts: 5246
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

flag_semaphore att rest R A S P B E R R Y ready

Sat Oct 12, 2019 9:07 pm

After connecting two SG90 servos to the Pi (GND/5V/GPIO[12]7 connected to SG90 brown/red/orange), and having figured out that pigpio pigs command "pigs s 17 X" with X=500/1500/2500 moves servo connected to GPIO17 to 0°/90°/180° position, I wanted to have some little demo. Bash script "flag_semaphore" attached:

Youtube video for this command:
$ ./flag_semaphore att rest R A S P B E R R Y ready
$ ...
This is double speed, no sound:

I have never defined so many bash functions, these are the move primitives for left and right servo, and pause:

Code: Select all

if [ ! -f /var/run/ ]; then sudo pigpiod; sleep 0.5; fi

p() { sleep 1
l() { pigs s 27 $1
r() { pigs s 17 $1

These are the special, non-character functions:

Code: Select all

rest() { l 2500; r 500; p
att() { l 1000; r 2000;p; l 2000;r 1000;p; l 1000;r 2000;p; l 2000;r 1000;p
ready() { l 500; r 2500; p; rest

What is really cool is how to execute the script arguments, sooooo simple:

Code: Select all

Y() { l 1000; r 1500; p

for ch in "$@"

There is one deficiency -- characters HIOWXZ cannot be signalled with two servos because of servo position 0°..180° limitation.
flag_semaphore (gzipped)
(261 Bytes) Downloaded 56 times

Return to “Automation, sensing and robotics”