Thursday, November 16, 2017

Bare Conductive Arduino MP3 Player

I found the Bare Conductive Touch Board Starter Kit while searching for activities to do with my almost nine year old son over the school holidays. It contains a custom Arduino board with a built in microSD card reader and audio output along with twelve electrode that can be used for touch or proximity sensor input. There is also a jar and tube of black conductive paint, a brush for painting them on alligator clip wires and adhesives, stencils and cardboard cutouts for designing the sensors. A 128 MB microSD card, USB card reader and portable speaker round out the collection.

The idea is that you either paint on the sensors or clip the wires to metallic objects so that when touched it triggers the playing an MP3 track.

It turned out to be a bit too complicated for a 9 year old, but my son likes to fall asleep and wake up to music and I had the idea that I would use the kit to make an interesting MP3 player on Alex's bedhead.

The first thing was to program the Arduino board, something I was now familiar with after the ticket gate project. The code examples provided were only for the triggering of single tracks, whereas I wanted proper player navigation. This included the ability to:

  • Stop, play, pause and skip tracks
  • Shuffle tracks
  • Change the volume
  • Play collections
By default the library used by the code only plays files named in the format TRACKxxx.mp3, where each x is a number 0 to 9. I did see some code for alternative names, but couldn't get it to work so I stuck with that format.

When the shuffle mode is selected random tracks are picked. Each played track is added to a list which is scanned to ensure that it is not repeated. Skipping a track forwards or backwards only moves to the next number and doesn't use random selection.

For playing collections I made a subdirectory, in my case called sleep and placed the relevant tracks in there. I also swapped the 128 MB microSD card for an 2 GB card I'd got with an old phone. This is the largest size supported by the FAT16 library. 

The code, listed at the bottom of the post, is memory intensive and occasionally locks, but it mostly seems to work.


The need to manually copy and rename tracks made the player impractical for use by my son, who also likes current pop. Instead a I got him a portable bluetooth speaker and an old mobile phone with Google Play Music installed.

Still, after all that effort I decided to get my player working anyway and painted up a pre-primed MDF board with the stencil, affixing the Arduino board and speaker at the bottom. Each silhouette corresponds to a control. It's not intuitive, but it is artistic and I might add to the design later. I like the look of the bare white, gold and black Arduino as well, a nice reminder of what is usually hidden inside the designs.


Wednesday, November 15, 2017

Raspberry Pi 5 inch and 3.5 inch touch screens

After making the Arduino ticket gate I've been inspired to play with some of the other "maker" offerings available. I recently purchased a Raspberry Pi 3 and Raspberry Pi Zero W to experiment with. That actually takes the Raspberry Pi in the house to three as I previously bought my son a Kano Computer, which also uses a Pi board.

The Raspberry Pi can be hooked up to a standard HDMI monitor, but I wanted to try something a bit smaller so I obtained an Adafruit 3.5" PiTFT Plus and a 5.0" HDMI touchscreen. The former came with a badly soldered header and I've yet to get it working. Its instructions are also woefully out of date and unsuitable for the current Raspbian Stretch version of the Linux OS. 

For both screens what you need is the LCD-Show code. However, if, like me, you installed Raspbian via NOOBS then you are likely to get a kernel panic after installing. Don't panic!

I found these instructions to be helpful, but in my case I needed to slightly modify the boot partition statement.

  1. You need to edit /boot/cmdline.txt on the SD card, either before your Pi reboots or using a second Linux machine (fortunately I had the other Raspberry Pi Zero and a MicroSD card reader to do this on).
  2. Replace root=/dev/mmcblk0p2 with root=/dev/mmcblk0p7
If editing on a second computer put the MicroSD back in the Pi's slot and reboot.

Everything should now work and you've now got a small Linux device. Not as small as my old Zaurus handheld PC's but a lot more hackable.

Size comparison between the Raspberry Pi with 5" screen and a standard mouse

Friday, October 06, 2017

Harry Potter and the Chamber of Secrets in Concert


I wonder if they intend performing concerts for all the Harry Potter movies. In April we attended the Philosopher's Stone, tonight it was The Chamber of Secrets. Next April, Prisoner of Azkaban, assuming that I can get tickets.

What do all three have in common? Well, apart from being Harry Potter movies, of course.

These were the three movies where the legendary John Williams composed the score.

Williams was rather busy during the production so his music was ably adapted and conducted by William Ross.

For this performance at the Sydney Opera House the Sydney Symphony Orchestra was conducted by the effervescent American Jeffrey Schindler. As with the previous concert he exhorted the audience to cheer at their favourite moments and actors, which they duly did.

The performance was great, though it was sometimes hard to concentrate on the music at times due to the distraction of the movie. Williams' action score really shines through during the live performances and this was no exception, though there was one point I wasn't sure if it was Quiddich or chasing Jango Fett on screen. Williams was busy at the time...

