Tag Archives: DEMO

Arduino Diecimila Board Access…

By wisecracker

This is a very simple starter DEMO to access Arduino Diecimila Board for the
Macbook Pro 13″ OSX 10.7.5…
A potentiometer is connected between 5V and Gnd with the wiper connected to
ANALOG IN 0 on the Arduino. This was adjusted to give the Ms and Ls as seen…

I now have DC in for this machine AND Linux too as on my Linux tools the device
becomes /dev/ttyUSB0 …

NOTE:- The device below is for MY machine and WILL be different for yours…

It is assumed that you have a Terminal up and running AND you have NOT
plugged in your USB Arduino Board yet…

Enjoy finding simple solutions to often very difficult problems…

Public Domain and you may do with it as you please…

Code:

Last login: Thu Jul 18 21:58:14 on ttys000
AMIGA:barrywalker~> # Find the USB device first.
AMIGA:barrywalker~> ls /dev/*usb*
ls: /dev/*usb*: No such file or directory
AMIGA:barrywalker~> # Now plug in the Arduino Diecimila Board...
AMIGA:barrywalker~> ls /dev/*usb*
/dev/cu.usbserial-A7007cvs /dev/tty.usbserial-A7007cvs
AMIGA:barrywalker~> # USE the /dev/cu.usbserial-A7007cvs device...
AMIGA:barrywalker~> cat < /dev/cu.usbserial-A7007cvs
MLMMLMMMMMMLMMMMLMLMMLLLLLLMLLMMMMMLMMMLMLLMLMLMMMMMMMMMMMLLMLLLMLLLLLLMLLLMLLM
MMMLMLLMLMMMLMMMMMLMLMLMLMMMLLLMMLLMMMMMMLLLMLLMMLMLLLLLMMMMLMLLLLMMMMMMMLLLMML
MMLMMMLLMLMLMLLMMMMLLLMLMMMMMLLMMLMMMLLMMMLLMMMMMMMMMMLLMLLLMMLLLMLMLMMLMMLMLML
MMMMMLLMMMMLLLLLLMMMMMMLLMLMMMMMLMMMLLMLMLMLLMLMLLLLMMMLMMLMMMMLMLMLMMLMMLMLMML
MLMLLLMLLLLLLMLLMMLMMMLMMMLMMLMLMMLMLMLMMLMLMMMLLLMLMLLLMMLLLMLMLMLLLLLLLMLMMML
LMcMMLLLLMLMMMMLMMMMMLMMLLMLMMMMMMLMLLMMMMMLMMMMLMLLMLMMMLLLMMMMMLLLMLMMLMLMMLM
MLMLLMLMMMMMLLLMMMMLLLMLMMLLMMLLMLLLMMMLLMMMLLMLLLLMMLLMMMMLLMMMMMLLLLLMMLLMMML
MLMMLLLMLLLLM^C
AMIGA:barrywalker~> _


The .PDE file for the Arduino as a test piece, this uses an early version of the
programming SW and I know it won’t compile on current versions so you will have
to modify slightly as required…

Code:

/* Using the Arduino as a DEMO single channel ADC for Windows (TM), Linux, */
/* AMIGA, WinUAE and now the Macbook Pro 13 inch OSX 10.7.5... */

/* Set up a variable for basic analogue input. */
int analogue0 = 0;

void setup() {
/* Open the serial port at 9600 bps. */
Serial.begin(9600);

/* Set the analogue voltage reference, DEFAULT is 5V in this case. */
analogReference(DEFAULT);
}

void loop() {
/* Read the 10 bit analogue voltage on analogue input 0. */
analogue0 = analogRead(0);
/* Convert to a byte value by dividing by 4. */
analogue0 = analogue0/4;

/* Send to the Serial Port the byte value. */
Serial.print(analogue0, BYTE);
}


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

A Simple Clock, Well Maybe Not That Simple…

By wisecracker

File Type: jpg
The attachment says it all really…

It is a DEMO at a glance digital readout using the “date” command to make it useful…

Enjoy…

