Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTangible computing › migrating from Arduino to Wiring board

Page Index Toggle Pages: 1
migrating from Arduino to Wiring board (Read 9438 times)
09/15/07 at 13:41:44

phineus   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 8
*
 
Hi, I have firmware I've written for Arduino and now I am upgrading to Wiring to get additional i/o and memory.

Are Arduino and Wiring IDE's the same?  Or do I need to install both and use each one against it's specific board?

Do I need to re-write my Arduino code for the Wiring board or will it just work as-is?
 
IP Logged
 
Reply #1 - 09/15/07 at 21:28:58

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hi, IDEs are different, you´ll need the Wiring IDE with the Wiring board. The code should work fine, but it really depends on what you´re doing, try to post the code you want to port to have a better idea. If it is of any help, the source for Wiring is here: http://wiring.org.co/source
 
IP Logged
 
Reply #2 - 09/16/07 at 00:46:51

phineus   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 8
*
 
I want to use the SimpleMessageSystem:

http://www.arduino.cc/playground/Code/SimpleMessageSystem

I have it working on the Arduino and it says on above page it can run on the Wiring board, too.  I have installed the Wiring IDE and opened the example but compiling fails with message:

Code:
In function 'void loop()':
error: 'messageBuild' was not declared in this scope In function 'void readpins()':
 In function 'void writepin()':
 



here's the code example for the Wiring version:

Code:
/*
 ---- SimpleMessageSystem Example 11 ----
 Control Wiring board functions with the following messages:

 r a -> read analog pins
 r d -> read digital pins
 r p -> read digital ports
 w d [pin] [value] -> write digital pin
 w p [port] [value] -> write digital port
 w a [pin] [value] -> write analog pin


 Base: Thomas Ouellet Fredericks
 Additions: Alexandre Quessy
 for Wiring: Sibylle Hauert
 */


void setup()
{

  // The following command initiates the serial port at 9600 baud. Please note this is VERY SLOW!!!!!!
  // I suggest you use higher speeds in your own code. You can go up to 115200 with the USB version, that's 12x faster
  Serial.begin(9600); //Baud set at 9600 for compatibility, CHANGE!


}

void loop()
{

  if (messageBuild() > 0) { // Checks to see if the message is complete and erases any previous messages
    switch (messageGetChar()) { // Gets the first word as a character
    case 'r': // Read pins (analog or digital)
	readpins(); // Call the readpins function
	break; // Break from the switch
    case 'w': // Write pin or port
	writepin(); // Call the writepin function
    }

  }

}

void readpins(){ // Read pins (analog or digital)

  switch (messageGetChar()) { // Gets the next word as a character

    case 'd': // READ digital pins

    messageSendChar('d');  // Echo what is being read
    for (char i=8;i<16;i++) {
	messageSendInt(digitalRead(i)); // Read pins 8 to 15 --> as well possible read 0 to 39
    }
    messageEnd(); // Terminate the message being sent
    break; // Break from the switch

    case 'p': // READ digital ports

    messageSendChar('p');  // Echo what is being read
    for (char i=1;i<4;i++) {
	messageSendInt(portRead(i)); // Read digital ports 1, 2 and 3 --> as well possible read 0-4
    }
    messageEnd(); // Terminate the message being sent
    break; // Break from the switch

  case 'a': // READ analog pins

    messageSendChar('a');  // Echo what is being read
    for (char i=0;i<8;i++) {
	messageSendInt(analogRead(i)); // Read pins 0 to 7
    }
    messageEnd(); // Terminate the message being sent

  }

}

void writepin() { // Write pin

  int pin;
  int port;
  int state;

  switch (messageGetChar()) { // Gets the next word as a character

    case 'a' : // WRITE an analog pin

    pin = messageGetInt(); // Gets the next word as an integer
    state = messageGetInt(); // Gets the next word as an integer
    analogWrite(pin, state); //Sets the PWM of the pin
    break;  // Break from the switch



    case 'd' : // WRITE a digital pin

    pin = messageGetInt();  // Gets the next word as an integer
    state = messageGetInt();  // Gets the next word as an integer
    pinMode(pin,OUTPUT);  //Sets the state of the pin to an output
    digitalWrite(pin,state);  //Sets the state of the pin HIGH (1) or LOW (0)


    case 'p' : // WRITE a digital port

    port = messageGetInt();  // Gets the next word as an integer
    state = messageGetInt();  // Gets the next word as an integer
    portMode(port,OUTPUT);  //Sets the state of the port to an output
    portWrite(port,state);  //Sets the state of the 8 pins of the port HIGH (1) or LOW (0)
  }

}


 


 
IP Logged
 
Reply #3 - 09/16/07 at 07:11:39

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Are you using this version? http://www.arduino.cc/playground/uploads/Code/adaptSMS4wiring.zip
 
IP Logged
 
Reply #4 - 09/16/07 at 14:54:15

phineus   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 8
*
 
Yes, I downloaded that and I'm pretty sure it's what I'm using. 

I think maybe I'm a little confused about what folder to launch things from and where everything needs to live (filewise).  It's not clear to me why I need these additional patches and files, and where to put them.  Is there a tutorial that covers what files go where and why?  It took me ages to figure out that half the time my Max patches weren't working because I was saving to a different directory and had 2 versions of the same thing, depending on whether I'd opened it from Recent or directly - affected if it worked or not.  Things have gotten a little messy what with all the downloading and extracting of things so some tips on keeping everything organized would help.

To use adaptSMS4wiring.zip, where do I put the files?  Which ones do I open directly in Wiring and which ones do I have to paste into a new sketch?  And does this error above mean it can't find a file?

PS I'm on WinXP in case that matters.
 
IP Logged
 
Reply #5 - 09/16/07 at 17:10:25

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
All libraries are inside the linraries directory inside Wiring. Wiring will check for un-build libraries everytime it starts and will attempt to build them. Then the commands in the library should be available from the environment.
 
IP Logged
 
Reply #6 - 09/17/07 at 18:40:45

phineus   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 8
*
 
Smiley Thanks, that's exactly what I needed to know!
 
IP Logged
 
Reply #7 - 12/03/07 at 17:02:53

sibylle_hauert   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 5
*
 
I'ts the missing: #include <SimpleMessageSystem.h>  in Your SimplemessageSystem_example_11.pde 
....at least with Wiring 13
With version 10, it worked without....at least for me;)
???
Greetings Sibylle
 
IP Logged
 
Page Index Toggle Pages: 1