Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Send dynamic tweet strings via the Twitter library on: October 03, 2010, 10:24:55 am
Thank you PaulS!!

It works OK now!
2  Forum 2005-2010 (read only) / Syntax & Programs / Send dynamic tweet strings via the Twitter library on: October 03, 2010, 08:02:34 am
Hello everyone!

I use the Twitter library that supports OAuth http://www.arduino.cc/playground/Code/TwitterLibrary and i want to post the values from a temperature sensor along with some additional text, in the same tweet.

As such, a tweet should contain a static text as well as the dynamic temperature value taken from the temp sensor.

So here is my question:

How can i concatenate a static text with a dynamic value in order to send the entire string via a single tweet ?

I test the following code taken from the Twitter library page:

Code:
/* Post a simple message to Twitter  */
#include <Ethernet.h>
#include <Twitter.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte gateway[] = { 10, 0, 0, 1 };
byte subnet[] = { 255, 255, 0, 0 };

Twitter twitter("YOUR-TOKEN");
char msg[] = "Hello, World! I'm Arduino!";

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting ...");
  if (twitter.post(msg)) {
    int status = twitter.wait();
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }
}

void loop()
{
}

In the example code above, the string array variable contains a static string
Code:
char msg[] = "Hello, World! I'm Arduino!";

The "post" function of the twitter library
Code:
twitter.post(msg)
expects a const char *message variable.


What do i need to do to concatenate a static text and a dynamic value ?

Any help to the right direction is much appreciated!

John
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: 7-Segment Serial Display (4-digits) on: September 10, 2009, 01:46:07 pm
Hi Mike

It's ok now!

Thanks
4  Forum 2005-2010 (read only) / Syntax & Programs / 7-Segment Serial Display (4-digits) on: September 10, 2009, 05:57:40 am
Hi to everyone

I have a 4-digit 7-segment serial display connected to the arduino using SPI. The serial display is from Sparkfun. Item number COM-09230.
http://www.sparkfun.com/commerce/product_info.php?products_id=9230

I followed the instructions and the code found in this post and it worked great.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247533060


I have modified the code so as the arduino receives data from the computer and display the data on the serial display.
However, the problem is that went i sent numbers, for example 0, the display shows the number 48 which corresponds to 0 according to ASCII. When i send 1 the display shows 49 and so on.

The following part of the code passes the data from the computer over to the function to display the data onto the serial display.

Code:
if (Serial.available() > 0) {
    
   incomingByte = Serial.read();
   write_led(incomingByte,10,1);
  
  }

Also, if i put a number directly in the function (the first parameter, in this case the number 7), the serial display shows the correct number 7. As such, only when the numbers as sent over the serial port are not show up correctly.

Code:
write_led(7,10,1);


I have included the full code below if someone knows what the problem is.

John

Code:
// Send alphanumeric data to the Sparkfun Serial LED Display (COM-09230) using SPI
// Tested using Arduino Pro Mini w/ ATMega168 @ 5V
// July 21, 2009  - Quazar & Busaboi
// No guarantees expressed or implied just a good starting point
// Based upon the many SPI tutorials on Arduino.cc
//
// "num" specifies the number to display
// "base" specifies the base to use (2-16).
//    Use 2 for binary, 8 for octal, 10 for decimal, or 16 for hex
// "pad" indicates whether leading zeros should be replaced with spaces.
//    pad==0 means spaces ("   0"), pad==1 means zeros ("0000")
//
// Notes: The display's decimal/punctuation indicators are not changed.
// Numbers that don't fit into 4 digits show as " OF " for "Overflow".
// Assumptions: "unsigned short" is assumed to be at least 16b wide.

#define DATAOUT 11 //MOSI
#define DATAIN 12 //MISO - not used, but part of builtin SPI
#define SPICLOCK 13 //SCK
#define SLAVESELECT 10 //SS - CSN
byte incomingByte;

char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
  return SPDR;                    // return the received byte
}

void setup()
{
  Serial.begin(9600);
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK, OUTPUT);
  pinMode(SLAVESELECT, OUTPUT);
  digitalWrite(SLAVESELECT, HIGH); //disable device
  // SPCR = 01010010
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/64
  SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);
  clr=SPSR;
  clr=SPDR;
  delay(10);
  write_led_numbers(0x78,0x78,0x78,0x78); //Blank display
  write_led_decimals(0x00); // All decimal points off
}

void write_led_decimals(int value)
{
   digitalWrite(SLAVESELECT, LOW);
   delay(10);
   spi_transfer(0x77);     // Decimal Point OpCode
   spi_transfer(value);    // Decimal Point Values
   digitalWrite(SLAVESELECT, HIGH); //release chip, signal end transfer
}
void write_led_numbers(int digit1, int digit2, int digit3, int digit4)
{
   digitalWrite(SLAVESELECT, LOW);
   delay(10);
   spi_transfer(digit1);    // Thousands Digit
   spi_transfer(digit2);    // Hundreds Digit
   spi_transfer(digit3);    // Tens Digit
   spi_transfer(digit4);    // Ones Digit
   //spi_transfer(0x7A);    // Special command
   //spi_transfer(0x01);    // Special command
   digitalWrite(SLAVESELECT, HIGH); //release chip, signal end transfer
}
void write_led(unsigned short num, unsigned short base, unsigned short pad)
{
    unsigned short digit[4] = { 0, ' ', ' ', ' ' };
    unsigned short place = 0;

    if ( (base<2) || (base>16) || (num>(base*base*base*base-1)) ) {
        write_led_numbers(' ', 0x00, 0x0f, ' ');  // indicate overflow
    } else {
        while ( (num || pad) && (place<4) ) {
            if ( (num>0)  || pad )
                digit[place++] = num % base;
            num /= base;
        }
        write_led_numbers(digit[3], digit[2], digit[1], digit[0]);
    }
}

void loop()
{
 
  if (Serial.available() > 0) {
    
   incomingByte = Serial.read();
   write_led(incomingByte,10,1);
  
  }
 
 
 /*
 for (int i = 0; i < 9999; i++) {
     write_led(i,10,1);
     delay(80);
  }
 */

}
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Changing I2C address of DS1307 RTC on: June 25, 2009, 02:19:39 am
Hey guys

Thanks for you replies.

Never though it that way! I will try the software approach.

And yes, imagine what a confusion would be when having multiple watches showing different times  smiley-grin
6  Forum 2005-2010 (read only) / Syntax & Programs / Changing I2C address of DS1307 RTC on: June 24, 2009, 06:30:12 pm
Hello to the Arduino community!

I have 2 DS1307 RTCs and i want to connect them to the same I2C bus.

I have read the datasheet of DS1307 but i can not find something that states how to change the default address.

Is it possible to change the default address of DS1307? So i can program each of them with a different time (kind of World Time project).

Thank you smiley
7  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display using SPI on: September 09, 2009, 05:47:08 am
Quote
Well now...after talking to myself late into the the night and with a great deal of help from fellow Arduinophile Quazar, we have this sample code for y'all to use to help get up the learning curve for this Serial LED Display from Sparkfun (COM-09230).

Hey!! It worked like a charm! Thank you!
8  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: RC car interfacing on: May 08, 2010, 04:35:29 pm
Hello deepuuus,

Take a look at a project that i did some time ago:

http://sites.google.com/site/electronicprojectsprogramming/control-an-rc-car-via-pc-using-xbee

You may find it useful.

Welcome to the electronics world!  smiley-razz

And yes, google a lot!
Pages: [1]