Code:

#!/bin/bash
#
# Clock.sh
# A bash DEMO to create a 6 x 7 character set using the whitespace character.
# It is a functional digital clock but this is not important as I want this
# method for an _at_a_glance_ digital display for a kids level shell digital
# voltmeter I am in the process of doing.
#
# The clock in normal size is white on black near the top. The extra large clock
# is green on black and in the centre of the terminal..
#
# $VER: Clock.sh_Version_1.00.00_(C)2013_B.Walker_G0LCU.
# Issued under GPL2.
#
# Written so the anyone can understand how it works.

# Set the window to white foreground on black background.
printf "x1B[0;37;40m"
clear
# Remove the cursor.
tput civis
# Set up all _variables_ as is required.
TIME=`date "+%H:%M"`
char="0"
# The plot _variable_ "p".
p="(C)2013, B.Walker, G0LCU."
# The background colours.
bg="x1B[0;37;40m"
# The foreground colours.
fg="x1B[0;37;42m"
# The initial character plotting points.
horiz=10
vert=9
# This function reads the time and stores it in "TIME".
clock()
{
TIME=`date "+%H:%M"`
printf "x1B[2;32f$bg The time is $TIME.n"
}
# This function is required to coreectly print out the large characters.
plot()
{
p="x1B["$vert";"$horiz"f"
vert=$[ ( $vert + 1 ) ]
}
# *********************************************************
# The eleven characters required for this DEMO are 0 to 9
# and the : colon character.
zero()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
one()
{
plot
printf "$p$bg $fg $bg "
...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Flash And Fade DEMO For Mac OSX 10.7.5, (And Linux?).

By wisecracker

This is an AT A GLANCE shell DEMO that does:-

1) 10 centred greyscale fades without warning beeps.

2) 5 centred yellow “WARNING!” flashes with beeps every ON state.

3) 5 FULL widowed red “DANGER!!!” flashes with beeps in the ON and OFF states.

It assumes that the warning bell is enabled inside the terminal.

It is primarily for OSX 10.7.5 and above but it could just as easily work in Linux or other UNIX like systems. It is issued as Public Domain and you my do with it as you please…

READ THE CODE FOR MORE INFO…

(Watch for wordwrapping, etc…)

Bazza, G0LCU…


#!/bin/bash
#
# Flash and fade for a Macbook Pro OSX 2.7.5 Terminal...
# A DEMO to show how to give an AT A GLANCE, and, audible warning of impending doom in a shell script.
# It is for something like an analogue Data Logger input say from an Arduino analogue source.
#
# It may well work on other Linux and Unix like machines but is untested and uses the "tput" command
# to hide and unhide the terminal cursor. The command "setterm" is commented out and could be used
# in place of the above depending on the *NIX flavour...
#
# Written in such a way that anyone can understand how it works.
#
# It starts with 10 cycles of grey/gray scale fading on a black background without any beeps then next
# 5 yellow warning flashes with a beep every full flash and finally 5 FULL screen red flashes with beeps
# on every ON and OFF state.
#
# Clear a screen to white on black...
printf "33[0;37;40m"
clear
printf "n Flash and fade for a default Macbook Pro OSX 2.7.5 Terminal.n"
# Turn the cursor off...
#setterm -cursor off
tput civis
# Fade on and off 10 times, grey/gray scales on black.
for fade in $(seq 1 10)
do
printf "33[12;23f33[1;30;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
printf "33[12;23f33[1;90;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
printf "33[12;23f33[1;37;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
printf "33[12;23f33[1;97;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
printf "33[12;23f33[1;37;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
printf "33[12;23f33[1;90;40mFading using four _shades_ of grey...33[0m"
sleep 0.1
done
# Over-write the above with the ...read more
Source: FULL ARTICLE at The UNIX and Linux Forums

A Crude 1KHz Audio Sinewave Generator Demo…

By wisecracker

A very simple crude sinewave generator.

The file required is generated inside the code, is linear interpolated and requires /dev/audio to work. Ensure you have this device, if not the download oss-compat from your OS‘s repository…

