Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, November 7, 2018

Ugly Christmas Sweater 2018



I just finished working on an ugly Christmas sweater for 2018.  I started with this gem, which was a thoughtful donation from a friend.  The biggest challenge I first saw with this type of sweater is that it opens up in the front, requiring some thoughtful planning to ensure there is enough power distributed from one side to the other.  In order to reduce the amount of hand sewing I needed to do (and to reduce resistance), I ended up using a combination of silicone wire and conductive thread.
To get started, I ironed some fabric stiffener to the front and neck of the sweater, because I've learned the hard way that conductive thread doesn't work reliably with stretchy yarn (without a little help).  My original thought was that I'd keep the Neo-Pixels and sensors confined to one side of the sweater, while sewing LEDs onto both sides.

The fabric stiffener did its job, but I ended up having to cut some of it out, because the sweater ended up looking rigid and boxy in the shoulders.
The next thing I did was work on writing the code and prototyping the circuit.  This took a long time, because I wanted my sweater to have the following features:

1.  Neo-Pixels triggered by a light sensor
2.  Multiple songs triggered randomly
3.  The ability to turn the music off and on with the press of a button
4.  A light display triggered by a temperature sensor
5.  A motor that did something useful  (if only marginally)

After lots of experimentation, and some judicious remixing, I have a fully functioning program! The code compiles and circuit works!  While I kept the idea for the motor alive in my code, I ended up scrapping the idea. 







Next, I needed to figure out the best power supply to use.  Initially, I wasn't sure whether a 3.7 V lithium polymer battery would work, since I was using power-hungry sensors and NeoPixels; a lipo cell ended up working fine.

Of note, the LilyPad Arduino 328 Main Board doesn't have a JST socket soldered to it, so I sewed on a LilySimple Power to add an on/off switch, as well as a place to put the battery.

Based upon preliminary tests, I noticed that  powering the circuit directly from the LilySimple Power was interfering with my temperature sensor.  The interference didn't happen whenever the LilyPad was connected to a USB port through the FTDI cable.  After a lot of experimentation with different batteries, voltages, and plugs, I determined that my problem might be that I had too many things connected to the positive (+) pin on the LilyPad.  When using a LilySimple Power, which attaches to the positive pin of the LilyPad, I thought that I needed to come up with another way to send power to the temperature sensor. 

While trying to figure out how to solve my problem I came across this LilyPad Temperature Sensor Example code, which explained that I needed to declare a spare analog pin as an output, set it to high, and then connect the positive (+) pin of the sensor to it.  BRILLIANT!

But...even after I made those changes to the code, the temperature sensor was still reading higher than it should have whenever my LilyPad was powered via the LilySimple Power.  The simple solution, which I wish I'd thought of earlier, was to modify the sensor threshold in the code itself.

To save time, I used the cording foot on my sewing machine to attach the silicone wire used for the power and ground rails going up the center of my sweater.

Very carefully, I split the coating of the wire in places where it needed to come in contact with the NeoPixels, and I hand-sewed them to gaps in the wire.





All of the wires and hot glue look pretty messy inside, but I'm hoping they'll be strong enough they way they are. 




When I turn the power on, green and white LEDs flash in an alternating pattern.  If I cover the light sensor, the NeoPixels fill with green, red, and then blue.  When the temperature sensor gets triggered by warm hands (or a warm cup of coffee), red LEDs turn on and flash.  If I want to hear one of four random Christmas tunes, I simply toggle a momentary push button and a piezo buzzer kicks into high gear, in sync with the lights!

To have a look at the code, visit my Wearable Electronics repository on Github.







Monday, November 14, 2016

