A Simple Kitchen Timer with CircuitPython

A simple program demonstration of object-oriented CircuitPython

Arduino has been a lot of fun, but Python still remains my most favorite programming language. So, it would be inevitable that I venture over to CircuitPython, right?!

Recently, our digital kitchen timer went kaput, so that gave me an excuse to buy a new microcontroller (or two, or three. Hey, they’re so cheap, why not pick up a few!), and become acquainted with new programming environment. This time, I went with Adafruit’s Gemma M0. Round and as small as a quarter, I liked it not only for being so cute, but also for convenient, quick projects. Gemma input/output pins are in the form of sew pads that also fit a 3mm screw, so it’s easy to alligator clip or screw in wires. Breadboards are fun, yes, but this is quite convenient, and the finished assembly is attractive as is, without a need to create a printed circuit board.

So, here’s my simple kitchen timer, with a piezo buzzer wired to the back via screws:

Continue reading A Simple Kitchen Timer with CircuitPython

Interrupt Programming with Arduino

Setting up interrupt functions on Arduino is quite simple. Search the internet, you’ll find several nice tutorials on the subject. I’m just sharing my own example for style, and to clarify, why do interrupts at all?

Interrupts are immediate, and they allow clean separation of concerns between main (loop) code and special-purpose functions. Like object-oriented programming, they clarify code intent.

The main loop() function typically has delays built in, so while you could test for a button push in the loop, it may take a while before the loop gets to that point in the code, so you’ll see a delay between the push the resulting effect. An interrupt does what it says – it interrupts the main loop and executes all the code in the interrupt function first, before returning back to the main loop.

Continue reading Interrupt Programming with Arduino

Object-oriented Programming with the Arduino Microcontroller

A Traffic Light Simulation with pedestrian crosswalks

These days, when I’m not managing teams and projects, I am primary a Python developer. But, recently I took it upon myself to learn Arduino, and it’s been fun going back to old hobbies – building circuits and C!

The Arduino programming language include some C++ elements as well, especially classes, so this has allowed me to introduce object-oriented design concepts as well. Here’s a simple circuit with two interconnected traffic lights, programmed in such a way that neither can be green at the same time. The connected pedestrian crosswalk switches initiate a countdown, then switching one light to red before allowing the other light to turn green. I’ve added an additional safety consideration for broken red lights.

Continue reading Object-oriented Programming with the Arduino Microcontroller

Carless In Houston

“What, you don’t have a car?!”  I’m in Houston, Houston’s a car town, everyone in Houston has a car, right?  Well, not everyone.  I had been using public transit for many years, so was already used to it, but it really became pressing 3 years ago when my son moved off to college. Do I buy him a car?  Or wait, why not give him my car, do I really need it?!  I examined my own transportation habits, and realized I could easily do without a car, and in fact even enjoyed being without a car.  Technology and service improvements have made it much easier these days, so give him the car I did, and couldn’t justify the expense of buying another one.

So, these days, I get around in Houston without a car.  Well, almost – my wife still has a car.  It’s a cherished classic car, though, a 1985 Mercedes, we give it a limited range, used mostly on weekends when we venture outside the loop to Chinatown.  (strike that – since September 2017, we have no car). Beyond that, we use alternate transportation.

I am not exclusively a public transit user.  These days, my modes of transportation are:

Each have their utility for different transportation needs. Continue reading Carless In Houston

Jakarta Contrasts

(see  also Indonesia and a “million dollars of problems”)

In 1997, Jakarta was in the throes of economic expansion. Our view from our apartment on the 16th floor of the Ascott presented a remarkable array of skyscrapers and shopping malls. The Japanese-funded malls were spectacular multi-level affairs, each of them rivaling Houston’s Galleria.  The skyscrapers were modern and sleek.  But, my young kids were fascinated by a contrasting view, of the open field directly below – a family living in a tin-roof shack right next to a fetid green canal.  Living without electricity and water, our kids would watch them in the morning, as someone would walk out to an empty spot in the field with bucket in hand to take a sponge bath or relieve themselves.  These folks, though, were at least surrounded by a lot of open air – just another block away was a squatter kampung, a crowded, tangled arrangement of shacks, handmade concrete-brick buildings, and dark alleyways.