It lasts for about 8 seconds before exiting and saves a 65536 byte file to your working directory/drawer/folder as sinewave.raw. Use an oscilloscope to check the waveform generated…

It is entirely Public Domain and you may do with it as you please…

Bazza, G0LCU…


#!/bin/bash
#
# 1KHz.sh
#
# A very simple DEMO crude sinewave generator using the device /dev/audio.
# It is an eight second burst and generates an approximation of a pure sinewave using linear interpolation.
# The "sinewave.raw" file length is 65536 bytes in size...

# Zero the raw file...
> sinewave.raw

# This is the b byte data list for the crude sinewave.
data="\x0f\x2d\x3f\x2d\x0f\x03\x00\x03"

# Generate the file as an eight second burst...
for waveform in {0..8191}
do
printf "$data" >> sinewave.raw
done

# Now play back a single run of the raw data for about eight seconds.
cat sinewave.raw > /dev/audio

# End of 1KHz.sh DEMO...
# Enjoy finding simple solutions to often very simple problems... ;o)


Source: FULL ARTICLE at The UNIX and Linux Forums

Use The Terminal To Test Arduino Is Working.

By wisecracker

Hi all…

(Apologies for any typos at all.)

This is a step by step _script_ to check if your Arduino is talking to your Linux or Macbook Pro computer using the Terminal…

It works on at least 3 Linux flavours and now the Macbook Pro

I hope you find it useful as a simple check for your Arduino setup…

This is issued as Public Domain.

The “Test.pde” is the code to program the Arduino with.
My Arduino programming SW is old and I am aware that the “Test.pde” script will not compile on current Arduino programming SW. I am assuming you will know what to do with it…

Code:

A basic, terminal, test sequence to check that the Arduino Diecimila board is _talking_ to your computer.

Step by step testing inside a Linux , OR, Macbook Pro Terminal usage for the USB Arduino Diecimila Board...
Issued as completely Public Domain by B.Walker, G0LCU, 2011-2013.

Common to both systems:-
------------------------

1) Boot up to your Linux flavour or Macbook Pro as root, (or run in a root Terminal).
2) Temporarily disable any net access or use a stand-alone machine.
3) Plug in the USB Arduino board.
4) Open up a, (root), Terminal and clear the screen.
5) clear

Linux flavours first:-
----------------------
6) Check that you have a device as ttyUSB?
IMPORTANT NOTE: Arduino boards are now detected as ttyACM? so although NOT tested this might still work...
If this is the case then replace ttyUSB? with ttyACM? below...

7) ls /dev
NOTE:- ? above will probably be 0.
8) If ttyUSB0, (to 7), appears then carry on; otherwise ignore the remainder of this text.

NOTE:- Assuming the device is ttyUSB0 from now on, change below if needed to your ttyUSBx device.
9) Place a wire link between ANALOG 0 and the 3.3 V terminals, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...

NOTE:- 'chmod' is probably not really needed but added for fullness!
10) chmod 666 /dev/ttyUSB0

11) Set up the on board serial I/O to 9600bps and RAW data transfer for PCLinuxOS and Debian.
12) stty -F /dev/ttyUSB0 1200
13) stty -F /dev/ttyUSB0 raw

14) Now start printing characters to the screen...
15) cat < /dev/ttyUSB0
NOTE:- The wire link characters will be from about 168 to 174 decimal allowing for bit error of the Arduino ADC.

16) Remove and replace the wire link from ANALOG 0 and GND or ANALOG 0 and 5 V too, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...
17) Press 'Ctrl-C' to stop any characters being printed to the Terminal.
18) Unplug the USB Arduino board.
19) Power down the computer IF REQUIRED.

Now the Macbook Pro:-
---------------------
6) Now find the device name, mine is tty.usbserial-A7007cvs, yours will probably be much different...

7) ls /dev
8) If you have a new tty* note its name then carry on, otherwise ignore the rest of this text.
(I will use my device name for this example.)

