The Blog

One Arduino Sketch To Rule Them All

It's been awhile since I've posted anything on the website, but I've been busy with other projects... and the most recent Arduino related project.

This newest project isn't shield, but rather a sketch that is designed to let you upload a single sketch to your arduino, configure the arduino and let it do it's thing.

Introducing macro's for your arduino!

Basically, these are going to be macros that read an input and do something to an output. So far you can take a digital measurement and make a digital pin do something based on that input. ie. if digital pin 2 is low than turn pin 13 high. If pin 2 goes high turn pin 13 off. In addition, you can also do things with analog readings as well. They are a bit more complicated, but the code is almost done (I'll be releasing the alpha when that part is done).

On the analog side of macros you'll be able to take an analog reading and compare it (greater than, less than, or equal to) and do something to a digital pin. (or TLC5940, PCF8574)

I'm not stopping there though. Right now I plan on integrating a RTC, TLC5940, onewire temp sensors, PCF8574 into macro's as well.

So you'd be able to say to your arduino, turn pin 13 on when temp > 78 or when hour == 8 turn pcf8574 pin 2 on.

The best part is that macros are store in the arduino eeprom (1024 bytes in a 328) so you'll be able to store hundreds of them (if you need that many). Pin modes (input/output) are also store in eeprom and changeable via commands (pin states can also be controlled by serial commands)

Implications?

Well, this code is going to be the successor to my aquarium project code. That code requires you to have a certain setup (namely mine) for it to work. With this new code you send some serial strings (for now, but I plan on integrating wifi and ethernet) to the arduino which programs the pins and macros and you've got your own custom setup.

Since the code is going to probably be bigger than 30kb I'm also implementing something interesting. In the beginning of the sketch you uncomment the 'modules' of the code you'll be using. Code is wrapped in #ifdef so if you comment out a module it won't be compiled in... which means lower size with the ability to control your shields. For example, if you want to use ethernet instead of serial you can uncomment #define ETHERNETCONTROL 1 and comment #define SERIALCONTROL 1 and the serial portion of code won't be loaded into the sketch, but ethernet will.

The code allows for different control types to be easily integrated. Basically, you re-implement the serial side of things, but things like pinMode, pinStatus, and macro setup are generic functions. So with ethernet to change pinmode you would get the pin # and mode (0/1) and pass it to setPinMode. It's as easy as that to add in different control options. Of course, wrap them in #ifdef and define a variable to enable/disable that code and you're off.

If you're interested in becoming a tester send me an email. Complete serial control of the arduino itself should be finished in a few days with other shield support coming shortly.

A dedicated project page will be up with the release of alpha code.

Oh, and I need a name for it so suggestions are welcome.

Iphone Controlled Arduino PWM Icicle Lights

The Arduino PWM Icicle lights are nearing completion (the code is done at least). All that's left to do now is get them hooked up with some wire and make a nice string of them (leave the easiest part until last). It took me quite a bit less time than I originally thought to code everything which I always like. I'll attribute that to using the excellent jQTouch library.

If you haven't checked out the first post you can view it here: Arduino PWM Icicle Lights

Not much has changed since that video other than the fact that they can now be controlled wirelessly. To accomplish that I've used an Xbee shield on the Arduino and an Xbee Explorer (from Sparkfun) to link the Arduino to the computer.

I'm using xampp on the computer to give me apache and a php extension which allows me to write the serial port (it's not open source, but I plan on porting the code to an open source extension I found... the extension I'm using is here).

Update: I've rewritten the serial control file. It's linux only at the moment. It should be pretty easy to port it to use serproxy, but I couldn't get that to work.

The code for the webapp I'm using can be found here

At the left you can see a screenshot of the webapp. It uses jQtouch (which is pretty simple to use), jquery for form submission.

Video Demo

 

Arduino Code

Can be found here

Arduino PWM Shield Icicle Lights Prototype

It's getting close to that time of year again. Time to put up Christmas lights. This year I kind of wanted to go a little overboard and have all the lights RGB and Arduino controlled. What I've come up with is a project that's going to use a PWM Shield, RTC, and Wifi/Xbee shield.

Why do I need all that hardware to control lowly Christmas lights? I really want to be able to have some cool effects run, as well as have them turn on and off automatically. As a kicker I also want to be able to control them via my phone (I will admit that's a bit overkill), but the end result is going to be pretty cool.

Click For Larger Image

The main shield behind this project is the PWM Shield. It's basically a shield that has two TLC5940's daisy chained together. For the project I'll be using two (each shield can be daisy chained to another shield using a simple jumper wire).

In the photo above you can see that I've hooked up the RGB LED's to the shield. Each LED required 3 channels and each one is hooked up in order. ie. Channel 0 = Red, Channel 1 = Green, Channel 2 = Blue, Channel 4 = Red etc.

Click For Larger Image

Above you can see a shot of the prototype. I've only got 6 lights hooked up (because I need more jumper wires as they make nice sockets for the led's); however, adding more led's is simply a matter of changing one int within the code.

Video

Next Steps

Sometime in the near future I'm going to finish the string and add in a RTC and either a Wifi or Xbee shield (not sure about the wifi because their shield may use some of the pins that the PWM shield uses). Once that's done I'll make a little webapp so I can control everything from my phone (which of course I'll release :-) ).

