Creating an automatic laser cat toy

Building an automatic, programmable laser toy

My cat loves chasing laser lights. She loves them more than I like pointing them. So every night she stands in the usual spots and whines for me to play with her. Some (most) nights, I don’t have the energy. After buying an automatic laser toy for $40, which just goes in a circle and my cat doesn’t even chase, I decided I could do better. So I built my own.

This was my first Arduino project. I was surprised how easy it was.

You’ll need an arduino uno, 2 servos, an LED laser, and connecting wires/breadboard. You can save space by stripping the wires and directly connecting them, in which case you’ll need a utility knife and electrical tape.

Follow the links for the exact parts. The total cost was $42. Keep in mind that’s with me not knowing what I was doing. (I could have just bought 2 servos – the parts to connect them to each other come with each servo, and the only thing I really needed from the kit were the wires. This would have saved me over $10)

Step 1: Assembling the pan/tilt mount.

This took maybe a couple of hours. It should have taken 15 minutes because it’s maybe 6 pieces and some screws, but one of the plastic pieces didn’t line up and I had to cut it up a bit. Again, I didn’t know what I was doing.

Assembling the mount

Step 2: Figuring out this whole arduino thing.

I was new to arduinos but had heard good things. I found them very easy to use. It was a simple matter of downloading some software, connecting power, and connecting the 2 servos to pins 8 and 9. First I did it through a breadboard and then I connected them directly.

The program I used to test it was the simple arduino servo test program found anywhere.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position

Step 3: Wiring

This was just a matter of eliminating the breadbox and directly connecting the parts to power, and well as putting it all in a little box.

I found a small box and taped the mount to it, then taped the laser (and a motion detector – that white bulb thingy – which I ended up not using) to the mount.

I kept track of which wires went to the 5v, which went to Ground, and which went to pints 8 and 9. Then I stripped the wires and either used wire nuts or electrical tape to connect them. I stuffed the arduino and wires inside the box.

Putting it together

Step 4: programming

After messing around with coding servo movement myself, I decided to look for a library. Fortunately there is lots of code for doing exactly what I wanted already on the internet.

I found a nice one by Frank Appio. It has 12 different patterns. The complete code can be found here:

The only changes I had to make were to set the pins to the ones I was using (pins 8 and 9) and figure out the desired angles I wanted my toy to use (using the full range of 180 put the laser on the ceiling!). The code is well organized so a quick read-through told me where to make the changes (it was the first two lines in the code 🙂


And that’s it! I found a hook or two to hang my toy and let it rip! The results aren’t perfect – sometimes the laser moves towards the cat, and what cat wants to chase something that’s moving towards them – but it’s still a lot of fun for the cat and I don’t have to wave a laser pointer around forever!

(initial attempts with the motion detection failed – it keeps detecting *itself* moving!)

Edge hijacking .pdf associations

Every time Windows 10 encounters any kind of configuration error, it changes all your file extension changes back to the defaults. So for example, if you have .pdfs open with Adobe Acrobat, you will suddenly find your pdfs opening with Microsoft Edge. Yuck. Same with .png and .jpgs – they will open in the default windows photo viewer, regardless of what fancy photo viewing program you might prefer (I like jpegger).

The thing is, there always seems to be a configuration error. Any time windows upgrade runs, Edge hijacks your pdfs. Any time a service pack fails, everything is rolled back – except your file extension settings. I’ve got a windows update that is permanently never working – why? I don’t know. It’s not a big deal – it just means every time I turn on my computer, my pdfs open with Microsoft Edge.

There’s a dozen posts asking about this problem, and every single one of them, the answer is “check the ‘always open with this program’ checkbox”. No matter how many times the user explains, ‘no, this doesn’t work’, someone else gives this as the correct answer and closes the question. It works for a few days, maybe even a few months, but eventually your .pdfs will start opening with Edge.

In the past, this sort of thing would have been fixed by a script – a small program, maybe just one line, that manually sets the correct entry in the Windows Registry for .pdf, “OpenWith = AcroRead.exe”. That’s it. But starting with windows 8, manual registry edits are no longer allowed. Oh, it will look like it’s allowed – nothing will prevent you from doing it – it just won’t work. That’s because every entry now comes with a “Hash”, a secret value that stores the time of the change and a bunch of other little details, so unless you know how to set the secret hash at the exact moment as the change, it won’t work. Windows will just ignore the change and keep doing things as if you hadn’t changed anything. Infuriating.

But one clever man wrote a solution. Christoph Kolbicz wrote a program to defeat the hash, and allows you to manually change the registry. Unlike every other solution out there, this one worked first try. No more ‘right click -> open With -> choose another app -> wait for list to load -> select program -> click ‘always open with’ -> OK, every day. No more unexpected surprises where you open your .pdf, find all your nice drawings or whatever all distorted, panicking, then realize it opened it in Edge. Again.

Download both files, and simply run the .bat file, and your .pdfs will be set to Adobe Acrobat.

If you would like to run them automatically when your computer starts, place the files in your user startup folder (E:\Users\[USERNAME]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup). Replace USERNAME with the correct folder name. It will not work if placed in the system startup folder.

Never run files from an unknown source, so please scan these with whatever virus scanner you may have. You may get a one-time Windows Defender warning, because it doesn’t like anything that edits the registry – you will have to click ‘run anyway’. For full details see the original blog post, and you will see that it is legit. You can change the .bat file however you please to work with any file extension.

compact gishwhes list 2017

1 massive beach portrait
2 do younger talent
3 pancake art
4 recycled wedding dress
5 wood nymph flute in elevator
6 shadow puppet birth
7 grandparent stories
8 alien specimens
9 THAT in jello
10 Renaisaance painting pizza
11 Ghosts shopping in real ghost town
12 poem and shrine to lost pet
13 Child drawing happiness
14 pastries to firemen
15 groucho marx a piece of fruit
16 parents reminicence age 10
17 spice comic/cartoon
18 gishwhes blankets to immigrant
19 pet food portrait
20 Toy story
21 spectral olympics
22 “mythical beast, climate change”
23 moon fairies
24 raspberry beret
25 wombat poop house
26 romeo and juliet socks
27 find someone from 10 smallest countries
28 fingerpaint complex mural
29 winter activity in summer
30 visit pet shelter with friend
32 bakery donate to women’s shelter
33 tickle armpit hair of airplane
34 shave gishwhes onto body
35 flowers to religion
36 creative book mixup
37 stormtrooper in new job
38 recreate celebrity picture
39 garbage cabbage patch kid
40 full church choir sing Carry on My Wayward Son while wearing dental cheek retractors.
41 personal “Stairway to Heaven”
42 “summer wet, wild and messy activity”
43 bake non-edible shape
44 slow insect race
45 bikers in bouncy castle
46 masterpiece of collard greens
47 large-scale structure of hope
48 farm animals watching sunset
49 protest obscure issue
50 cream-filled balloon volleyball
51 sign and large military craft
52 paint a leader on bare back
53 say it with cake
54 Tweet approval for first nuclear strike US law
55 Castiel kite with a child
56 Hammock Self-Containment Unit
57 mermaid dance at a Sea Organ
58 recreate Zombie vs. Vampire War
59 sign at legislative building
60 balloon obstacle course
61 carpool kareoke with a harlem globtrotter
62 bee planting bee-friendly plant
63 paper airplane from stratosphere
64 Quilt a gishwhes onesie out of underwear
65 SuperWhoWatch chalk art
66 Personify your favorite movie title
67 Banana Bikini or Briefs
68 gishwhes banana bread
69 Tell your parents something bad that you did as a child
70 “Cook a delicious omelet using just a magnifying glass, a hot sidewalk, and the sun”
72 underwater board meeting
73 put decorated envelopes of change in laundromat
74 alien shopping cart
75 break a rule
76 caveperson glass-blowing
77 embody your team name
78 video games with pediatric child
79 SPN-themed Rube-Goldberg machine
80 shame yourself on aired footage
81 multitask on panorama
82 cover yourself in maple syrup and maple leaves.
83 vegetable and spaghetti fireworks
84 reenact childs book
85 Largest Awesome Balloon Sculpture
86 evil unicorn (may use photoshop!)
87 dress as bear in school
88 Mannequin-pin Bowling
89 lipstick on a trampoline
90 “Dressed as a chicken, offer to help people cross a busy street.”
91 Leave a Yelp review of gishwhes
92 Human NASCAR
93 elected official’s declaring gishwhes an act of lawful resistance
94 Camouflage yourself in a pet store
95 Make computer generated recipie
96 cooking tiny hamburgers & hot dogs on dental grill
97 “Gereja Ayam, indonesia”
98 puppet Trump controlled by a Putin
99 make and find a letterbox
100 “Muse in london, UK”
101 Create a gishwhes ad
102 poll 400 people on how they brush
103 place markers around the world that tell a story
104 diametrically party-opposed legislative co-wearing a Shirt.
105 decorated give-away calendar
106 “lumbasumba dance with REAL monkey, a parrot, or a camel”
107 GPS spell out message of hope
108 The chickens have come home to Proust.
109 Wonder Woman being “Superman-splained”
110 transylvanian gnu art
111 “toilet paper roses in Foshan, China.”
112 “ballet troupe in tutus, engaged in a bar brawl”
113 Maximum Security Birdhouse in park
114 Airbnb review of your mother’s womb as an “extended stay hotel
115 Seraut into an elaborate dot-to-dot image.
116 5 Star Wars characters competing in the Kessel Run in a shopping mall.
117 Dean Winchester driving a pedi-cab or quadricycle with Castiel & Sam
118 drone administering a catholic rite
119 Trump l’oeil.
120 sofa bed derby
121 tiny elf nightclub in busy area
122 Make a portrait of one of The Rolling Stones out of moss.
123 5 people chalk art at art museum
124 Hand-paint small rocks with a message of kindness
125 pixie sticks and sand buddhist symbol
126 find specific golf ball in canyon at britannia beach
127 “tricks on a BMX bike, in nun habit”
128 get gishwhes mascot on official iPhone emoji list.
129 create a “take what you need” public pantry
130 A tactometer used to measure tact.
131 Make a collage that features things only locals from your town would know about.
132 “couch surfing: real surfing, real couch”
133 sculpture of an endangered animal from trash
134 animal-infused yoga
135 Freeze frame your life with credits
136 adopt a chupacabra
137 70 year old joyride in old car with costumes
138 Show us you taking a step to overcome one of your own prejudices.
139 team knit or crochet one piece of a quilted throw
140 complex drum geometry
141 “iger & Turtle in Duisburg, Germany”
142 Fortune 2000 CEO in the lobby of his company’s headquarters on horse
143 peacenik Stormtroopers (may photoshop)
144 “chocalho, an apito, a reco-reco, and a pandeiro concert”
145 giant sized tiddlywinks
146 monster moms at Hoxton’s Monster Supplies in England.
147 “gishwhes mascot in ghent, belgium”
148 “Dress up as a superhero, budapest, hungary”
149 ice sculpture of Trudeau
150 Make and display a convincing UFO in a public place in Ireland
151 “Tashirojima, Japan, dressed as a dog”
152 decorate exterior of your home
153 wind-powered toothbrush
154 dress up as aliens in Slovakia
155 famous scupture from 1 tampon
156 archaeological finds that prove Her Majesties love
157 Tweet voyager 1
158 photoshop fun emoticons into facebook
159 longest poem about a virus
160 dress as alien in assisted living facility
161 recreate a David LaChappelle.
162 Lube luge.
163 an aquarium hat with live fish
164 zillow listing for property on Mars.
165 bored in bookstore
166 Follow a tomato back in time
167 suck 5 scoops from bottom of ice cream cone
168 Have your social media page printed on microfiche
169 write Ass butt on an Ass’s ass.
170 angel typing angelic alphabet
171 7 year old stump grinding a unicorn
172 ideal gishwhes Item List
173 complete one of these ideal items
174 An Airbnb listing for the gishbus.
175 Wild West teacup and saucer holsters.
176 TLC in Sydney or Melbourne
177 “Scottish terrier, kilt, scotch egg, Irish monument.”
178 time traveling costumes in Prague
179 audio dream diary
180 a silent film actress doing hip hop
181 “2,000 word essay on twitter about getting pregnant”
182 photoshop anacronism into painting
184 atmospheric water generator
185 be tree huggers
186 Build an edible spacecraft
188 Show us your best nose art
189 The World’s Worst Lawyer.
190 orange peels cocktail dress
191 5 miles of signs to orange juice stand
192 slow speed work
193 ZEROS ARE NOT ZEROS at math dept
194 “50 mile gps drawing of mascot, pineapples”
195 steel shred a decommissioned bus.
196 many random acts of kindness to Giles Duley
197 little known music technique
198 change a life!

The Adventures Of Mish

Chapter 1

For as long as she could remember, Mish had always wanted a dragon. She would spend her days walking along the stream, picking through the rocks, hoping to find something like what she imagined a dragon egg should look like. She had it all planned out. She would keep the egg behind her father’s forge for warmth. When it hatched she would keep it in the stable and make sure it did not set the hay on fire. When it got bigger, she would have to make sure it didn’t eat the chickens. And eventually, one glorious day, it would be big enough to ride! They would fly through the sky and have the most wonderful adventures, fighting off pirates and saving princesses! Mish longed for that day.

She searched the woods, looking up into the biggest trees, wondering if dragons laid eggs on the ground, like snakes and other reptiles, or whether they were more like birds, and laid their eggs in nests in the trees. “I think they are like birds”, she decided. Besides, she didn’t know what would happen if she stumbled across a nest on the ground. What if there was a dragon guarding the nest? She couldn’t take an egg from a mother. The mother probably wouldn’t like that, and might try to eat her. Better to take an egg from an unguarded nest.

She thought she spied what might be a dragons nest high up on one of the biggest trees in the forest, so she ran back home, borrowed her brothers’ sword, and thrashed her way through the prickly underbrush for a closer look. After several hours of futile effort trying to climb the tree to get a better look, she decided it was just a very large squirrel’s nest.

But there were no dragons nests in the trees, or on the ground, and the rocks along the stream were just rocks. After all, weren’t dragons big, and flew through the air? She thought she should have seen one by now if one were living in the area. And why would a living egg would just be lying amongst the stones and water? Mish though upon this problem daily, but after coming to no answers, she decided to ask her mother..

But her mother only smiled her slow, sad smile, shook her head, and looked away. There was no point in asking father. He would either grin and give some nonsensical answer that would have her talking to cows, or he would scowl and swear and set her to work on some meaningless task to keep her occupied.

Her brother was not much help either. “At the dragon store, dummy!”, he said. At first Mish was pleased with this answer, but after consideration, she realized there were no dragon stores around here. Even the nearest village, several hours away, only had one store. She asked but the owner said no, no dragons sold here. Maybe In the city? But that was several days away, and besides, didn’t a store mean that you had to pay money to buy things? Mish didn’t have any money, and even if she did, dragons were probably very expensive.

Her schoolteacher said he didn’t know, the other girls just giggled and laughed at the question, and other adults didn’t seem to understand the question. “You should be looking for a nice boy instead”, they would say.

And so she put the problem out of her mind.

Years went by, Mish looking the whole time, but she never found her dragon. She wasn’t worried. She had her whole life ahead of her, or so she thought, with plenty of time to find her dragon.

Then one day her mother sat her down and calmly explained she could no longer go by the stream, or walk through the woods, not by herself anyway. Mish protested. Mother explained it was “too dangerous”. When Mish rationally explained that she had been playing in the woods for years and nothing had happened to her that she couldn’t handle, Mother explained that she was “too old”.

Mish was confounded. She realized her search for her dragon would be over if she wasn’t allowed to go by the stream or the forest. She couldn’t take a friend because she didn’t have any friends, not unless you counted the silly girls at school, but they wouldn’t understand what she was looking for anyways.

Her brother was older, and he can go wherever he wants! Mother said “But he’s not a girl”, which got Mish even more confused. Seeing this mother sighed, then explained that Mish was of an age where men were starting to pay attention to her, and she couldn’t be alone anymore when she went out, or they would make her life difficult. Numbly, mish listened as her mother destroyed her life, how should would have to stay at home and help her tend the house, and her brother must walk her to school from now on. Oh, and she would have to start wearing her dress.

Mish hated wearing her dress. “How can you climb trees or fight pirates in a dress?” She thought. She remembered her dragon that she would ride someday. She had tried to ride a horse once while wearing a dress, and it was a difficult, embarrassing experience. And so she stupidly blurted out “But how will I ride my dragon!?”

She was nervous, and when Mish got nervous she made stupid jokes, and she meant it to be funny, but as usual mother took the question seriously. “Mish, there are no dragons around here. They are on an island in the middle of the ocean. They don’t leave their island, people who go there don’t come back, and the ocean around it is full of pirates.

Mother continued to lecture on how Mish needed to start behaving like a lady, with proper manners, and how it was her duty to find a husband and make babies, but Mish was no longer listening. She knew what she had to do now. She had to become a pirate!

US Soccer bans punting

US Soccer, in a document titled ‘player development initiative’, has banned punting at the younger levels. A new line 1/3rd of the way up the field will be created, and opposing players have to move behind that line every time the goalie gets the ball. The goalie is then expected to throw or roll the ball to a teammate in an un-pressured situation. This is supposedly to help younger players ‘develop’.

In other words, US Soccer has banned one of the most fun moments of the game in order to someday, hopefully, win the World Cup.

If we had a youth athlete who was neglecting anything in his current life in order to win the World Cup, we would tell him that he was being ridiculous. There’s currently less than a thousand american players that play at the international level compared to what, 10 million youth soccer players? The odds of a youth player playing internationally are something like one in a billion. The odds are much smaller if we are talking the World Cup. We would tell that kid to go watch Coach Carter starring Samuel Jackson and stay in school. Colloquially speaking, “don’t quit your day job”. Yet when the official soccer organizing body of the United States of America tells kids to ‘quit their day game’, somehow it’s ok.

US Soccer states player development is the most important thing at the youth level. False. The most important thing is fun.

I currently have a U10 team. The only reason anyone wants to play goalie is to punt the ball. Every kid loves punting the ball and the urge to do it is, for whatever reason, highest at this level. It’s the only thing they can do well as a goalie. Can they dive? No. Proper positioning? No. Coming out on a breakaway? More likely they will keep backing up into their own net. But one thing they all can do is punt. It’s fun to do and it’s fun to watch.

Parents love a good punt. The ball sailing majestically the entire length of the field… They ooh and ahh and say ‘what a great punt!’ (They never go ‘what a great throw!’) It’s an exciting moment of the game where everyone on the field starts running in anticipation of that booming kick.

Instead, US Soccer wants to take away that excitement. Why not just ban goals? If you want to change the rules of the game to force kids to get better at passing, it’s the logical choice. Just mandate a game of keepaway for an hour straight. Don’t even have points, because that is too similar to keeping score, which is focusing on winning, and therefore bad.

Or why not ban goalies? Players have to score from within the goal box. Right now, goalies don’t do much with their feet. Is learning to throw the ball a valuable skill? No. It’s not even fun. So why not just eliminate goalies entirely? At least that player will get some field time, run around, use their feet and gain ball skills.

If the goal is really to force players to do short-distance passing, it’s the logical choice. Ban throw-ins, goals, long-range shots, and goalies. Make it like some indoor soccer fields, where they paint lines on the field, and if the ball travels too many lines at once, it’s a foul. Just like the Icing Rule in hockey. Most soccer fields in america already have American Football markings on them – why not use those? If the ball travels more than twenty yards without being touched, its a foul.

Why don’t we do that? Oh, right, because that would be bloody stupid! Long passes are an integral part of the game, and so is punting. There is quite literally no other way to send the ball seventy yards up-field. It’s a valuable tactic to deliberately create a loose ball and gamble on your team recovering it, if it gains you field space. It’s why the pros do it, else they would just send the ball short every punt or goal kick. And as a tactic it is even more valuable at the younger levels.

U10 players literally don’t have the strength to do accurate passing. Forcing a team to do something they are not capable of doing well, at the inevitable cost of more goals scored against them, is a recipe for getting kids and parents to quit. This is US Soccer forcing little kids to use a tactic because they feel that’s how the game should be played.

Make no mistake. This type of short passing game is how the pros do it, not the average youth team and parent, who is perfectly content to yell ‘send it!’ and chase it to the corner. ‘Development’ is US Soccer trying to get American to compete at the international level. It’s sacrificing millions of kid’s fun to create that one superstar.

If they had disguised this ‘no fun’ initiative in the guise of protecting kids heads, that I would understand. Heading has been recently banned as dangerous, and most headers at the youth level come from punts (there’s no other moment in the game where the ball spends enough time in the air for kids to deliberately get underneath it). So I could understand banning punts because they were dangerous. But banning punts in order to force short passing?

The rule also states they want to create a ‘low pressure’ situation for passing. The rule as written will not accomplish that. Currently the rule says ‘as soon as the ball is put into play’ the other team can attack. So what this means is the other team will line up on this 1/3rd line, and as soon as the goalie releases the ball, they will charge. That’s not ‘low pressure’. That’s a free kick, or a kick-off.

If US Soccer really wanted to create a low pressure situation, they would force the other team to stay behind the 1/3rd line until the ball crosses it. That would give the team unlimited time to learn to pass. Currently it gives a player what, three seconds? That’s how long it takes a kid to sprint twenty yards.

And why draw an extra line? The 1/3rd line is just formalizing the distance the other team has to move away, which was never a problem. No little kid ever hung around the goalie hoping to intercept his punt. Why not just say they have to get back 20 yards? I like the 1/3rd idea, but what I don’t like is taking away the choice of a punt. By forcing the play to the ground, it’s like turning every punt into a goal kick.

If you’re going to change rules, why not just allow players to receive their own goal kicks within the penalty box? Goal kicks happen more often than punt situations. Teammates are already allowed to stand in the box. Why force leagues to go through the hassle of drawing new lines on the field? At the U10 level, the goal kicks are so weak they sometimes can’t clear the ball out of the box, and the referee has to stop play and tell them to take it again. It’s a stupid rule, has an easy fix, and would accomplish the same thing as this ‘player development initiative’.

Or why not just allow youth goalies unlimited time to release the ball? Often the ‘high pressure’ we see deployed by the opponents comes because the goalie rushes the release.

The rule also states the goalie can pass the ball. A pass is defined as a deliberate strike with the foot. A punt is defined as dropping the ball and kicking it before it hits the ground. I see a simple loophole here – just drop the ball, let it bounce, then kick it. It’s a pass, not a punt. Or you can be really fancy and teach kids to do the half-volley kick, where goalies drop the ball and strike it a millisecond after it touches the ground. (It gives it backspin which lets it stay aloft a little longer)

All these loopholes, discussion of ‘development’ and adding, not simplifying, rules, tells me the ‘no punting’ initiative is poorly thought through and misguided. I beg US Soccer changes their mind before making the rule mandatory in August of 2017.

Review of Best Served Cold by Joe Abercrombie

Best Served Cold is Joe Abercrombie’s best, and worst, book.

In case you don’t know Abercrombie, the best part of his books are his characters. Best Served Cold has some of the best characters he’s ever written, like Friendly, the cleaver-wielding cook who gets along with everyone, unless they insult his dice. There’s my personal favorite, the depressed poisoner, obsessed with poisons and getting people to like him. And of course there’s the strong female main character, Monza, the Butcher, the Snake of Talins. Favorites from previous books also make an appearance.

Abercrombie forces his seven characters together with wildly different motivations. Sex, money, revenge, the antidote.. Then he makes them hate each other, revealed through murderously philosophical dialogue. I hung on to every unrealistic word. He ratchets up the tension to unbearable heights (or lows), and at times I had to put down the book and remind myself not too get too attached because you know someone is going to die (which doesn’t happen how you think it will).

And oh, the fight scenes! Abercrombie does some amazing fight scenes, and the plot of Best Served Cold – revenge on seven powerful men – gives him a chance to write not one, not two, but seven action packed fights to the death.

Now for the bad. This is Abercrombie’s first book after his hugely successful First Law trilogy. He’s experimenting, and he makes everything extreme. It works with the characters and dialogue, but other parts are borderline unreadable. I admire Abercrombie’s clinical precision in describing fights and injuries. No unimaginative screaming from his characters. But in Best Served Cold, he goes on for pages and pages of this stuff, how ‘the silky smooth sword penetrates the flesh’, bones, blood, yada yada. Pages of the stuff.

There’s torture scenes. They do have a purpose, to provide motivation or show the evilness of a character, but to spend several pages on them, while you the reader wince at every detail, it’s just too much. You wonder if he enjoys writing this. In the dedication to Best Served Cold, Abercrombie warns us that we will read this book and worry about him.

And then there is the mandatory sex scene. He doesn’t do just one, but three or four. Again, he goes too far, and pushes it from borderline rated-R to blatantly X-rated. I don’t want to read about a guy’s cock. (Does anyone??)

Abercrombie also throws in some weird supernatural elements, supposedly foreshadowing events of future books, but it just comes across as forced, out-of-place. Best Served Cold lacks the polish and precision of all his other books.

My advice? Read the prologue, the first ten pages or so. It’s the best scene in the book, second only to when Friendly avenges his dice. If you are hooked, then keep reading. If you find yourself wincing once too often, then skip Best Served Cold.

Review of Otherland by Tad Williams

Most science fiction/fantasy books are simple. One or two main characters, an evil villain, and stuff happens. But every now and then comes along a work of fantasy or science fiction that approaches something resembling literature. Otherland by Tad Williams is such a book. It features not one, not two, but five main characters, each with their sidekicks, backgrounds, families, motivations and environment. An African professor and her zulu ‘bushman’ sidekick. An online barbarian, invincible in virtual combat but is suffering from progeria and about to die in the real world. A serial killer with the power to disrupt electronics. A wheelchair-bound hacker whose story is told through the eyes of a five-year old girl. And the character who dominates the book, Jonah, who is permanently lost in the belly of a virtual reality based on literary classics.

Each chapter of the book jumps between these characters. Each character has their own plot, and as a reader you feel like you are reading five different books where nothing happens. Eventually things start happening to each of them. One’s brother falls into a strange coma. Another experiences online visions. Another finds out about this mysterious virtual reality called ‘Otherland’, the hacker seduces a little girl, and Jonas, the lost one with amnesia, well, I just started skipping all his chapters once I figured out the author was just using those chapters to recreate literary classics such as Through the Looking Glass, The Odyssey, Peter Pan, Wizard of Oz, Aesops Fables, and more surreal adventure-type books.

By the end of the book the characters come together and you manage to piece together the plot: A bunch of bad guys have discovered a way to trap people in virtual reality while their real body falls into a coma. They plan to build their own virtual reality, called Otherland, one where they can alter reality. They plan to trap humanity in Otherland and become gods. The only one who can stop them is the guy with amnesia, Jonas. We’re not sure how yet.

So the main characters and their sidekicks – a British vampire; a kid who only talks in annoying techno-babble; a faithful archer; an almost-sentient robot – nine in total, just like The Fellowship of the Ring – set out to traverse the depths of this crazy virtual Otherland, find Jonas, and save the world. Oh, and one of them – you don’t know which – is hacked by the serial killer, who is planning to kill them all and seize the god-like powers for himself, waiting to strike at any moment.

The book is an epic setup of a thousand pages. It’s complicated, requires patience, and is not for the casual reader. I’m looking forward to book two.

Grumpy at the grade 7 advanced recertification.

I took my USSF Grade 7 referee certification this morning. First, an explanation of what that is. Almost every soccer referee starts at Grade 8 (under age 13 starts at grade 9). It’s just an arbitrary number. Theoretically you can get to Grade 1.

You have to get re-certified every year. It’s just a multiple-choice test. It costs money, something like $45. But for $25 more, twice a year somewhere in the state you can take the ‘advanced re-certification’. You take the same written test, just get an 80% instead of the usual 70%, and you have to take a fitness test.

I could not find consistent information on what the fitness test consisted of. I found other states guidelines and used those as a basis for my expectations. You have to do some 40m sprints, a 150m dash – “no problem” I thought.. Turns out Wisconsin is a lot tougher than Nebraska.

Instructions were to be on the starting line, ready to sprint at 8am, at Waukesha High School. This meant a 5:30am wake-up time for me. 🙁 I managed to survive getting out of bed and actually made it there on time and was proud of myself. Then they announced what we would be doing. It was to be SIX 40m sprints, with a timed break inbetween, and then SIXTEEN 150m sprints. SIXTEEN. Not Six. You had to do each in 35 seconds, then walk 50m in 40 seconds, and then do it again. If you missed one, just one, you failed. No second attempt, no extra lap, just. Done. Only 8 of 13 passed. This one poor old guy kept going even after he failed… This test discriminates against experience.

I passed (The sprints were easy for me, but the last 2 dashes were brutal – My stamina is horrible if I’m not chasing a ball). Then it was on to the classroom part of the test. Once again another classroom environment that does not appreciate questions Or alternative points of view. It probably did not help that I brought in Jello Shots (true – they were leftovers I had made for Halloween trick-or-treating, that didn’t get eaten because it rained and few trick-or-treaters came to my door. I brought the Jello Shots in, announced they were for anyone who wanted one, and was told “That’s not appropriate.” and to take them back out to the car.)

Let me give you a taste of what this class was like.

In soccer, the definition of a foul has, for as long as I can remember, required one of three things: careless, reckless, or excessive force. The definition has always been up to the referees to decide. Good judgement and all that. I’ve always taken them to be three different words for the same thing. After all, the consequences for the same are the same, they all fall into the same category of fouls, and the dictionary definitions of them are complementary.

A similar rule exists for yellow and red cards. Each has a specific criteria. For example, unsporting conduct (whatever that is) is a yellow card. Serious foul play is a Red card. These rules exist independently of each other. You can have a yellow card but no foul, or a foul with no card. Each is evaluated separately.

But in this class we were introduced to a new publication from USSF, one that turns this relatively simple rule into a muddy, sticky mess. We were introduced to this new publication with the clarification that this is NOT the “advice to referees”. That one is wrong and should be ignored. This one is the “Guidelines for referees”. Guidelines, not Advice. Don’t get them confused.

The publication is larger than the rules book. These ‘guidelines’ now clarify things by introducing a lot more new rules (sorry, not rules, just guidelines). They talk about ‘tactical purpose’ and what constitutes an ‘obvious opportunity’. But back to the careless, reckless or excessive criteria, the heart and soul of what constitutes a foul.

Now, with these new ‘clarifications’, careless means ‘not being careful’ and reckless means ‘complete disregard for an opponents safety’. Excessive force means force placing the opponent in a dangerous situation. In addition, BY DEFINITION, careless means no yellow card. Reckless now, by definition, means you MUST give a yellow card. Excessive force now requires a red card.

Definitions are all good and well, but the problems with these definitions are numerous.

First off, they contradict the existing rules for yellow and red cards. The list of offenses leading to a yellow (or red) card are well defined. ‘Being reckless’ is not one of them.

A similar problem exists for the definition of ‘excessive force’, saying that it is dangerous and therefore deserving a red card. The problem there is, the rules for direct vs indirect kicks also say that ‘dangerous play’ is an indirect (and by implication a less serious) foul. So which is it? A minor indirect kick? Or the most serious punishment possible, a red card?

Second, this secondary publication is called ‘guidelines’. Are those rules or not? Anyone getting a yellow card for a reckless play can simply put out the argument ‘where is that in the rules?’ It’s not. It’s in the secondary publication for referees. It may be official – but then why not put it in the rules? Why a secondary publication?

Third, the definitions defy common sense understanding of the words. Careless means reckless. Reckless means careless. Look it up in the dictionary. Excessive force could mean several things – any larger, or more coordinated player colliding with a smaller or off-balance player, thus resulting in the smaller player falling down, could be accused of ‘excessive force’. I’ve used excessive force myself, and I know it is something different than being ‘dangerous’. Using more force than necessary, and sending an opponent flying a little farther than you should have, does not mean its dangerous.

Fourth, the definitions include a tautology or self-defining logic. If I give someone a yellow card, then BY DEFINITION it must be reckless. So I can punish a similar foul two separate ways (And there are many reasons why I might punish one team or player more stringently than other), and when questioned why I gave player One a red card but player Two no card, all I have to say is “Oh that was excessive force.” or “Oh that was careless.” And what made it careless and not reckless? “Oh, because I didn’t give a card.” It’s a convenient dodge for referees to help them avoid explaining their decision. It’s circular logic, begging the question, and provides no real explanation.

And lastly is the simple observation I posed to the class: “Every five-year ever does not consider the opponents safety. They’re not capable of it. You’re saying I should be giving every kid a yellow card?”

I point these things out to the instructors and they get grumpy. One of the guys was on the USSF national advisory committee and could not give me a satisfactory answer for why these two publications are separate, or how to resolve the discrepancies. He claimed he saw no issues. The guy running the clinic and who is the head assignor for all referees in Wisconsin became visibly upset when I pointed out the flaws in logic. His assistant stepped in a gave a lecture how we as referees are required to “enforce the rules, regardless of our personal opinion”. He kept looking at me. I asked “Why do you keep looking at me?” His response: “because you’re driving me crazy!”

I may be a bad ref, but I’m an expert at not knowing when to quit. Seeing the distress of these poor instructors, I suggested an alternative definition, one that I was taught years ago, a definition they used to teach, and a definition that both makes sense and is compatible with the existing rules.

My alternative definition, which I tried to offer as politely as possible, was the concept of intention. A foul that was merely clumsy, where the defender was genuinely trying to play the ball and not contact the opponent, and either misjudged his own skill or the skill of his opponent, and instead UNINTENTIONALLY kicked the other player, should be merely a foul; no yellow card.

If instead the challenge was an intentional foul, then it should be a yellow card. This falls under the category of unsporting conduct. Any intentional foul, regardless of its severity, should be considered unsporting. Makes sense to me. (And of course a red card is something extreme, not just excessive but downright unconscionable. You’ll know it the instant you see it. I don’t like that definition but it seems to be true, and was the guideline given by the instructor. It’s so rare its not an issue. The argument here is between yellow cards and no cards.)

The instructor, again, didn’t seem to appreciate me. He stepped forward and asked “How do you know what their intention is? Can you read their mind?” I don’t know if he was serious or being a smart-ass, but this is a question I’ve thought about and although the question surprised me, I had the answer ready.

“Yes”, I said. “I can. I can look at their eyes, I can read their body language. Yes I can tell what’s going through their mind. That’s my job. Every call I make I’m judging their intention.”

Nervous laughter rippled through the class. My answer might have been funny but I wasn’t joking. It’s true – I do read their minds, to the best of my ability anyways. I tried to clarify this. I explained that the concept of intention is already used in the wording of the rules. The word “careless” has the word “Care” in it. It implies their intention, or lack thereof. The handling rule explicitly uses the word ‘intentional’. Another rule about yellow cards says if someone fouls ‘deliberately’. Yet another guideline uses the phrase “With the tactical purpose of breaking up a promising attack”. Purpose, deliberate, care – all different ways of referring to someone’s mental thought process, or intentions.

And yet the instructor scoffed at me! He pulled out the rule book and read a rule aloud. “There’s no mention of intention” he stated. “Purpose!” I countered. “Purpose means the same thing!”. He shook his head, make a derogatory sound, and turned away. Scoffing!

I was miffed. I don’t know what’s so controversial about what I said, or why the lack of acceptance.

Then we got to the actual test. It was a group test, which means we could help each other (in groups of 3 or 4). You’d think that would make the test easier, but it did not. Everyone asked everyone else what they thought, and it was rarely unanimous, and that led to debates, which lead to wording and interpretation. Sadly, I opened my mouth in these crucial moments to suggest alternative interpretations. (I’m really good at multiple interpretations of words.) All were suggestions and questions, and I totally expected to be vetoed down (I just wanted to be thorough or careful), but that led to me being rejected outright when we came to a question I was certain of the answer.

Question: “Someone kicks a direct free kick directly into their own goal. What’s the call?”
Answer: “Corner kick”.
I was certain of this one. The correct call is a corner kick for the other team. You cannot score on yourself from a dead ball/free kick. I stated as such, and to my dismay, my partners went “mmmm, I think it’s a goal.”
“No, I am certain about this one. its a corner kick.”
“Mmm. It’s a goal.”
“No, I’m not guessing here. I’m 100% certain.”
“Mmm, that doesn’t make sense.”
“I know, but that’s why I remember this rule. The correct answer is C. I’m positive.”
“I think I’m putting down A” (Chorus of agreements)
“No, I’m POSITIVE its C”
“Well you can put down what you want.”

I used the strongest language I could, expressed the most emphatic opinion I was capable, and was dismissed. Well then, screw you guys too. You just keep listening to the pretty girl and putting down what she says – I’m gonna put down the correct answer.
So from that moment on I just ignored my partners.

It was the third hardest test I’ve ever taken. The first was in my “Advanced algorithms” class (I got a 58%, the third-highest(!) grade) and the second was Organic Chemistry II, Where I got a D (64% if I recall). This test I got a 72%. Passing required an 80% or better. I failed.

Turns out, it didn’t matter! After the instructor read the correct answers, he announced everyone passed! He then took the questions and our answers back, without going over what we got wrong or why we got it wrong. It was bullshit. I only remember a few questions I got wrong; whatever I managed to remember in the two minutes I had to review the correct answers. And what I know I got wrong I’m not certain what the correct answer was, or why.

Here’s the online form we used for the pre-test. As you can see, it doesn’t show the correct answers and is, ergo, useless.

I think they did this to cover their own incompetence. Ok, not incompetence – their mistakes. They made a lot of mistakes. Here’s what I remember in those initial minutes.

After the test they handed out copies of the 2016 Rules of the Games (Yippee, I can replace my battered 2012 copy) and I immediately looked up the answers to what I could. They got several answers on the test wrong. For example, the question “Which of the following is a requirement for penalty kicks?” Answer A) read “The keeper must have both feet on the goal line”. I stopped right there and wrote “A” because I know that is a requirement. The correct answer was supposedly C), “all players except the kicker and goalkeeper must be behind the penalty mark.” That is also true, but then that makes the answer to the multiple choice both A) and C). I asked my partners what they had, and they all said they had C). It was supposedly not A) because keepers can, so they said, stand on OR BEHIND the goal line. Wrong. I looked up the rule, it says they must be on the goal line. (I remembered this because last year they modified the rule (For high school rules) to add the phrase ‘facing forward’. The idea of a goalie sticking his butt out towards the kicker intrigued me so I made a special study of the rule).

