User avatar
HermannSW
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:
https://en.wikipedia.org/wiki/Flag_semaphore#Characters

Youtube video for this command:
$ ./flag_semaphore att rest R A S P B E R R Y ready
$
https://www.youtube.com/watch?v=CdKShDd ... e=youtu.be
This is double speed, no sound:
Image


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

Code: Select all

#!/bin/bash
if [ ! -f /var/run/pigpio.pid ]; 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 "$@"
do
  $ch
done

P.S:
There is one deficiency -- characters HIOWXZ cannot be signalled with two servos because of servo position 0°..180° limitation.
Attachments
flag_semaphore.gz
flag_semaphore (gzipped)
(261 Bytes) Downloaded 56 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “Automation, sensing and robotics”