If you have any questions, comments or suggestions I'm all ears. I'd love to hear some ideas for sequences.

 

The Code:

#include "Tlc5940.h" int green; int blue; int red; boolean flipflop = true; int num_rgb = 6; int num_channels = (num_rgb * 3) - 1; int maxbrightness = 1000; int seq1_red = 1000; int seq1_green = 0; int seq1_blue = 50; int seq2_red = 0; int seq2_green = 1000; int seq2_blue = 0; /* Red = 1 Green = 2 Blue = 3 */ int fadein_color = 1; int fadeout_color = 2; int color_min = 0; int color_max = 1000; void setup() { /*You can optionally pass an initial PWM value (0 - 4095) for all channels.*/ Tlc.init(0); Serial.begin(9600); } void loop() { for(int i=0; i<10; i++){ blink_alternate(); } for(int i=0; i<4;i++){ fade_through_flipflop(); } for(int i=0; i<4;i++){ fade_through(); } } void blink_alternate(){ Tlc.clear(); if(flipflop == true){ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(i % 2){ Tlc.set(green, seq1_green); Tlc.set(blue, seq1_blue); Tlc.set(red, seq1_red); }else{ Tlc.set(green, seq2_green); Tlc.set(blue, seq2_blue); Tlc.set(red, seq2_red); } } flipflop = false; }else{ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(i % 2){ Tlc.set(green, seq2_green); Tlc.set(blue, seq2_blue); Tlc.set(red, seq2_red); }else{ Tlc.set(green, seq1_green); Tlc.set(blue, seq1_blue); Tlc.set(red, seq1_red); } } flipflop = true; } Tlc.update(); delay(1000); } void fade_through_flipflop(){ Tlc.clear(); if(flipflop == true){ for(int j=0; j<=maxbrightness; j++){ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(i % 2){ if(fadein_color == 1){ Tlc.set(red, color_min + j); }else if(fadein_color == 2){ Tlc.set(green, color_min + j); }else if(fadein_color == 3){ Tlc.set(blue, color_min + j); } if(fadeout_color == 1){ Tlc.set(red, color_max - j); }else if(fadeout_color == 2){ Tlc.set(green, color_max - j); }else if(fadeout_color == 3){ Tlc.set(blue, color_max - j); } }else{ if(fadeout_color == 1){ Tlc.set(red, color_min + j); }else if(fadeout_color == 2){ Tlc.set(green, color_min + j); }else if(fadeout_color == 3){ Tlc.set(blue, color_min + j); } if(fadein_color == 1){ Tlc.set(red, color_max - j); }else if(fadein_color == 2){ Tlc.set(green, color_max - j); }else if(fadein_color == 3){ Tlc.set(blue, color_max - j); } } } delay(10); Tlc.update(); } flipflop = false; }else{ for(int j=maxbrightness; j>=0; j--){ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(i % 2){ if(fadein_color == 1){ Tlc.set(red, color_min + j); }else if(fadein_color == 2){ Tlc.set(green, color_min + j); }else if(fadein_color == 3){ Tlc.set(blue, color_min + j); } if(fadeout_color == 1){ Tlc.set(red, color_max - j); }else if(fadeout_color == 2){ Tlc.set(green, color_max - j); }else if(fadeout_color == 3){ Tlc.set(blue, color_max - j); } }else{ if(fadeout_color == 1){ Tlc.set(red, color_min + j); }else if(fadeout_color == 2){ Tlc.set(green, color_min + j); }else if(fadeout_color == 3){ Tlc.set(blue, color_min + j); } if(fadein_color == 1){ Tlc.set(red, color_max - j); }else if(fadein_color == 2){ Tlc.set(green, color_max - j); }else if(fadein_color == 3){ Tlc.set(blue, color_max - j); } } } delay(10); Tlc.update(); } flipflop = true; } } void fade_through(){ Tlc.clear(); if(flipflop == true){ for(int j=0; j<=maxbrightness; j++){ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(fadein_color == 1){ Tlc.set(red, color_min + j); }else if(fadein_color == 2){ Tlc.set(green, color_min + j); }else if(fadein_color == 3){ Tlc.set(blue, color_min + j); } if(fadeout_color == 1){ Tlc.set(red, color_max - j); }else if(fadeout_color == 2){ Tlc.set(green, color_max - j); }else if(fadeout_color == 3){ Tlc.set(blue, color_max - j); } } delay(10); Tlc.update(); } flipflop = false; }else{ for(int j=maxbrightness; j>=0; j--){ for(int i=1; i<=num_rgb; i++){ red = (i * 3) - 3; green = (i* 3) - 2; blue = (i * 3) - 1; if(fadein_color == 1){ Tlc.set(red, color_min + j); }else if(fadein_color == 2){ Tlc.set(green, color_min + j); }else if(fadein_color == 3){ Tlc.set(blue, color_min + j); } if(fadeout_color == 1){ Tlc.set(red, color_max - j); }else if(fadeout_color == 2){ Tlc.set(green, color_max - j); }else if(fadeout_color == 3){ Tlc.set(blue, color_max - j); } } delay(10); Tlc.update(); } flipflop = true; } }