9) Place a wire link between ANALOG 0 and the 3.3 V terminals, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...

NOTE:- 'chmod' is probably not really needed but added for fullness!
10) chmod 666 /dev/tty.usbserial-A7007cvs

11) Now start printing characters to the screen...
(The command stty does NOT work for this on the Macnook Pro so revert to the command cu instead.)
12) cu -l /dev/tty.usbserial-A7007cvs -s 9600

13) Ctrl-C does not work so just close down the Terminal COMPLETELY.
14) Unplug tha Arduino board.
15) Power down the computer IF REQUIRED.

=============================================================

This is the "test.pde" code for the Arduino Diecimila board:-
-------------------------------------------------------------

/* Test.pde */
/* Using the Arduino as a DEMO single channel ADC for WinUAE. */
/* For use with AF2005 or greater. This is just demonstration code */
/* only and shows that I/O is possible through WinUAE by other means. */

/* Set up a variable 1 byte in size for basic analogue input. */
int analogue0 = 0;

void setup() {
/* open the serial port at 9600 bps. This rate is used for purely */
/* for simplicity only. */
Serial.begin(9600);

/* Set the analogue voltage reference, DEFAULT is 5V in this case. */
analogReference(DEFAULT);
}

void loop() {
/* Read the 10 bit analogue voltage on analogue input 0. */
analogue0 = analogRead(0);
/* Convert to a byte value by dividing by 4. */
analogue0 = analogue0/4;

/* Send to the Serial Port the byte value. */
Serial.print(analogue0, BYTE);

/* Delay 500 milliseconds before taking the next reading. */
delay(500);
}

=============================================================

Enjoy finding simple solutions to often very difficult problems...

Bazza, G0LCU...


Source: FULL ARTICLE at The UNIX and Linux Forums

The Start Of A Simple Audio Scope Shell Script…

By wisecracker

This is a DEMO shell script to generate a simple graticule and plot inside it…

Apologies for any typos…

it is another building block along with my other two shell uploads recently to start a semi_serious project of an Terminal_AudioScope…

The fist upload I posted recently was to show how to animate colours, the second was to be able to manipulate a known bainary file to become a timebase and now this simple display…

The next upload will be a simple working unit using “/dev/dsp” for Linux through either the internal micrphone or the external mic input… The limitations of this device is that by default it samples at 8KHz, to 8 bit depth, mono, so don’t expect anything wondrous…

There is a FLAW in this DEMO. It is NOT a bug! What is it? ;o)

You need to know how the console or terminal works to find it…

Be aware of wordwrapping, etc…

Code:


# !/bin/sh
#
# AudioScopeDisplay.sh
#
# This method can also be used for a simple kids level Analogue Data_logger/Transient_Recorder
# Cannot use "setterm -cursor off" as Mac OSX 10.7.5 has not got "setterm", thought of another way for the Macbook Pro... ;o)
#
# $VER: AudioScopeDisplay.sh_Version_0.00.01_Public_Domain_B.Walker_G0LCU.

display()
{
clear
graticule="+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
printf "$graticule"
}

while true
do
display
for horiz in {2..65}
do
# Simulate an 8 bit grab and divide by 16 to give 4 bit depth. Add offset of 2 to allow
# for mssing the top graticule line...
vert=$[ ( $RANDOM % ( 256 / 16 ) + 2 ) ]
# There IS a FLAW here at _printf_, NOTE, not a bug! What is it? ;o)
printf "x1B["$vert";"$horiz"fo"
# Slow it down so you can see it working...
sleep 0.05
done
printf "x1B[20;1f"
sleep 1
done


Enjoy finding simple solutions to often very difficult problems… ;o)

Bazza, G0LCU…

Source: FULL ARTICLE at The UNIX and Linux Forums

Another Building Block, Binary File Manipulation…

By wisecracker

Apologies for any typos, and IF this has been done before…

This is yet another building block. The code generates a 256 byte binary file of _characters_ 0x00 to 0xFF for general usage and generates another binary file manipulated in a basic way.

