Archive for the ‘Code’ Category

Getting Started with Pachube & Arduino

Thursday, June 25th, 2009

Another post on Pachube and how easy it is to get setup and going. This post will cover the basic steps on how to get some sensors online!  I will be using my project of two light sensors as an example.  The status of my light sensors are viewable at http://www.pachube.com/feeds/2145

Pachube + Arduino from Morgellon on Vimeo.

STEP ONE: GET A PACHUBE ACCOUNT!

Head over to the Pachube website and see various sensors from all over the world and view their status.  Be sure to view the ABOUT page, this describes INPUTs and OUTPUTs, along with ways to interface with Pachube and your sensors.  The QUICKSTART page has the details to get started and how to use your API.  Pachube is still in beta, so you’ll need to get an invite code… but no worries, Pachube has an email address on the QUICKSTART page.  Just send them and email asking for an invite and what you would like to do.  If they let me in… they will let anyone in! ;)

STEP TWO: PREPARE ARDUINO!

The Arduino can be interfaced with Pachube two ways: 1. With an Ethernet shield OR 2. Via USB connected to a PC running Processing… which is the way used in this tutorial… as I feel it is an easy and inexpensive way.  You can learn more about each way at the Pachube Arduino page.

To prep the Arduino, you need to connect the sensors you will be using and verify that they are working correctly! Once the sensors are good, then upload the “Standard Firmata” to the Arduino.  Now the Arduino is prepped for Pachube!  Leave the Arduino connected to the PC.

STEP THREE: PREPARE PROCESSING!

To have Processing communicate easily with Pachube, you will need to add a few libraries.  They are the Pachuino, Arduino and EEML libraries, they are available and there is more info at the PACHUINO page.  Download, unzip and move them to the libraries folder, in your sketchbook folder.  Now Processing is ready!

STEP FOUR: PREPARE INPUT FEED!

Once you have a Pachube account and your API key, go ahead and set up a new feed for your sensors.  Since I have light sensors, I started a new INPUT FEED.  I chose to make my feed “manual” (as this is easier for me) which means Pachube gets updates only when I send them.  Instead of Pachube connecting directly to my PC to pull the info.

STEP FIVE: PREPARE CODE FOR PROCESSING!

Once you have the libraries in the folder, you are ready to start Processing and start coding.  Below is the code I used for my light sensor.  This was taken from the sample code and stripped to make it more simple. I added a LED on pin 11 to light up (to let me know when my Arduino was running) and a delay(1500).

Be sure to add you API Key, and the URL of your INPUT FEED!

import processing.serial.*;
import cc.arduino.*;
import eeml.*;
import pachuino.*;

Pachuino p;
Arduino arduino;
int ledPin = 11;