Maker to Makerpreneur - Part 1

The other day I had a wonderful idea. Wouldn't it be great to write a series chronicling my own experiences with turning things I've made into a nice little side business? With the maker movement gaining more momentum all the time wouldn't it be great to have a resource you could turn to where you could learn how to turn something you love into something you love and can make money from?

My Background

I'm a PHP programmer (mostly) although I've always been very interested in electronics. Ever since I was young I've been taking things apart to figure out how they worked (when I was young it was more a case of breaking them). I discovered Arduino a little over a year ago. I actually stumbled across it (via stumbleupon). I was immediately hooked.

After doing the basic Arduino code I started to find things around the house that could be improved using an Arduino. Number one on my list was my aquarium. It had so many little things that needed to be measured/controlled. Since there were no shields that did what I wanted to do I learned eagle and designed my first circuit boards.

They weren't very pretty, but they did work and I learned some things along the way. After posting in the Arduino forum (and on my website) about what I was doing I had people inquire as to whether I was selling any... and overnight I turned into a Makerpreneur.

Although we moved recently you can see my Maker space in the photo on the left. It's not a big space, but I've been able to successfully prototype 5 shields that filled a need that I had.

The First Rule

The first rule is don't start building something for somebody else. If you're serious about becoming a Makerpreneur make something that fills a need in your life first. For me that was controlling my aquarium.

By finding something that fills that need you can be sure that you'll be able to draw on the passion you have for fixing that problem. When I started I had no idea how to route a circuit board, but I learned because I really wanted to fix my problem.

That's what the maker movement is all about really. You find a need that you have and fill it with something you make. You can guarantee that there are more than a thousand people with that same need that you have.

Which is where the business can come in.

The Key To Success