A Working Prototype (#IoT)

Merging Different Functions

I've reached the point in my exploration where I've got several different functions merged into one program and a working prototype that uses alligator clips, a servo, a buzzer, NeoPixels, and surface mounted LEDs. The trick is going to be figuring out how to streamline the circuit so that it can fit neatly inside of a book (that will be built to accommodate it), with different functions playing on different pages to help tell a story of some sort.  

I just ordered some conductive fabric strips to test out for the hinges.  This tape is conductive on both sides, so I could conceivably use it on the hinges and adhere it to copper tape soldered to the Photon.

I have been unsuccessful getting a more compact servo to work with the code, so I may have to table the servo idea, unless I can come up with a way to conceal it.  The servo I'm currently using, the TowerPro SG90, is over an inch tall.  The one I want to use, the HK5320, is much smaller.  I can't figure out if the issue I'm having relates to voltage or something else.

SMD LED Function

Monday, November 7, 2016

Interactive NeoPixels with Photon and Twitter (#IoT)

Today, I spent time experimenting with code and playing around with  If Then Than That (IFTTT), which recently changed its set-up.  My goal was to start merging programs on my Photon.  So far, I've got a servo and NeoPixels running in one program, but I'd still like to add in code for a buzzer and LEDs that will be triggered by a light sensor.

My most exciting breakthrough was figuring out how to use IFTTT's "New Tweet From Search" feature, which makes it possible to trigger a web request by filtering a search in Twitter.  In the case of my experiment, I created Applets, formerly referred to by IFTTT to as recipes, that can control the colors of NeoPixels connected to my Photon, in much the same way that CheerLights work!


This could provide an interesting way to interact with a wifi-connected book.  A reader could send a tweet to change the color of LEDs in the book or scan a QR code to achieve the same effect, by triggering a Maker Event (also set up in IFTTT).  While I'd already figured out how to do this with my own Tweets, I now know how to allow other peoples' tweets to interact with my Photon.  My next step is to add code to the program so that a musical function is called in response to data received on a light sensor.



Tuesday, October 25, 2016

Triggering a Rickroll on a Photon with a QR Code (#IoT)


Over the past couple of days, there has been a lot of news circulating about security issues present in gadgets connected to the Internet of Things.  Keeping that in mind, I'm cautiously continuing my experimentation with the Photon, trying to be mindful of the fact that there are privacy risks involved in transforming ordinary objects into smart objects.

Thinking about ways that music might contribute to the creation of an interactive book that I'm going to be creating, I started tinkering with the code from Spark Fun's Music Time tutorial that plays Rick Astley's song "Never Going to Give You Up."  I tweaked the code by creating a new Particle function that only plays the music when the function is triggered by a web call.  I used the Maker Channel on If Then Than That to trigger it and linked it to a QR code (see previous post).

Even though electronic buzzer music can be a little annoying, I'm thinking that it would be interesting if QR codes embedded into a book could trigger different tunes or sound effects to help advance a narrative. 

Monday, August 15, 2016

MIDI to Arduino: Easily Add Music to Your Wearable Electronics!

I just discovered a magical tool that can convert a MIDI file directly into Arduino code that may be uploaded to a wearable microcontroller such as a Lilypad!  It's called Green Light Go -- Midi to Arduino Source Code Generator.



Using this tool is a MUCH easier way to code music than trying to use sheet music and a frequency chart to cobble a song together.  (Ask me how I know.)

To get started, your computer needs some type of MIDI sequencing/notation software, such as Rosegarden, which is open source.  From there, you'll be able to upload MIDI files and modify the names of individual tracks to correspond with the pins on your microcontroller.  This demo video explains exactly how it works.

Here's a video of my Lilypad playing the Simon and Garfunkel song The Sound of Silence through a buzzer on pin 7.

  • I started by finding a MIDI file I wanted to use on this site.
  • Next, I uploaded The Sound Of Silence [4] (MIDI sequencing by Mick O'Neill) into Rosegarden.
  • After changing the names of the tracks, I exported the file as a new MIDI file, which I then uploaded into Green Light Go.  
  • Once the code was generated, I pasted it into an Arduino sketch on Codebender and uploaded it to my Lilypad.  You can find the code for it here.
In the process of tinkering, I learned that MIDI files with a short simple tracks work much better than sophisticated files with lengthy tracks.


Friday, December 18, 2015

Running Neopixels on an ATtiny85

ATtiny85 controlling sewable neopixels
Today, I am learning how to use an ATtiny85 to program sewable neopixels, with the goal of moving toward using surface-mounted RGB LEDs in paper circuitry.  The reason that this is so exciting is because the ATtiny85 is an inexpensive, low-profile chip, making it useful for notebook hacking and art projects!  If I can figure out how to make this entire process happen on a Chromebook, it would be a huge breakthrough for classroom instruction.


At the time I was working on this project, there was still one step that required the use of a PC: the process of burning a boot loader/ changing the fuse timing on the ATtiny85.  To use neopixels, the ATtiny85 needs to run on an 8 Mhz internal clock, rather than the default of 1 Mhz. As of 11 January 2016, this issue has been fixed, making it incredibly easy to do this type of thing with students using Chromebooks!

Once I converted the chip to 8 Mhz, I was able to use CodeBender and a Chromebook to program it with neopixel sample code (with only a couple of small tweaks).

My next step was to see if I could apply this new learning to building a paper circuit with copper tape and surface mounted RGB LEDs.  The photos demonstrate a prototype using the surface mounted RGB LEDs soldered to wire!

Since I was able to get the LEDs to do what I wanted with wire, I am 100% convinced that this can be replicated with copper tape!  Stay tuned!



ATtiny85 controlling SMD RGB LEDs






















Updated 19 Dec 15:
I've created my first paper circuit with neopixels!  To learn more, visit BlingtheBook.blogspot.com.

Tuesday, July 14, 2015

Code Bender & Chromebooks: Cloud-based Arduino Programming


I've just spent the morning programming ATtiny85s (for paper circuitry projects) using my Chromebook!

I just discovered that it's possible (and easy) to program an Arduino board by adding the CodeBender plug-in to your browser!  Using CodeBender takes less time than trying to set up the Arduino IDE on a PC and allows users to access their sketches from any computer!  This is bound to save time if you are ever teaching a workshop for a group who hasn't set up Arduino on their devices before, or if your students are Chromebook users.

Lessons Learned:
1.  When using CodeBender, you cannot use an AVR Tiny Programmer on a Chromebook (you can use one with the Firefox browser, however).  Using an Arduino UNO set up as an ISP, however, will do the trick.







Monday, December 29, 2014

The temperature sensor on my hat works!

In my last post, I shared my first completed eTextile, a hat that plays Rudolph the Red-Nosed Reindeer in sync with his flashing nose! After quite a bit of trial and error, I added a temperature sensor and got my hat working the way I want it to! Figuring out the code for this sensor wasn't entirely intuitive.

For example, I wanted the buzzer music to come on when the temperature dipped well below room temperature.  When trying to figure out the code for the temperature sensor, I spent a lot of time writing things like:



if(sensorValue <=155)
and if(sensorValue <=100) 
and if(sensorValue <=50)


By using the Arduino Serial Monitor, I'd determined that the ambient temperature of my room equated to approximately 157 (I don't yet know how that translates to degrees in Fahrenheit).  I thought that using the <= sign would tell the LilyPad that I wanted it to trigger the music when the temperature went down.   This was NOT the case.

The correct way to achieve the result I was after actually looks like this:

 if(sensorValue >=155)

The >= sign doesn't seem to mean GREATER than in this case, because when the temperature goes DOWN, my music comes on.  I would like to understand this better.

In any case, when I wear my hat indoors the lights flash, but the music doesn't come on unless the ambient temperature is pretty chilly. The beauty of this is that the music should only come on when I'm outside, away from the delicate nerves of my loved ones (or to signal our need to heave another log onto the family hearth).






Friday, October 31, 2014

Mozilla Thimble: A Platform for Literacy Learning & Creative Remixing


After viewing the fantastic K12Online tutorial shared by Melissa Techman, titled Coding/Making/Writing with Connected Learners, I was inspired to tinker with Melissa's templates to make my own website.

Although I haven't created something revolutionary here (I merely altered her code and added my own images/text), I thoroughly enjoyed the process that Melissa's post made possible.  It gave me some great ideas and practical tips for organizing a similar activity with students! In her shared resources, she reminds users that parental permission is required for students under the age of 18.  (Terms of Service)

I love the way that Melissa designed a project that not only gets students thinking about books that they enjoy reading, but that she integrated coding to allow them to create unique book reviews that they share with a wider audience!   The flipping postcard (this one is mine), which she used to encourage students to create their own book reviews, has a great deal of potential!  Students can even add their own narration or sound effects!

As a fan of remix culture, I love the way that she shared her templates and demonstrated ways that Mozilla tools invite collaborative remix.  She really made my toes tingle by reminding users of the importance of attributing all images, including those with Creative Commons licenses!

I feel the need to continue experimenting with Mozilla's suite of free tools!

Wednesday, August 6, 2014

Code Camp

Yesterday at Code Camp, we learned how to create 3D spheres and boxes.  Using Processing2, we learned how to translate, rotate, and change the scale of our grid!

Here is what I created!



Today, we had time to build upon what we've been learning.  I feel like I am finally get the hang out this.



We also learned how to use Processing2 to create our our Andy Warhol inspired photograph!





Tuesday, August 5, 2014

Code Camp: Art Strand

I am participating in the Tarrant Institute's summer Code Camp at the University of Vermont this week.  We are using a programming language called Processing to create interactive works of art.

Here is the first sketch that I created yesterday!  I am most proud of the pattern that I created with the squares.  I also like that when the big, blue "breathing" circles come together, as they increase in size, that they look a bit like a monster with bulging eyes.


When I got home, I changed the code from this first sketch to create two more pieces of art (see below)!




Today, at our second day of camp, I learned how to make shapes rotate, as well as changing in size!




Tuesday, December 10, 2013