Show Posts
Pages: 1 2 [3] 4 5 ... 25
31  Forum 2005-2010 (read only) / Syntax & Programs / monome protocol on: May 15, 2008, 07:24:05 am
Hi
I'm trying to implement the monome protocol on the arduino, but I have some trouble figuring how to translate those C commands into the Arduino IDE. the monomeserial recognize my board as a 40h after I changed the FTDI chip ID, but I can't (yet) use it as a monome.

The messagePackButtonPress function is used to send serial data :
void messagePackButtonPress(t_message *message, uint8 state, uint8 x, uint8 y)
{
    message->data0 = (kMessageTypeButtonPress << 4) | (state ? on : off);
    message->data1 = (x << 4) | y;
}

t_message is defined as follow
typedef struct {
    uint8 data0;
    uint8 data1;
} t_message;

You can find the protocol specifications here : http://docs.monome.org/doku.php?id=tech:protocol:40h & http://docs.monome.org/doku.php?id=tech:protocol:serial:series

I know that each data to send (adress, state, xpos, ypos) must be 4 bits long, but what I don't understand is the message->data0 & message->data1 syntax. I tried

Serial.print(0x0000 | 0x0000);
Serial.print(0x0000 | 0x0000);

But I must have some bit shifting of variable type problem (I'm really bad with all this binary stuff ^^)

How to translate in "Arduino style"? Thanks
32  Forum 2005-2010 (read only) / Syntax & Programs / Re: diming LEDs on: May 31, 2008, 06:29:54 pm
The problem with your code is that you used FOR loops. You program doesn't goes further that the loop until it have finished doing it.
Another way to do it could be something like.

Code:
led1val = 0;                  // Led 1 starts off
led2val = 255;              // Led 2 starts fully ON
led1inc = 1;                 // Led 1 increments 1
led2inc = -1;                 // Led 2 increments -1 = decrements 1

void setup() {
   analogWrite(led1,led1val);
   analogWrite(led2,led2val);
}

void loop() {
   led1val += led1inc;
   led2val += led2inc;
   analogWrite(led1,led1val);
   analogWrite(led2,led2val);

   switch (led1val) {
      case 0:
         led1inc = 1;
         break;
      case 255:
         led1inc = -1;
         break;
   }
  
   switch (led2val) {
      case 0:
         led2inc = 1;
         break;
      case 255:
         led2inc = -1;
         break;
   }

   delay(100);
}

NB : this is "pseudocode", don't take it for granted, got to test it smiley-wink
33  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rainbow calculator on: April 18, 2007, 04:25:39 am
To me, the best way to make that is to use the HSV color mode (Hue Saturation Value)
Hue = Varies from 0 to 360°. It defines the point in the spectrum, 0 = 360 = red, 10 is like a purplish color, etc... This way, you have an easy way to find all the colors in the spectrum, just by varying the angle.
Saturation = "Purity" of the color. Varies from 0 to 100. The lower the value, the more the colour will be dull.
Value = Brightness of the color.

Exemple : to have a pure RGB red (255,0,0), HSV value will be (360 or 0, 100,100)

You can then convert the value to RGB by using this kind of code

http://www.easyrgb.com/math.php?MATH=M21#text21

It seems that maximal value for H is 256 on this code, haven't tried it myself yet, but i gave the same advice to a guy on a french electronic forum and here's his result ^^


34  Forum 2005-2010 (read only) / Interfacing / Re: php with arduino on: July 23, 2008, 02:08:57 pm
I guess that you have to run a serial proxy, like the one used for having Adobe Flash to talk with the Arduino.
http://www.arduino.cc/playground/Interfacing/SerialNet
35  Forum 2005-2010 (read only) / Interfacing / Re: Cross-platform reading of a text file into Arduino on: February 26, 2009, 03:17:31 pm
Web page is a good idea, but you'll need an ethernet module, etc... too complicated.
Just do a little Java application with Processing. With a small GUI to enter the numbers, you can save and load the textfile + send the values to the Arduino via serial.
36  Forum 2005-2010 (read only) / Interfacing / Re: OS X: arduino + adium and gmail on: February 21, 2009, 03:47:09 pm
You're welcome
37  Forum 2005-2010 (read only) / Interfacing / Re: OS X: arduino + adium and gmail on: February 21, 2009, 02:58:25 pm
Sorry, I forgot about that.
The package is already present on macosx systems, but a bit find to hard.
Here's the way to have it working

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems;action=display;num=1225564736
38  Forum 2005-2010 (read only) / Interfacing / Re: OS X: arduino + adium and gmail on: February 21, 2009, 01:27:43 pm
Here's a processing sketch that polls adium using the applescript you gave earlier.
It returns an integer.
Nobody never talks to me, so I always get 0, but it should work ^^

Code:
import com.apple.cocoa.foundation.*;

void setup() {
  size(400,400);
  int adiumUnread = runAS();
  println(adiumUnread);
}

void draw() {
  
}

public int runAS() {
  String script = "tell application \"Adium\"\n"
  +"  set x to 0\n"
  +"    repeat with theChat in (every chat)\n"
  +"    set x to x + (unread message count of theChat)\n"
  +"    end repeat\n"
  +"  end tell\n"
  +"  x";
  NSAppleScript myScript = new NSAppleScript(script);
  NSMutableDictionary errors = new NSMutableDictionary();
  NSAppleEventDescriptor result = myScript.execute(errors);
  return result.int32Value();
}
39  Forum 2005-2010 (read only) / Interfacing / Re: OS X: arduino + adium and gmail on: February 21, 2009, 07:35:48 am
O Hai

Thinking fast, I guess the easiest way is the third.

First would be the best (that's what I thought about). I did not take time to browse the adium applescript doc, but I'll have a look at it later.

I'm not sure the second would be possible. I don't know if you can poll Java apps.

Gotta go, but I'll check it when I come back.

NB : you should post that lovely sketch to the "User Experience Sketches" group on flickr, they'll love that ^^
http://flickr.com/groups/uxsketches/pool/
40  Forum 2005-2010 (read only) / Interfacing / Re: OS X: arduino + adium and gmail on: February 21, 2009, 06:09:52 am
http://processing.org/hacks/hacks:applescript

http://trac.adiumx.com/wiki/AppleScript_Support_1.2
41  Forum 2005-2010 (read only) / Interfacing / Re: Get Ipod Name (receiving data from Ipod) on: February 06, 2009, 04:18:44 am
Sorry, I won't be able to help you further, I've never used the SoftwareSerial library.

Do you have an iPod serial communication informations source somewhere ? My first guess would be about the speed. On your first sketch, you use the serial connection at 19200, but the softwareSerial won't run faster than 9600 bauds. Maybe that's an issue.

Cheers
42  Forum 2005-2010 (read only) / Interfacing / Re: Get Ipod Name (receiving data from Ipod) on: February 05, 2009, 05:33:15 am
How is the iPod connector wired ?
It seems you're using the Rx/Tx pins of the arduino (0 & 1) to send serial commandes to the iPod.
But those pins are also the one wired to the FTDI which allows serial communication between the Arduino and the computer.
You can't have 2 devices on those pins.
I think you should use the SoftwareSerial library to communicate to the iPod, and leave the Rx/Tx pins unconnected so that the hardware UART can communicate with the computer.

http://www.arduino.cc/en/Reference/SoftwareSerial
43  Forum 2005-2010 (read only) / Interfacing / Re: Is there an Arduino/Other More Powerful? on: August 08, 2008, 06:04:57 pm
As much as you have pins left. If you're using I2C devices (with each device having a different adress), you can link a whole bunch of them on 2 pins. The I2C protocols is made for 112 devices on 2 wires, but be careful with th cable length for noise, etc...

As you certainly know, the ATmega168 is not a processor that allows multi-tasking, so everything runs as a sequence, and with a huge lot of external devices, you might have some program loops that could take a lot of time. For instance, if you use 112 x I2C EEPROM chips, with each eeprom having a write-time of 3ms, it will take 336ms to write one byte on each eeprom... I know it's a dumb example unless you want to build a really huge memory card, but for the project you described on your first post, timing might (and certainly will) be an issue.

I don't even know if you can dump an image from a CMOS camera sensor at 25fps with the arduino, but if you can, I doubt the mega168 will have enough power to manage to do something else...
44  Forum 2005-2010 (read only) / Interfacing / Re: Best Interfacing program on: October 06, 2008, 06:28:55 pm
If you understood how to write code in the Arduino IDE, you should try it's older brother, Processing. This is a language with a very smooth learning curve, but it's real powerful.

http://www.processing.org
45  Forum 2005-2010 (read only) / Interfacing / Re: examples and code at bottom - graph on: September 11, 2008, 09:16:29 pm
Maybe your processing sketch isn't listening to the right com port.
Pages: 1 2 [3] 4 5 ... 25