One of the worries that comes up is somebody is going to steal my idea and profit for themselves. I don't really think that's true anymore. Those in the open source world care a lot about attribution (myself included) and I have yet to see someone release my designs as their own.

The whole key to getting people to notice you is to contribute. If you want somebody to look at your widget than post on a forum what you're doing. Ask for feedback and get others involved. If someone has a problem that you know how to solve than help them solve it (@jcrouchley has helped me countless times).

On top of that make sure you have your own website/blog. When you're starting up don't worry about having a store on it, just worry about posting what you're doing. This generates interest and also valuable feedback (my commenters have left me amazing ideas).

Do Something and Don't Worry What Others Think

Before I wrap up this post up there's one more nugget. Even if you have mistakes in what you've made go ahead and make it and show it to people. When I started I was chastised a little bit because it seemed I had no idea what I was doing (and there were mistakes). Ignore those people and listen only to the ones who give you valuable feedback (I find in the open source world many are willing to help the clueless... as long as it isn't something you couldn't find on Google).

 

Make sure to keep checking back for new posts in the series. I'll be discussing everything from how to come up with design ideas all the way to promoting, selling, shipping, ecommerce and a slew of other topics.

Stay tuned!

Arduino 'Bonjour Like' Library

A lot of the projects that I'm currently working on I want to have a mobile phone (or computer) interface for. The aquarium project, as well as the home automation shields and environmental shields I'm working on are all connected via ethernet or wifi. My problem was I kind of wanted to just deploy them with a generic sketch and do configuration from the phone or computer.

The Idea

The phone app could query my LAN with a string and when any arduino receives it the arduino could reply with capabilities.

ie.

  • In app settings put 192.168.0 for your network
  • phone sends out requests to 192.168.0.1 to 192.168.0.255 with string 'ARDUINOACK'
  • If device is arduino it replies 'ARDUINOACK'
  • Device IP is store into database

Once the arduino receives the 'ARDUINOACK' it subsequently replies with it's capabilities (and ip) in JSON format which the requesting app than stores in a database.

The result is you could deploy any number of arduino devices with a generic code base and remotely monitor/configure them.

Sample Algorithm

  • open app and input ip range 192.168.0
  • Click 'Find Devices'... phone sends requests with 'ARDUINOACK' with it's ip address to 192.168.0.1 to 192.168.0.255
  • Arduino replies with 'ARDUINOACK' with ip address
  • app sends 'REQUESTCAPABILITES' to found ip addresses
  • arduino returns JSON list of capabilities (includes number of devices as well)
  • Sample JSON string: {ip:192.168.0.100, location:unknown, ds1b820:3, photosensor:1, wifi:1, bnc:2, eeprom:1, sdcard:1,ds1307:1}
  • app stores arduinos ip address and capabilities
  • You give that arduino a name in the app
  • Open that arduino's settings and the page presented is based off the arduinos capabilites
  • ie. if it replied with {output:5} you could toggle output 3 to off (or set a timer, or on/off times)
  • ie. it replied with temp sensors attached and when you open settings it would show the temperature values.

I haven't really started on the arduino code; however, it will mostly be copied from my arduarium project and made a bit more modular.

The mobile apps are being made in phonegap (having to relearn javascript again) and there will be both android and iphone versions.

Cool Stuff

Here's just a sample of some of the cool stuff you could do.

  • deploy environmental station outside hooked up via wifi. Open your phone and add that arduino in and one of the screens would tell you what the weather is like outside.
  • deploy arduino with wifi and ac relays around your home. Add in the arduinos and program in location. After that you could control your entire homes devices with minimul setup.

The idea here is to develop one codebase for the arduino and one codebase for the app which could let you do 1001 things.

As an aside this could also work with an internet server as well. To start I'll be building it for my LAN, but it would be cool to be able to control things over the internet. It would simply be a matter of telling the arduino the ip address to report to.

Every 100th Order is Free and You Get a $100 Credit

I'm pleased to announce that every 100th order that Practical Maker ships is going to be free! In addition, the lucky winner will also get a $100 credit for a future order.