Another answer the test got wrong is the answer to ‘what happens if someone other than the designated kicker steps up and kicks the ball into the goal’. They said it was an indirect kick for the other team. False, because the rule specifically says if there is an infraction and the ball goes into the goal, the kick is retaken. Emphasis on “into the goal”, which was specifically stated in the question. The instructors seemed to have added that phrase unthinkingly.

There was another one saying a player who steps into the goal (beyond the goal line) is “leaving the field without permission” and is considered an “outside agent”. Interfering with the play then falls into the ‘outside agent’ catchall, meaning its a drop-ball. I disagree, because players constantly leave the field in the normal course of play, whether running after the ball or just absentmindedly stepping off. Technically it’s leaving the field without permission, but hence the concept of “implied consent”. It’s not a phrase anywhere in the rules, but that’s what it is: implied permission. He’s not an ‘outside agent’!

There were several more ‘iffy’ questions like this, like should you card a player who is about to leave the field with the referee’s permission but then jumps into play and plays the ball. They said yes, its a card; its unsporting conduct. I argued ‘no, it is not a substitution until he actually leaves – before then, it doesn’t matter what happens.’ Their counter-argument was the question says nothing about ‘substitutions’ or that play had stopped. I asked “When else does a player get permission to leave the field??” but did not get an answer. Iffy.

