カテゴリー別アーカイブ: Arduino

「フロラブレラ」プロジェクト完了(Adafruitが作ったデザインのLED傘)

UntitledAdafruitが作った楽しいプロジェクトです。作り方の説明は、Adafruitのサイトにありましたので、作り方の写真などをアップしないつもりです。近所の子供たちにも大好評。一番楽しかったことは傘を横に向けて回すことだそうです。

  2015-03-26 20.20.50 2015-03-26 20.20.47 2015-03-26 20.14.33

背景

johnny5家族と電気プロジェクトをしようと話したときにまずロボットはどうだ!って聞いたんですが、興味はないようでした。僕の子供の頃の一番好きだったロボット-ジョニーファイブ!でも反応無かった。。。

そんな背景があり、Adafruitの色々なプロジェクトを見せたら(特に服または服にかけるプロジェクト)、興味を持ってくれたので、以下のプロジェクトを一緒に決めました

RGB LED with Fixed Brightness

Fading the RGB LED was fun to figure out but it was too “blinky” to use for most things I could image. I wanted to have it fade smoothly through the available spectrum AND stay at a constant brightness. Here is the slightly-more-zen-less-blinky RGB LED:

The code below is an update of the previous code. It uses a very simple normalization method – just scale everything by the same amount to reach a target brightness.

By the way, this was developed on codebender and I’d like to say thanks to them for the excellent site and tools. In fact, you can run the code below on your arduino directly from this page.

Bugfix on Piezo Music Example (Circuit 06)


Updated: From the friendly people at Oomlout.com who make the ARDX:

Thanks for explaining the issue to us, we’ll get it marked to be fixed in the next update run.


Going through the ARDX tutorials, the piezo music one was nice and simple. However when I listened to the output, there was something off. It wasn’t keeping the beat. You can hear it below at the end of the 7th note (Twinkle twinkle little star …).

Twitch. I have some musical kids books that have this same bug. Twitch every time.

The original note logic goes like this:

  • note_beats[i]: how many beats to play the ith note
  • beat_time: how long for each beat
  • pause_time: short pause after each note so notes are audibly separated

So complete_note_time = (note_beats[i] * beat_time) + pause_time

This is fine when all notes have the same number of beats. However when each note is held for various beat counts, the pause time does not get extended so each note is no longer a full beat. Let’s do the easiest fix (although not the best):

Now complete_note_time  = (note_beats[i] * beat_time) + (note_beats[i] * pause_time)

No more twitch:

Here is the code with the fix noted on the pause line.

Smooth Spectrum for an RGB LED

I want to share this modification to the RGB tutorial since it was fun and looks nice. This RGB LED which came with the Adafruit ARDX kit is actually just a packaging of 3 LEDs sharing a common lead on one side. Controlling it is (almost) exactly the same as controlling 3 separate LEDs. It’s important to note that this particular RGB LED is common anode(+) which in the end means that unlike the other tutorials, 5V ==> Off; 0V ==> Max brightness.

Anyway here is some code that continuously and smoothly runs the LED through a (basically) non-repeating spectrum.  It’s not random but it will appear random to the human eye. Importantly, the steps are smooth so there are no sudden shifts in color or brightness.

Arduino – ARDX Kit Mounting Problems and Solutions

I have the Arduino Uno (mine is R3) and the ARDX kit as sold by adafruit.com. I  ran into some problems mounting it.

No room for the nut next to the power jack.
No room for the nut next to the power jack.

If you follow the instructions with the kit, the bolts go up from under the board. However the nut barely has enough room to fit next to the power jack and definitely doesn’t have enough room to rotate. Adafruit suggested turning the bolt to tighten it – somebody else may be able to get that to work but I couldn’t due to having the second nut which also needs to be tightened.

Invert the bolt.

So you can invert the bolt – then the head fits nicely next to the power jack and it’s easy to tighten everything well.

Have to clip the excess bolt length beyond the rubber feet.
Snip snip.

Now you will have to snip the bolt to be shorter than the rubber feet. They are almost the same height so you may need to remove the nut before cutting.

Additionally, I had to snip the soldered power jack lead below the PCB because it was longer than the spacer nut. I guess it should probably be desoldered before snipping but I was too lazy and not confident enough for that.

Arduino ARDX Kit Fits after Mod
Mounted and ready.

Everything fits now. Hopefully adafruit will update the package for future orders. They never answered my question on the forum about updating it so I’m doubtful.