void setup(){
p = new Pachuino(this, Arduino.list()[0], 115200);
p.manualUpdate(”http://www.pachube.com/api/2145.xml”); // change URL — this is the feed you want to update
p.setKey(”—YOUR API KEY HERE—”);

// local sensors
p.addLocalSensor(”analog”, 0,”Light Sensor Inside”);
p.addLocalSensor(”analog”, 1,”Light Sensor Outside”);
}

void draw(){
//p.debug();
p.digitalWrite(ledPin, Arduino.HIGH);
delay(1500);
}

// you don’t need to change any of these

void onReceiveEEML(DataIn d){
p.updateRemoteSensors(d);
}

STEP SIX: LAUNCH CODE AND COLLECT DATA!

Make sure that:

  • Sensors are *working* and connected to Arduino
  • Arduino is running “Standard Firmata” and connected to computer
  • Processing is collecting sensor data from Arduino
  • Computer has Internet connection

Now run your program and begin collecting data and sharing it on the web!!  Check your feed to make sure you data is being transmitted.  Have fun and happy tinkering!

–Morgellon OUT!

Arduino + Pachube = Web Connected Sensors!

Wednesday, June 24th, 2009

Quick update before I zonk out…  Yesterday I setup an account for Pachube and spent all night getting familiar with how it works. Pachube describes itself as a service that enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to facilitate interaction between remote environments, both physical and virtual.

It also works with Arduino and Processing… hrmmmmm…..

As a “test” project, I set up two light sensors in my room.  One is mounted on the wall, the other is taped to the window facing outside.  The idea is to compare inside light levels to outside light levels and adjust for energy consumption.  If the light level outside is equal or greater than inside, then perhaps I should open the blinds to let in more light… or maybe even go outside… *gasp*
The two light sensors are connected to an Arduino running the Standard Firmata.  The Arduino is connected to a PC running a Processing sketch that sends the sensor data to Pachube.  Nice and easy!  I’ll post more details, code and a basic tutorial later… after I’ve slept… that way it *might* make sense.
Until then, here are some pictures and graphs. (yay graphs!) The two graphs are generated by Pachube and are fairly easy to customize.  The higher the number, the less light is present.  So, hopefully the Inside Light Sensor will stay a nice high number as I sleep… while the Outside Light Sensor should lower over the course of the day.

The graphs will continue to update as they receive more data from the sensors.  It will be interesting to watch and compare the differences in the two graphs.  More to come soon!

–Morgellon OUT!!


Yarn & Code…?!

Wednesday, June 17th, 2009

That’s right, we are still alive!  I can’t stand the pain of not posting any longer, so I thought I would make the time to do a brief update.

Things have been quite action packed and distracting for me!  A recent move has not helped with the distraction factor either, lol. Between work, packing and unpacking, here are the other things I’ve been doing with my time:

Learning to Code. As I progress in my projects, my lack of coding abilities are really starting to be the limiting factor.  Among other things, I have been wanting to incorporate Processing into more projects.  In order to manifest my crazy ideas into reality, I decided to really focus on learning to “code”.   My favorite and possibly most valuable resource has been the Programming Methodology videos from Standford University.  The course is taught around Java, which is convenient for me as Processing is Java based.  Here is a link to the Programming Methodology course videos on youtube… they are also downloadable!  http://www.youtube.com/view_play_list?p=84A56BC7F4A1F852&search_query=programming+methodology

I’ll embed the first lecture to wet your whistle!

Crafting. Yes, that’s correct.  Crafting. I’ve been wanting to do some “wearable” projects… making use of the LilyPad, conductive thread and my madness, among other things.  So, I have been learning to use a sewing machine, along with hand stitching and other techniques.  Recently, I even had the opportunity to learn to make yarn from wool.  I also have acquired a large amount of wool and a Navajo spinning spindle, to spin the wool into yarn.  One of the things I would like to try is spinning my own “conductive yarn”.

If for some reason you were interested in learning more on this technique of spinning, here’s a nice link explaining the process: http://www.graftonfibers.com/navajospinning.htm

Don’t worry, things are starting to settle and slow down with me… so hopefully I soon have time to start applying my new found knowledge to some neat Arduino projects.

– Morgellon OUT!

Flourish Conference 09

Friday, April 24th, 2009

Finally gotten around to posting some pictures and video from the Flourish Conference, in Chicago IL.  Flourish was a blast, Droops and I had a wonderful time with all the great people that we met.


Massimo Banzi at Flourish ‘09 from Morgellon on Vimeo.


Processing Workshop at Flourish ‘09 (pt1) from Morgellon on Vimeo.


Processing Workshop at Flourish ‘09 (pt2) from Morgellon on Vimeo.

Recent Developments with the Ethernet Shield

Saturday, April 11th, 2009

There has been quite a flurry of development revolving around the official ethernet shield recently. Here are what I consider a few of the more important changes.

Ethernet fixes – There are some connection issues with the ethernet library with regard to incomplete disconnects. Since the wiznet chip only supports 4 simultaneous connections, this manifests itself pretty quickly if you are trying to poll a server for changes. Etracer, from the arduino forums, found and fixed this problem and has released a new client.cpp as well as detailed the issues in a post to the arduino developers mailing list.

Another recent addition is Ben Combee’s Webduino library, which greatly simplifies processing html forms when using the arduino and ethernet shield as a web server. The library and basic examples are available at: http://code.google.com/p/webduino/

Bjoern Hartmann’s UDP library has also been used for a couple of recent projects including work on DNS/DHCP and fellow Infonomicon member Cynshard’s work on a NTP library. The NTP library is particularly useful since it can be combined with the software Date/Time library to have fairly accurate time without adding a hardware realtime clock to your project.

As you can see, there seems to be a lot of development activity ongoing for the official ethernet shield and since the addition of networking to the arduino greatly expands its possible uses, I think we’ll see even more. Please remember to thank these folks for their code and bugfix contributions…

Basic Processing to Arduino Communications

Friday, February 20th, 2009

Finally sat down and figured out how to send some basic signals via serial from Processing to an Arduino.  For this example I was just looking for basic functionality, so I settled for a simple way to turn a LED on and off.  It’s also mostly sample code gathered from the Internet.

The Processing code creates a small black square on the screen.  When the mouse cursor is moved over the square, it changes color to yellow and sends a “H” over serial to the Arduino.  While the Arduino detects a “H” on serial it will light the LED.

Here’s a video of it in action and describing how to get started.

Basic Processing to Arduino Communications from Morgellon on Vimeo.

  • Download Processing

http://processing.org/download/index.html

  • Download Arduino to Processing Library

http://www.arduino.cc/playground/Interfacing/Processing

Now that you’ve gotten all the files installed and in their proper places, try out my test code I used in the video.

Arduino Code (Download here)

//  Read data from the serial port and turn ON or OFF a light depending on the value

char val;         //Data received from the serial port
int ledPin = 13;  //Set value ledPin to pin 13

void setup(){
pinMode(ledPin, OUTPUT);  //Sets pin as OUTPUT
Serial.begin(9600);    //Start serial communication at 9600bps
}

void loop(){
if (Serial.available()){  //If data is available to read,
val = Serial.read();    //read it and store it as val
}
if (val == ‘H’){              //If H is recieved
digitalWrite(ledPin, HIGH);  //turn ON light
} else {
digitalWrite(ledPin, LOW);  //If not leave light OFF
}
delay(25);
}

Processing Code(Download here)

//Check if the mouse is over a rectangle and write the status to the serial port

import processing.serial.*;
import cc.arduino.*;


Serial port;    //Create object from Serial class

void setup() {
size(200, 200);
noStroke();
frameRate(10);
//Open the port that the board is connected to and use the same speed (9600bps)
port = new Serial(this, Serial.list()[0], 9600);
}

void draw() {
background (255);
if (mouseOverRect() == true) {  //If mouse if over square
fill(242, 204, 47);                    //change color
port.write(’H');              //send H to serial port
} else {            //If mouse is NOT over square
fill(0);          //change color
port.write(’L');  //send L to serial port
}
rect(50, 50, 100, 100);  //Draws the square
}

boolean mouseOverRect() {    //Tests if mouse is over square
return ((mouseX >= 50) && (mouseX <= 150) && (mouseY >= 50) && (mouseY <= 150));
}

Processing Interview

Monday, January 19th, 2009

Looks like Ben Fry and Casey Reas the creators of Processing, were recently interviewed on FLOSS Weekly! This is a nice intro into the world of Processing! If you’re looking for ways to extend your *duino projects, communicate with a PC or just have some creative fun, Processing could be for you!

Be sure to head over to the FLOSS Weekly site and listen to this interview!

Arduino Composite Video

Wednesday, November 26th, 2008

Television! Teacher, mother, secret lover. –Homer J. Simpson

Having only discovered the duino recently, I’m constantly searching for applications that push the limits of what can be done with the device. There have been several sketches posted that will output composite black and white video to your TV with a very simple circuit, but the most interesting of these to me is the Arduino Pong code by Alastair Parker. What I’ve done is strip the code down to just the intro screen in order to simplify the idea and get my mind wrapped around it. Check out the following schematic, code and resulting output.

Download the code.

Arduino Composite Video Schematic

Arduino Composite Video Schematic

To change the on-screen text, grab a sheet of graph paper, create a rectangle that is 38 units wide and 14 units tall, and mark the pixels you would like to turn on. After that, it’s simply a matter of changing the “setPixel(x,y)” lines in the code. Have fun and as Homer says: Let us all bask in television’s warm glowing warming glow.

Composite Output Result

Composite Output Result

The circuit on breadboard

The circuit on breadboard

Processing color selector

Wednesday, October 15th, 2008

I am working on having processing read and act on data from the ardunino, this is a simple test and code should be up soon, i am working on a code repo for Morgellon and I to share projects.


Arduino / Processing Color Selector from droops on Vimeo.

This is for our talk at Phreaknic, the ardunio reads 3 linear pots and outputs serial data that looks like this:

X 56
Y 67
Z 10
X 59
Y 89
Z 10

Processing takes this, splits it up, and makes the pretty colors.

Processing is Crazy

Wednesday, October 8th, 2008


Metamorphosis from Glenn Marshall on Vimeo.

  • Cool Arduino Parts

  • You are currently browsing the archives for the Code category.



  • Viagra online
  • Order cheap cialis
  • Buy viagra no prescription
  • Cialis online
  • Buy generic cialis
  • Order propecia no prescription
  • Cheap propecia online
  • Propecia online pharmacy
  • Order levitra online
  • Cheap price cialis
  • Online pharmacy levitra
  • Buy viagra online
  • Buy discount levitra
  • Cheap cialis online
  • Propecia hair loss