Show Posts
Pages: 1 [2] 3 4 ... 38
16  Forum 2005-2010 (read only) / Syntax & Programs / Re: Help needed splitting up serial messages from Max. on: October 07, 2009, 10:30:20 pm
Well, as a starting point, you'd need to define a "buffer" to hold the incoming message.

Then you read what charachter is available on the serial port, and add that to the next position in the buffer. Keep doing this until there is nothing left on the serial port.

Then you could to a compare, like saying if the first charachter in the buffer is == 'h", print "hello" to the LCD screen.

Later on you could test if the buffer contained numbers, if so, convert the string to a number of type int or long or whatever, then use this number to manipulate the high/low status of the digital pins.
17  Forum 2005-2010 (read only) / Syntax & Programs / Re: Sending quotation marks over serial on: November 22, 2008, 02:11:11 am
Sweet! Easy when you know how - thanks.
18  Forum 2005-2010 (read only) / Syntax & Programs / Sending quotation marks over serial on: November 22, 2008, 12:01:19 am
How do you send quotation marks (") over serial? Obviously they are used in the serial.print() function to include the charachters between them, so how do you explicity include them in the string to be sent?

I don't have a c/c++ background, I can imagine there is a way to do it, but I can't find it.



19  Forum 2005-2010 (read only) / Syntax & Programs / Re: Charlieplexing LEDs on: November 21, 2008, 02:53:41 am
Nothing hard about it! Just use the PinMode command - it can be used anywhere, not just at the start of the sketch!
20  Forum 2005-2010 (read only) / Syntax & Programs / Re: send port register status over serial on: December 12, 2007, 11:19:05 pm
Did you check the Reference page for the Serial.print command?


Serial.print(b, BIN);


Serial.print(b, BYTE);

command seem like they might be what you are looking for.

21  Forum 2005-2010 (read only) / Syntax & Programs / Re: Sleep Function (not delay) on: October 21, 2007, 05:43:16 pm

I had the same request...

Matthias really helped me out. The code he posted (and I adapted for my project) is here

It's not technically a "sleep" state, but it's relatively low power, and then a timer interrupt is used to run a function at regular intervals.

Have a look at the code, I'd be happy to try to answer any questions using my limited experience.

Note the code is for ATMega8, some of the register names would need to be changed to get it working with a Mega168
22  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino and sleep settings on: April 13, 2007, 07:45:33 am
Well I'll revive it then...

Nice work on getting the sleep code up and running.

For my project I want the microcontroller to wake up every 5 minutes or so and update one variable. Seems like a waste to not put it to sleep during the in-between times, but I don't want to have to manually wake it up, I was hoping it would wake up itself automatically.

Is there any way to use an internal interupt to wake it up, or alternatively, is there another (better?) way to do it? I think some of the PIC range have built in real time clocks, but of course who wants to use one of them...  

23  Forum 2005-2010 (read only) / Syntax & Programs / Re: arduino & accelerometer to count footsteps? on: February 13, 2007, 05:53:24 pm
As shown by sparkfun the Nike+ipod thing uses a peizo transducer - seems like a good idea
24  Forum 2005-2010 (read only) / Syntax & Programs / Re: Small syntax question on: November 06, 2006, 03:23:46 pm
if (Serial.available() >= 2)

That did it - awesome, thanks heaps.

If I could make a suggestion, it would be awesome if there was an example simmilar to this in function. As a newcomer to programming, especially serial communications, it took me ages to work out how to read more than the first byte, and I don't think I ever would have got the process of converting the bytes into a multi-digit integer without the code I linked to. Anyways just my thoughts, it may have been obvious to everyone else.
25  Forum 2005-2010 (read only) / Syntax & Programs / Small syntax question on: November 05, 2006, 11:20:46 pm
Hey guys,

Hoping someone could help with this small bit of code. I mad a small sketch to light a LED connected the pin which the user selects over the serial connection, eg type 13 to turn on the LED on pin 13, 07 to turn on LED on pin 7 etc...
 I heavily used the code from Gian Pablo Villamil (username gpvillamil) posted here: http://

Here's my code
byte incomingByte ;
int LEDpin;
void setup() {
 void loop() {

  if (Serial.available()) {         // if serial data waiting
    digitalWrite(LEDpin,LOW);       // if so, turn off previously lit LED

    LEDpin = 0;                     // reset pin variable
     for (int i = 0; i <=1; i++) {  // for the first two bytes (i.e. 0 and 1)
       incomingByte =;  // read byte
       Serial.println(incomingByte,DEC);   // print what was read
       LEDpin = LEDpin * 10 + (incomingByte - 48);  // assemble full 2-digit integer
     Serial.print("Lighting up LED #");   // Display which LED will be lit
     digitalWrite(LEDpin,HIGH);     // Light up LED
    while (Serial.available()) {  
     incomingByte =; // clear the buffer

It all works really well, but here's my question. If I comment out the line

       Serial.println(incomingByte,DEC);   // print what was read

it doesn't work anymore....

What does this line do besides print the byte values out to screen? Does it somehow change the type of incomingByte?

Thanks for your help.

26  Forum 2005-2010 (read only) / Interfacing / Re: Serial communication with SonyEricsson C902 on: November 20, 2008, 06:21:36 pm
Have you tried swapping the pins on the phone end? Some sony phones are set up as DCE, which means they send out data on the RX pin, and receive it on the TX pin. The names are relative to the microcontroller, not the phone.

Also, are you sure dialing 000 is a good idea? Do that in Australia and you'd have the police knocking at your door, it's the equivalent of the US 911...
27  Forum 2005-2010 (read only) / Interfacing / Re: Arduino to MATLAB on: March 09, 2007, 05:52:10 pm
You should just be able to get MATLAB to open the serial port and listen to incoming data. We did this using other serial sensors back in the Uni days, but I don't have a working version of MATLAB anymore to test it with Arduino.
28  Forum 2005-2010 (read only) / Interfacing / Re: Pixel from video in processing to Arduino LEDs on: December 20, 2009, 05:54:12 am
Seeing as how it's the same video over and over again - I'd cheat. Work out the RGB value you want at each timestep, "record" it, and replay it over and over on the arduino.

Then you just need to get the arduino to start "playing" at the same time as the video, which is A LOT easier than calculating values in real-time ever playing.

Of course you've got to work out the RGB values at least once - that bit;s up to you.
29  Forum 2005-2010 (read only) / Interfacing / Re: TLC5940.   Is there a max. length of daisy chain? on: October 27, 2008, 07:11:56 pm
Sounds like you are running out of RAM.

You could look at upgrading to the AtMega328 (involves some hacking at the moment) which will give you twice the RAM (2k vs 1k) and twice the program space (32k vs 16k)
30  Forum 2005-2010 (read only) / Interfacing / Re: Seperating Serial messages w/ Prefix's? on: February 10, 2009, 11:44:14 pm
If you post up your commented code, and explain what it does and how that is different to what you want it to do, I'll bet you get a reply or three
Pages: 1 [2] 3 4 ... 38