Still, I was disappointing in my performance. Hostile classroom non-withstanding, I should have done better. I’m grateful to the instructors for passing everybody. I would have preferred an explanation, and a chance to see what I got wrong (I hate being wrong!) but it didn’t seem to bother most everybody else so… go with the flow.

I’m a grade 7 referee! Yey! (Which means nothing other than bragging rights)

cubieboards part 2

It turns out cubieboards are unstable at higher CPU load. Cubian desktop from my prior post kept crashing on me. When I tried fancier stunts like auto-login and auto-execute programs, it would crash beyond repair. After several re-installs, I determined I had to go with a different operating system.

Not wanting a completely bare-bones version of Linux, nor a fancy Desktop X with all the bells and whistles, I went with something called cubieez. Written for cubieboards, it is lightweight, stable, and has a graphical user interface.

The steps required to get the hardware pins (GPIOS) to work were slightly different than my previous post, so I’m going to document them here.

My steps:

  • Install cubeez (SD version)
  • Buy an SD card and a way to attach it to your Windows PC
    Download Cubieez
    Download Win32DiskImager
    Using Win32DiskImager, write the cubieez image to the SD card. Put SD card in cubieboard and turn it on.

  • Set load to desktop: no
  • Right click anywhere or use the main menu and open a terminal.
    Type in Cubie-config and find the settings to turn off the desktop. From here.

  • Set up auto-login
  • This is just changing one line in /etc/inittab. Read here.

  • Install sunxi-tools
  • Sudo apt-get install sunxi-tools (for bin2fex and fex2bin programs)

  • Edit FEX file
  • follow the steps here
    To decide what to add to the file, read here and here.

  • install gcc
  • sudo apt-get install gcc build-essential

  • Write, compile and test c code
  • sudo nano test.c
    compile and test c code
    Read here and here. You’ll need the necessary wires and diodes.

  • Auto-execute your c program
  • in /etc/profile, add 2 lines at the bottom:
    modprobe gpio-sunxi

    (where test is the name of your c program)
    reboot (sudo reboot) and your c program should automatically execute