The Chamber of Secrets is Alex's favourite Harry Potter movie out of the first three (all he's seen) and he was rapt the entire time, despite the late hour.


Earlier he and I had caught the expensive lift up Sydney Tower. Though the views were good I've seen them a lot lately out the windows of planes and the large groups of tourists reminded me how much I hate being surrounded by tourists, even when I'm one myself.


I'm looking forward now to John Williams' best Harry Potter score in the Prisoner of Azkaban. Hope I can get good tickets!

Wednesday, October 04, 2017

Arduino ticket gate - part 1

Alex is obsessed with automatic ticket gates and desperately wants one to play with in the house. Don't ask me why.

The mechanisms in automatic paper ticket gates are extraordinarily complicated and not something I could hope or want to recreate at home. However, modern gates tend to use RFID stored value cards to trigger them.

Using parts from an Arduino education kit along with an RFID module I bought at Jaycar I was able to build a simple system that triggers a servo motor when an RFID card is tapped on the sensor. It also changes the red LED to the green and plays a sound. I put a delay in to "hold the gate open".




The cheap RFID module seems a bit dodgy and the system often requires a few reboots to work. This is the first time I've soldered and used a circuit board in years. I haven't used the Arduino much either, just following a few of the examples given in the book. Still, I'm pretty pleased with the result!


Using the Arduino is so much easier than the electronics I did at uni and as a kid.

The next step is to put it in some housing and attach a "gate" to the servo. Going to get Alex's help to do that.

Sketch


/**
 * Ticket gate model
 * Detect RFID chip and trigger a servo
 */

#include  
#include
#include

#define SS_PIN 10
#define RST_PIN 9
#define GREEN_PIN 6
#define RED_PIN 7
#define PIEZO_PIN 8
#define SERVO_PIN 5

Servo gateServo;
int openTime = 5000;

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.

void setup() {
  Serial.begin(9600); // Initialize serial communications with the PC
  gateServo.attach(SERVO_PIN);
  gateServo.write(90);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(RED_PIN, OUTPUT);
  pinMode(PIEZO_PIN, OUTPUT);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(RED_PIN, HIGH);
  
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card
}

void loop() {
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  gateServo.write(180);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(RED_PIN, LOW);
  tone(PIEZO_PIN, 261, 100);
  delay(100);
  tone(PIEZO_PIN, 392, 200);
  delay(openTime);
  gateServo.write(90);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(RED_PIN, HIGH);
  mfrc522.PICC_HaltA();
}

Wednesday, September 06, 2017

Sun sets, but Oracle didn't predict it

Sun microsystems
Oracle has quietly shut down the remnants of Sun's Sparc processor and Solaris operating system lines. Both Sun and Oracle have made a huge impact on my life.

Back in 1992 I had my first encounter with Unix in a numerical mathematics course at the ANU. A number of our lessons were held in the university's computer labs housing Sun Sparc terminals. I marvelled at the huge high resolution greyscale CRT screens, opening terminals and text editors to edit and run Matlab scripts on the Solaris server. They looked so much nicer than the PCs and Macs we used elsewhere. Long before they were readily available for PCs these terminals used laser mice, though they required a special mouse mat to operate.

A year later, when I bought my first modem, I would connect into a Solaris Unix server via the terminal and access my email and play IRC. I met my wife over Solaris.

As a result of my Internet obsession I drifted into the role of web developer, eventually gaining employment at CSIRO's Australia Telescope National Facility managing their website. The site ran on a Solaris 2.6 server and for a time I even had a Sparc terminal to access it.

It was here that Oracle came into the picture. I built some web applications utilising the Oracle database, the only one available to me.