I need this facility for a kids project I am doing that WILL be uploaded on here in the not too distant future… It will be the basis of a _timebase_… ;o)

The for loops in the code are purely for DEMO purposes only.

This is Public Domain and you may do with it as you please and this site is the first to be issued with it. It WILL be uploaded elsewhere…

Watch for wordwrapping, etc and read the code for more information…

Enjoy finding simple solutions to often very difficult problems…

Bazza, G0LCU…

Code:

# !/bin/sh
#
# BFM.sh
# A very simple DEMO Binary File Manipulation shell code issued entirely as Public Domain.
#
# Apologies for any typos...
#
# This is a DEMO to show how to generate binaryfiles in the shell.
# I need this facility for a kids project I am doing. It will be posted onto here in
# the not too distant future...
#
# To run, ensure the script is executable and from a terminal type:-
#
# *****$ /absolute/path/to/BFM.sh
#
# And away you go...
#
# Many thanks to MartyBartFast of the Linux Format forums for reminding me of the backticks... ;o)
#
# Written so that kids and newbies can understand what is going on...
#
# $VER: BFM.sh_Version_0.00.10_Public_Domain_2013_B.walker_G0LCU.
#
# Enjoy finding simple solutions to often very difficult problems...

# These two files WILL be generated inside YOUR default /directory/drawer/folder/...
# Zero them as a starter JUST for this DEMO...
> SomeBinaryFile.dat
> MyBinaryFile.dat

# This loop is to give a usable 256 byte binary file only from 0x00 to 0xFF continuous...
clear
for character in {0..255}
do
# Note:- The backticks and the four escape characters are required...
char=`printf '\\x'"%02x" $character`
printf "$char" >> SomeBinaryfile.dat
done

# Do a hexadecimal dump to prove the file is binary and 256 bytes in size...
printf "nOffset. Hexadecimal Dump. ASCII Dump.n"
hexdump -C SomeBinaryFile.dat

# Now this EXAMPLE loop is the working loop. The three variables set the "start", (_offset_), of where you want
# your file to start, the "jump" between each _sample_ and the last_byte_limit to where you want to finish...
# IMPORTANT!!! There is NO error detection or correction in the code as it is a DEMO so don't come back and
# say that you can crash it, e.g. setting the "last_byte_limit" to -1 for example...
# Also although I am using a "for" loop for this DEMO you could select a single byte manually and code accordingly...
#
# The _variables_ for this DEMO. The jump is set to every seventh byte for this DEMO.
start_offset=4
jump=7
last_byte_limit=200

# _hexdump_ is used to select the byte(s) according to this DEMO "for" loop...
for subscript in $( seq $start_offset $jump $last_byte_limit )
do
number=`hexdump -n1 -s$subscript -v -e '1/1 "%u"' SomeBinaryFile.dat`
char=`printf '\\x'"%02x" $number`
printf "$char" >> MyBinaryFile.dat
done
# Now display it...
printf "nOffset. Hexadecimal Dump. ASCII Dump.n"
hexdump -C MyBinaryFile.dat

# A terminal window dump of what should occur...
#
# Offset. Hexadecimal Dump. ASCII Dump.
# 00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
# 00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
# 00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
# 00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;?|
# 00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO|
# 00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[]^_|
# 00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |`abcdefghijklmno|
# 00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.|
# 00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................|
# 00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................|
# 000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................|
# 000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................|
# 000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................|
# 000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................|
# 000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................|
# 000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................|
# 00000100
#
# Offset. Hexadecimal Dump. ASCII Dump.
# 00000000 04 0b 12 19 20 27 2e 35 3c 43 4a 51 58 5f 66 6d |.... '.5<CJQX_fm|
# 00000010 74 7b 82 89 90 97 9e a5 ac b3 ba c1 c8 |t{...........|
# 0000001d
# Barrys-MacBook-Pro:~ barrywalker$
#
# BFM.sh DEMO end...
# Enjoy finding simple solutions to often very difficult problems...


Source: FULL ARTICLE at The UNIX and Linux Forums