A meandering journey through the ins and outs of Mac and microcontroller communications!

8th March 2012


Is the US Government deluded?

So this blog is supposed to be about macs and micros, but having spent a day trawling the net for nothing in particular, I came to a worrying conclusion:

the US government is deluding itself and it’s people. This is based on reading 5 links.

  1. of the 5 most powerful computers out there, 2 are Chinese, and one is American (we’ll get back to this;

  2. The US TSA have introduced “naked body” scanners despite not testing whether they have health risks, or even if they work in all cases.

  3. In fact they have been shown to be easily bypassed.

  4. Now here it becomes scary! This was the officially blogged reply to the above by the TSA (read the comments also!).

  5. Finally this wonderfully arrogant report.

So what did I conclude?

That in the face of fact (eg bypassing Airport security), officials will refuse to acknowledge the issue, and will talk like teenagers rather than fix massive security or even health issues.

That a government who is outclassed in computer hardware (and most probably hacker know how, though I don’t have data) can suggest that the Chinese “are beginning to practice a capability that some senior U.S. officials say makes them near-peers,” IS DELUDING ITSELF AND IT’S CITIZENS.


30th January 2012


LEDs as sensors

So I was aware that there is a negative breakdown voltage. But actually, that is mumbo jumbo to me. But putting an LED in reverse will allow you to measure light. I began this googlethon with a link I can no longer find. But then I hit on this one! http://provideyourown.com/2011/cheap-alternative-for-hard-to-find-cds-light-sensor/ And indeed, it works (having tweeked the light level constant):

class AmbientLightSensor {
  AmbientLightSensor(int ledPin) : mLedPin(ledPin), mMeasureAnalog(false) {}
  void setAnalogMeasurement(int thresholdLevel); // measure from an analog pin
  void setDigitalMeasurement(); // measure from a digital pin (default)
  int measure();
  int mLedPin;
  bool mMeasureAnalog;
  int mAnalogThresholdLevel; // (0 to 1023)
  void charge();
  void discharge();
  int measureUsingAnalogPin();
  int measureUsingDigitalPin();
void AmbientLightSensor::setAnalogMeasurement(int thresholdLevel)
  mAnalogThresholdLevel = thresholdLevel;
  mMeasureAnalog = true;
void AmbientLightSensor::setDigitalMeasurement()
  mMeasureAnalog = false;
void AmbientLightSensor::charge() {
  // Apply reverse voltage, charge up the pin and led capacitance
  pinMode(mLedPin, OUTPUT);
  digitalWrite(mLedPin, HIGH);
void AmbientLightSensor::discharge() {
  // Isolate the diode
  pinMode(mLedPin, INPUT);
  digitalWrite(mLedPin, LOW); // turn off internal pull-up resistor, see http://arduino.cc/en/Tutorial/DigitalPins
int AmbientLightSensor::measure() {
  delay(1); // charge it up
  return (mMeasureAnalog)? measureUsingAnalogPin() : measureUsingDigitalPin();
int AmbientLightSensor::measureUsingDigitalPin() {
  long startTime = millis();
  // Time how long it takes the diode to bleed back down to a logic zero
  while ((millis() - startTime) 30) // a decent level of darkness !!! I had to change this massively
//  { pinMode(led1, OUTPUT); trying output as well as input: so far no joy.
    digitalWrite(led1, HIGH);//}
    digitalWrite(led2, HIGH);
  delay(400); // check every 0.2 secs
  // pinMode(led1, INPUT);

A couple of things to notice: 1. the capacitance (and therefore drop off time) varies by individual LED:



  1. I haven’t got the LED talking in between listening - but that is most likely me novice status.

Oh, and obviously, I am using an Arduino because it is easy!


25th January 2012



Why is it that just as I get everything installed and working, I find inventortown.com? You can edit your code online, compile online and then download the Launchpad binary, ready to install.


24th January 2012



I hope somebody is reading this! I feel like an isolated post-apocalyptic sufferer, huddled round the radio. Help us!

SOPA was just the USA, ACTA is everybody else AND the USA. Please act to save innovation:



23rd January 2012


Screwdriver and Macbook Air in hand. Cape unseen, but evil is afoot!

Screwdriver and Macbook Air in hand. Cape unseen, but evil is afoot!


23rd January 2012


Finally, getting to the point!

So here we go with a fresh install of goodness!

Before all else, install Xcode from the Mac AppStore.

Then, and unnecessarily at the moment, we install macports from source if you are running 10.7.2 as currently the binaries don’t install.

Now the macports source builder does not edit your .bash_profile, so we need to do that so the port command can be found. Here is a general work around for people not used to fiddling with Lion protected files:

Open terminal and copy and paste this code:

cd ; cat .bash_profile ; (echo '0a'; echo 'export PATH=/opt/local/bin:/opt/local/sbin:$PATH'; echo 'wq') | ed -s .bash_profile

This puts the new paths as first call when bash looks for commands.

Now let’s start doing things in some logical order.

The driver required to over ride MacOS’s desire to grab anything it can and then ignore stuff it doesn’t know about!

Download and install the Driver

Followed by the gnu tools binaries

You might as well get the breathing LED pack there while you are at it, as this will be used to prove we didn’t screw up!

More tomorrow.


23rd January 2012


Did anyone every see WiFi in the Time Machine?

Listen carefully: do not rely on a server based Time Machine backup to restore your MacBook Air when you screw up! It will take longer than the age of the universe to restore it. Fortunately, I now have the perfect opportunity to start over fresh, without the millions of failed usblib installs and other *nix detritus that was clogging my machine.


23rd January 2012


New task: get Apple talking to Texas Instruments

So here I am, starting a new year a new blog and a new goal: to get my shiny MacBook Air talking nicely to the TI MSP430 Launchpad. Now as with all things Apple vs. the World, getting stuff to happen that Apple didn’t think of can be a chore. So it is with development tools for the MSP430.

Fortunately, I am travelling in the footsteps of others: Some lead to brick walls; Some lead to Linux or Windows; But there are a few gems out there.

I am trying to stay on open source, so where better to start than GNU and gcc.

After much searching I struck gold.

http://osx-launchpad.blogspot.com/ Not only does this blog have a link to prebuilt toolchain, but there is a link to a kernel extension which enables the fabled debugging of the MSP430 on a mac. Launchpad CDC/VCP Drivers

As soon as I have more time, we will get started with the nitty gritty.