By this stage I was not a fan of either Solaris or Oracle (or 'Orrible as called by some). Much of the open internet ran on open source solutions like Linux and MySQL and, as expensive commercial products, the Oracle database and Solaris operating system often required custom compilations of libraries and custom rewrites of code. Our version of Solaris only supported 256 colours, meaning that images supplied by our users were often of too poor quality to use on the web.

A lot of time that could have been spent developing practical applications was instead wasted just wrangling the systems to work in the first place.

Eventually that job finished and I ended up writing PHP scripts on a Windows IIS box, which was a whole new set of pain.

Today I am still writing PHP, but running it on a Ubuntu Linux server, which is an extremely popular and well supported combination meaning that it's easy to find answers to problems online. But I haven't escaped Oracle, which acquired Sun in 2009, entirely. We use the very popular MySQL as our database and that was purchased by Oracle as well.

By all accounts the marriage between Sun and Oracle was not a happy one (it certainly wasn't on our servers) and I'm sad to see the disappearance of the former. Farewell!

Saturday, August 05, 2017

School dances and a cushion concert

Last night we finally had our first taste as parents of a combined schools performance when we attended the Sutherland Shire Schools Music Festival. Alex had joined the boy's hip hop group at school and they, along with a number of other schools, were performing dances at the festival.

Having seen the boys and senior girls performing the past few days at the local shopping centre and school open day I must say my expectations were low. Right from the start I was blown away by the talent and energy of many of the student dancers in a real performing environment.



It helps that they started with some John Williams music from Harry Potter. Though what was the idea playing the opening to Star Wars for a dance named "Borg" (and yes there were sound grabs of Locutus)? Obviously a proper education in scifi is lacking in our public schools!

Speaking of John Williams, I woke up this morning and spotted an Instagram advertisement for the Sydney Symphony Orchestra playing Star Wars live in concert early next year. A dream come true! I immediately snapped up some tickets.

The music continued with an afternoon concert today in Petersham Town Hall listening to The Metropolitan Orchestra performing music from movies and a couple of original compositions. This was a cushion concert for families, with patrons encouraged to bring rugs and cushions and sit on the floor up close to the orchestra. One of Alex's school friends joined us.

I'd heard the Metropolitan Orchestra perform the Doctor Who Symphonic Spectacular at the Sydney Opera House back in 2012 and was impressed with their professionalism. Being so familiar with film music as I am it is difficult for me to listen to it being played poorly.

No such problem here. The Metropolitan Orchestra were magnificent with a fantastic sound. Sitting up close we could feel every note, every percussion. More than that, they looked like they were having fun.

Every orchestra member was dressed up in some superhero or movie costume. There were Minions on Double Bass, Dorothy Vader on violin and Indiana Jones on the drums, to name just a few. All lead by their conductor, Princess Else, aka Sarah-Grace Williams.



They played Superman, the Raiders March, the Flying Theme from ET, Batman, Star Trek: The Motion Picture and a medley from Frozen. Of special note was the soloist in Gabriel's Oboe from The Mission. He played with exquisite precision, beautiful.

There were also premieres of two original compositions. The Vikings, composed and performed by one of the orchestra's French horn players was very easy to listen to and I could easily imagine it accompanying a television documentary on the warriors. Bedtime Stories was more classical in nature, with hints of Holst.

The concert ended with the Star Wars main theme, reminding me just how exciting next year will be.

Wednesday, May 17, 2017

Another car through the garden


It was about a quarter to eleven and we were just getting ready to sleep after watching some Highway Patrol repeats earlier in the night. Then we heard the sound of cars hooning around. Then a screech and a loud crash.

Not again.

Almost to the month, four years after a young drunk driver had crashed into the shrubs between our neighbour and us another driver had passed through the same space and crashed into our neighbour's house.

Along the way he demolished our letter box, hedge and most of the shrubs planted after the first incident, then down a retaining wall to land on top of our neighbour's trailer, his car just touching the lower brick wall of the house.


Fortunately the 23 year old driver was just shaken and the house survived unscathed but for a broken window and ruined flowerpots.

It could have been much worse. A couple of weeks ago another young driver in Illawong died after losing control of his car, rolling it and being flung out.

Our driver, from a house just down the street, was undoubtedly speeding in his Volkswagen Golf, as do many on this stretch of road. His brother had been just behind in his Alfa Romeo. Their specialist auto insurer Shannons was indicative of their likely revhead nature.

On the back of the car was an Apple computers sticker. Don't believe them when they say they don't crash.


A crowd of neighbours gathered around the accident. I called the police, but it was the tow trucks that arrived first, then the fire brigade, the cops and the ambulance. The freelance journalists. Then more tow trucks.




The police collected statements, the paramedics gave him a once over and presumably tested for alcohol and drugs. The fireman had little to do. For most of the time it was standing around watching the tow truck drivers attempt to haul the car back up the way it came.


By the way, don't trust any insurance advice tow truck drivers give. They just want your money. The emergency services, on the other hand, were great.

Gradually the crowds drifted away. The freelancers collared me for an interview on camera. I misstated some facts but it was way past midnight by now and I wasn't thinking straight.

The story actually featured on the Channel 9 and Channel 7 morning news, surprisingly.





So now we've got no letterbox, our beautiful hedge has been trimmed far more than I intended (granted it needed trimming) and a pair of lovely callistemon and lilli pilli shrubs is probably gone. Insurance won't pay for the garden and we are wondering if someday a car will plough into Alex's bedroom.


It's not just us. Apparently the house at the corner has had three cars in their yard and the are lamp posts and street signs suffering frequent damage. All because the idiots in this area (like most others) think they have the right to show off their non-existent driving "skills" and put everyone else in danger. I am tired of people bitching about speed limits in residential areas like this when the evidence is in - they aren't the great drivers they think they are.

They are murderous f'ing idiots.

Popular Posts