Saving your work

I was sick of re-installing and losing all my code, so if you want to save your code in case of a crash or wipe, you can save everything online in a GIT repository.

Go to and make an account. Login and create a repository (choose to automatically use the default readme). Get the link to your new repository (for example, mine was this:
On your cubieboard install git if not installed (Sudo apt-get install git), then type these commands:
git config --global "YOUR NAME" (use account name)
git config --global "YOUR EMAIL" (use account email)
(From here)
mkdir git-repo
cd git-repo
git clone
Copy your code to the repository folder with
cp /root/test.c .
cp /root/test .

(where test is the name of your file)
Add it to your project, commit it, and push it online
git add .
git commit -m "a message"
git push origin master

(From here and here).
Your code is now saved online and can by copied back to your computer by doing
You can view all my code here

A complete beginners guide to Cubieboard 2

I just got my hands on a cubieboard, and all the potential that it comes with.  Like making your own portable play-any-video-game system!



Holy cow!  Write a program, plug it in, and BOOM amazing awesome stuff happens!

Well, not quite.

I had a hard time getting going with my cubieboard, so here is a quick guide on cubieboard programming.

First off, what is a cubieboard?  I had never heard of it before, and could have used a brief explanation.  Basically it is the computer that drives tables and smartphones.  Its a tiny programmable computer with hardware pins you can hook up to anything.  Maybe you have heard of its smaller cousin, the Raspberry Pi.  There is a google book on the topic, well written for complete beginners.  Check it out here.

So a cubieboard is a computer, right?  So I did what you do with any new computer: I eagerly plugged it in and looked for the power switch.  Or tried to.  Let me tell you right now, it doesn’t come with a power cord and there isn’t a power switch.  It goes on when you connect a power source.  Fortunately my laptop power supply worked (if you don’t have one, try here).  Unfortunately, my cubieboard did not come with any operating system.

It’s supposed to come with android pre-installed.  Mine didn’t, for whatever reason.  Turns out it didn’t matter, because you are supposed to install a different operating system no matter what (apparently android sucks?).

Install an operating system??  Don’t panic!  It wasn’t that hard.

Back in the old days, you had to load a CD with an operating system, fiddle with BIOS settings to load the CD on boot, reset your computer, and go through a several-hour long process.  A cubieboard is simpler and faster.

First you need a “MicroSD” card and a way to connect the MicroSD card to your regular computer.  I didn’t have one.  I had to run to walmart and picked up both for a total of $12.96.  Plug in the MicroSD card to your computer and follow these instructions to copy Cubian to it.  Cubian is an operating system specifically for cubieboards.  It is a modified version of Linux.  If you plan on doing any programming on a cubieboard you WANT Cubian.  Do not follow other tutorials saying you should install Debian, or Ubuntu, or BootBerry.  I tried those.  Debian produced a devious flicker, and Ubuntu, while it looked very pretty and was easy to use, kept crashing after an hour.  BootBerry, while written for Raspberry Pis, worked well, but did not provide an option to install Cubian.  Cubian has everything preconfigured.  You won’t need to muck around with FEX files or kernels (more on this later).

This guide assumes you are going to use the pins on the cubieboard, to hook them up to buttons or sensors or whatever (thats where the true power of a cubieboard lies).  There are a few things you need to know about the pins on the cubieboard, things that took me a while to figure out.

First, pins are NOT GPIOs.  Pins are the physical bits of metal sticking out of the board.  GPIOs are abstract things that must be created.  They CAN be pins, but for the cubieboard you have to assign a pin to a GPIO.  (Click here for info on GPIOS).

Second, there are 96 pins (count em) but you can only use 60-some of them.  Why?  I’m not sure.  Some pins carry pure voltage, or connect to ground, which is why they cannot be used as inputs/outputs, but that only explains about 5 pins.  The other 25+ I have no idea about.

Third, pins and GPIOs have a different numbering system.  Pin 1 is NOT the same as GPIO 1.  In fact, Pin 1 on the cubieboard is a direct connection to the power supply, so you cannot use it as a GPIO no matter what.

Fourth, you must assign pins to GPIOs, by something called a “Fex” file, sometimes referred to as “script.fex” or “script.bin”.  This is done automatically if you installed Cubian.

Fifth, the pins (and by proxy, the GPIOS) have weird messed-up names.  Pins, while numbered, have names like “CSI1”, “DEF”, “VCC-1”, etc.  Usable pins, pins you can assign to GPIOs, have names like “PG3”, “PD5”, “PE9” (they all start with P).gpio_defination_large[1]

Sixth, you need to know all the previous 5 steps.  Sorry, it’s true.  You need to know the names of the pin, the pin numbers, and what pin corresponds to which GPIO.  Fortunately, there is a handy chart found here.



The bottom line is, Cubieboards are DUMB.  They cannot detect their own pins.  They don’t know which pins are inputs or outputs.  They know nothing.  You need to install an operating system just to get a cubieboard to do anything, and the only free operating systems (Linux, Android) are not meant to work with physical pins.  If you don’t use Cubian, you would have to install special software (called a Kernel) to get the Operating System to access the pins, then you need to install special software to access the files that access the pins, then you need to edit the files – its a pain.  If you really want to know more, click here and here.

All this was backround information to the big secret: pins on a cubieboard are accessed via files.  Edit the file on the operating system, and the voltage on the cubieboard changes.  Or, if its an input, change the voltage and the file changes.

This took me a day to realize, so I’m going to repeat it.  All those tutorials on programming GPIOS and code snippets are about one thing, and one thing only – someone has invented a way to access each GPIO on a cubieboard by modifying a regular file.

Try it yourself, right now.  Assuming you have cubian installed, type in
echo timer > /sys/class/leds/blue:ph21:led2/trigger
and your cubieboard should start blinking (the blue light).  Here is the full article.  If you don’t have cubian you will have to install a package called sunxi-leds.

What’s going on here?  Well, if you know Linux, you know that “echo” just outputs some text – “timer” is a special code word – and the “>” symbol just means ‘write (or “pipe”) to this file’.  The file is called “trigger” and is in the /sys/class/leds/blue:ph21:led2 directory.  Yes, that is a valid directory name in Linux.  So we are putting the word “timer” in the file called “trigger” and the cubieboard automatically starts blinking!  It’s brilliant, and works for every GPIO on the cubieboard.

Unfortunately, these special files do not automatically exist.  They do for the above example, the blue blinking light, and the green light, but for everything else you must create them for each pin or GPIO.  So here are the steps to enable a hypothetical GPIO #1:

In your linux command prompt, type:

echo 1 > /sys/class/gpio/export

(Note that echo 1 corresponds to the number of the GPIO you want to use.  If you want to create, say, GPIO #21 you would type ‘echo 21’ instead).

This is the command that creates the magic files that connect to the pins.   If you type ‘ls’ in the command prompt, you will see a new directory created.  Unfortunately, the new directory is named after both the GPIO you created and the name of the physical pin.  So the new directory will be called something like “gpio1_pg3” where the first part is the name of the GPIO (which you created) and the second part is the name of the pin (which you have to memorize from the chart).  It’s stupid, but what can you do.

Now decide if this GPIO is going to be an input or output.  That is, do you want the voltage going to this pin changing based on what a computer program is telling it what to do (output), or is the pin going to receive voltage from some external source and a computer program detects it (input)?

If it is input, type
echo “in” > /sys/class/newdirectory/direction
or for output,
echo “out” > /sys/class/newdirectory/direction

Now you can either set the value of the pin/GPIO directly (if it is output) or detect it using the cat command (if it is input).

To test this you will need an LED/diode and a small jumper cable.  Connect pin #1, which is a direct connection to the power supply, with your now GPIO pin#1 (named ‘pg3’, fourth from the top, right-most row.  See diagram.)  Connect the short end of the LED/diode to pin 1 (the direct voltage) and the long end to pin ‘pg3′(again, 4th from the top right)

.  2015-09-01 23.19.52

Then in the command prompt, type
cd /sys/class/gpio/gpio1_pg3
echo 1 > value
and the LED/diode should light up.  (Picture)2015-09-01 23.23.27

Amazing, right?  By now you should realize that
echo 0 > value
will turn it off.

If you’ve made it this far, and understood everything up to this point, all you need to do is understand how to do everything programmatically.  I’m trained in the C language, so I’ll do my examples in C.  Most examples out there are in Python.  Use whatever programming language you prefer.

You’ll need to know how to create and compile a program in C.  So install the C compiler, then using your preferred text editor (I prefer the simple nano) create your C program ( called it ‘test.c’), then compile with the command gcc test.c, then run it by typing ./a.out.  Here is my complete program to turn on the LED:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){

FILE * fp;

if((fp = fopen("/sys/class/gpio/gpio1_pg3/value", "w")) == NULL){
printf("File not found");


return 0;

The key is using the fprintf() command.

To detect if a pin voltage has changed (meaning the pin is an input) you do a similar process – Open the file, and check if the value is 0 or 1.  You can do this in linux by going to the directory/file and typing in cat value  (See video).  1 is the default, and when you hook up the pin to ground (which is something like pin #20) the value will change to 0. (note this is different for output – output you attach the pin to VCC (pin #1), not ground).

In C, use the fgetc() command:

     int ch;
     fd = open(filename, O_RDONLY);
	ch = fgetc(fd);

	if (ch != '0') {
	} else {

Hope that helps beginners with cubieboard.  Good luck!


EDIT: turns out there are stability problems with cubieboard2 and cubian. Read about my adventures here in part 2.