It doesn't matter what you order... if your order can be divided by 100 evenly you get it free AND you get a $100 credit at the site for a future order.

There is a maximum to how large the order can be. If your order is more than $250USD you'll get a credit on that order (and you can also apply the $100 credit as well).

Thanks so much for supporting me!

BNC Shield Demo

The new BNC (formerly called PHORPDuino Shield) is here! This revision has some very exciting changes. (The pic says V0.2, that's just because all the V0.3's are gone. Only difference is spacing added between some caps).

Key New Features

  1.  Analog input is pinned out. User can select via a jumper which analog input they wish to use.
  2. Added some buffering to make readings more stable. Previous versions jumped around a bit. That's fixed.
  3. Removed the second BNC connector (to add in buffering)
  4. MCP3204 is available (not standard). This adds in 12 bit readings
  5. 2 trim resistors for rough/fine tuning
  6. Added a reset button and reset jumpers
  7. LED's added to show power to the shield is working (TC1121 to ensure V+ and V- is working)

Without further ado, here's some pics:

And a video demonstrating the shield:

Arduino TLC5940 Shield Demo

At last... the shield I've been dying to get is here! Introducing the Arduino TLC5940 shield. It's got two TLC5040's for a total of 32 PWM outputs.

Without further ado, here's a picture of the shield:

 

 

Click For Larger Image

 

As well as a video demo:

 

 

 

This shield has a lot of possibilities. With 32 outputs stackable to however many you need (once I figure out how to provide enough power) the sky's the limit for your PWM dreams.

I personally designed the shield to be a sort of advanced aquarium lighting controller. Somebody suggested 'why not replicate lightning in the aquarium?' and the idea was born. It will consist of 32 strings of 3 luxeon led's. It should be quite interesting.

Key Points

  • 2 TLC5940's
  • 32 PWM outputs
  • Daisy chainable up to 640 outputs
  • User selectable current settings (20ma, 40ma, 80ma, 120ma)
  • Stackable (not the one in the picture or video because I didn't have any 90 degree headers, but with those on it's stackable)

 

DIY Labs is now Practical Maker

In this day and age it's near impossible to find a domain name that you like that isn't taken. I started out with diy-labs.com because it was pretty much all I could think of at the time.

Well, a couple days ago I stumbled upon practicalmaker.com and felt it was the perfect name to represent my goals as a maker.

Some of the projects may seem outlandish, but they all serve a practical purpose in one way or another.

I hope you like the new name. Let me know if you do!

TLC5940 Shield, BNC Shield and I2C LCD/Keypad Controller

I haven't really been updating the website lately, but I've still been working on some cool things. The fruit of that labor is some new shields, an updated shield and a board based on @jcrouchley LCD/Keypad controller.

TLC5940 Shield

The TLC5940 shield is exactly that. It's got two TLC5940's onboard giving you a total of 32 PWM pins. The cool thing about this shield is you can stack (a lot) of them on top of each other because SIN and SOUT are pinned out. All that's needed to add a second shield in is a jumper wire from the first shield to the second.

 

BNC Shield

Initially I changed the pHDuino shield into something that fit more with what I wanted... ORP and pH on one shield. The only problem was it was very sensitive to power supply fluctuations. I've taken the second BNC connector off and added some more buffering as well as a 12 bit ADC (for future use). After more than a month of testing it's never been off by more than 0.5 from a calibrated pH monitor. The great thing is this shield will also work with an ORP probe and any sensor that produces minute voltages and has a BNC connector (no EC though)

 

I2C LCD/Keypad Controller

I was lamenting on twitter about how there was no open source lcd/keypad controller. Well @jcrouchley heard me and designed one. I've taken his schematic and put it on a pcb and am working on a library. The best part? It's based on the attiny2313 and should cost around $10 or so.

 

EC Shield

Many people email me and ask when the EC shield is going to be done. Well, it's getting close. I've got the schematic drawn up and am waiting for some parts so I can breadboard it. After some testing I'll get some boards done and release it.

 

I think that's it for now. If you have any questions you can send me a message on twitter or contact me using the contact form.