Walking down Jalan Thamrin or visiting Blok M, local Indonesians hardly paid us any attention -they were middle-class Indonesians, office and service workers just like any other city.  But, a mile off the beaten path, a visit to an open market or the nearby Textile Museum, suddenly were were noticed by everyone. Hellos (“halo” or “selamat”) and smiles greeted us – the more daring would want to touch our pale skin or take photos with our children.  We often went out with our neighbor Alaude, a young red-hair Dutch woman, and she was even more exotic to the locals.  Much to Connie’s chagrin, they assumed Alaude was my wife and Connie the nanny; they would stop us to get a picture together, or surreptitiously line up a photo of themselves with us in the background.

Continue reading Jakarta Contrasts

Happy Birthday, Walter Grinder!

I didn’t realize that Walter Grinder and I almost share a birthday! Today is his 75th birthday, and numerous students and professors are writing tributes to Walter, so here’s mine.

Walter Grinder’s history is intertwined with history of the Institute for Humane Studies.  Coincidently, IHS was also born in the same year as myself. IHS was instrumental to my college education. Though I was a computer science major in college, I also minored in economics, and it was an econ professor who first recommended me to an IHS summer seminar. So, in 1981 I fly up to Valley Forge for a week-long seminar (all-expenses paid, at that!), where I first met Walter Grinder. He good-naturedly teased me for being the rare student from the south (most IHS students then seemed to come from the West or East coast), and was even more surprised to find I was a Cajun.

Well, this first encounter with IHS led to many – a week-end seminar in the fall, (can’t remember where), and the following spring a week-long seminar in Chicago, where I met the esteemed Voluntaryist George H. Smith, as well as the legal theorist Randy Barnett, among others.  Then, in the summer of 1983, I head to another IHS economics seminar at New York University, along with my friend Gerard Mildner. While there, we were offered a summer-long research fellowship at IHS. It was quite a special honor, as only 8 to 10 students were selected that summer. So, very excitedly, we make our way back to Houston, Gerard and I pack up our belongings in his car, I strapped my bike to the back bumper, and we make for a 2-week long road trip to Stanford University.

Walter Grinder was the anchor of IHS then, steered our young interests in productive ways, and was an ever-present figure in the Menlo Park office. He still good-naturedly teased me for being a Cajun, living on the bayou or such, but one evening, after reading some essay I wrote, he exclaimed, “Kevin, you are like a diamond in the rough”. As a mentor, I was assigned the esteemed, and very friendly, professor Shudha Shenoy. I was recall that Larry White was there that summer as well – not as an undergraduate research fellow, I think, but in some other capacity.

I biked all around Menlo Park and Palo Alto, and my best days were spent in the Stanford University library, 8 million books strong, as well as the Hoover Institution Library. My only regret was the research paper I finally wrote for that summer – looking back at it, I think it was rather uninspiring and mundane.

Wind forward a few years later, after marriage, the birth of our first daughter, and then her passing away, I felt a little lost, and decided to further pursue my 2nd greatest interest (beyond computer science), and enrolled in the PhD economics program at George Mason University. And, lo and behold, IHS had moved there, as well as Walter Grinder. Of course he still remembered me well, and was a key recommendation for me to get a full-scholarship to school.

Walter has made it his lifelong career in investing in and developing human capital, the creative mind. Happy Birthday, Walter!

America’s Foreign Policy Calculus

The United Nations is far from perfect, that I agree. But, it is our channel for international peace and diplomacy, and I am dismayed to see a U.S. President yet again bypass, ignore, and generally disregard this institution. Yes, I’m an idealist – I sincerely believe that War does not have to remain a permanent condition of mankind, that we can eradicate it, and ultimately replace it and all its surrounding institutions with processes of justice, diplomacy, and liberalism. There are steps we can make in this direction, but unfortunately, America’s foreign policy is far from traveling down this path.

Here’s some sweeping assertions about our current situation:

  • There is an America foreign policy regime
  • It is, if you will, a “spontaneous order”, a long-operating result of varied interests and processes.  Eisenhower named it “the military-industrial complex” – “complex” is a good word here; it is not simply a cabal, a small, smoke-filled room of profiteers, king-makers, world conquerors, whatever. It’s not a sinister plot, or conspiracy, but the systemic outcome of lots of players.
  • These players include the military itself, military contractors, intelligence communities, foreign policy think tanks, etc.
  • These players do not all have the same interests, but their interaction still produces a consistent outcome.
  • This complex has had a continuity, and consistency, that outlasts Presidencies.
  • This continuity stretches back to at least the early 1960s, but probably has its roots in WW2, with the permanent establishment of a Department of Defense (previously called Department of War), the CIA, and a few other key institutions.
  • This continuity is fed by an increasing percentage of taxpayer money that is directed its way.
  • An old Constitutional restriction – no appropriation of funds longer than 2 years for the raising of Armies – the that would have perhaps provided some brakes to this self-perpetuation, is largely ignored these days.
  • The general outcome of this regime is to #1, perpetuate itself (a lesson from Public Choice ECON 101, of course).
  • The regime is driven by “realpolitik”, not idealism.  Liberty, democracy, the human condition, are all secondary issues to its preservation of itself and “American Interests”.
  • The regime has a focus, and thus produces analysis and attention to, areas where its interests can be preserved or enhanced, and ignores other areas, no matter how stridently offensive to liberty, democracy, or humanity.  For example, the long-running Congo war has been completely ignored in the U.S. for decades.
  • A secondary factor in this focus is gamesmanship against other world powers that may threaten its dominant position in the world today.  Namely, Russia and China, though to a lesser extent, even Britain and France.
  • Its foreign policy “calculus” first analyzes this question: “if we take an action in this direction, will it enhance our interests?”.  This calculus extends even to regime change – either directly pondering assassination of foreign leaders, or supporting rebel causes that may lead to the toppling of a foreign leader.
  • Being realpolitik, this calculus will of course seek to preserve foreign leaders, no matter how undemocratic or brutal they are, if that means its interests are preserved or enhanced.
  • World events are still unpredictable, so the regime must react to events it doesn’t always control, and refactor its calculus
  • Thus, we’ll see the U.S. supporting certain players, such as Osama bin Ladin, Qaddafi, or Saddam, during certain periods, only to withdraw support later.
  • The regime doesn’t always win.

Robert’s Rules of Order, Diagrammed

In the distant past, I was a certified parliamentarian. On occasion, I still do chair meetings, or all called upon to provide some training on parliamentary procedure. Most recently, last weekend I was asked to prepare some training notes for a group of folks, so I started refreshing myself on Robert’s Rules of Order. That led me to thinking, “how can I visualize all these rules, in a simple flow?” The result is this diagram, below the fold.
Continue reading Robert’s Rules of Order, Diagrammed

Notes on Parking Ordinance Changes in Houston

The City of Houston Planning Committee is considering changes to our parking ordinances. Some notable changes include increasing the parking ratio for restaurants (from 8 to 10 spaces per 1000 square feet) and bars (from 10 to 14 spaces per 1000). These rules come on top of an already increasingly “suburbanized” parking and building rules. In general, not good. I’ll try to make it to the hearings on these changes, and below are some of my talking notes

I speak for myself, but some credentials:
– Inside-the-Loop resident for many years
– office in Rice Village
– board of directors of a non-profit shop in Rice Village
– married to a Montrose-area cafe owner

In summary, what I want to present here is “one size does not fit all”. Houston is a very diverse city, don’t define a cookie-cutter ordinance to meet a very varied problem – instead, more local dialogue and collaboration required.
Continue reading Notes on Parking Ordinance Changes in Houston

Cross-Platform CSS for Translucent DIVs

Had a need recently (in 2011!) to make some translucent (semi-opaque) elements on a Web page. CSS3 supports an “alpha” channel, the “a” in rgba, to provide color opaqueness, but IE 7 and 8 do not support this attribute.  So, most web developers resort to using a translucent background-image.  However, there is a pure CSS way that is compatible with all modern browsers today (IE6 ignored, of course).  This takes advantage, though, of some CSS parsing bugs, so may not satisfy the CSS purists out there, but it works for me 🙂

Demo: solid background inner-box surrounded by a translucent box, overlaying a background-image.

Continue reading Cross-Platform CSS for Translucent DIVs