Show Posts
|
|
Pages: 1 [2] 3 4 ... 39
|
|
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.
|
|
|
|
|
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.
Thanks,
Alex
|
|
|
|
|
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...
|
|
|
|
|
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:// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160543432Here's my code byte incomingByte ; int LEDpin; void setup() { Serial.begin(9600); } 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 = Serial.read(); // 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 Serial.println(LEDpin); digitalWrite(LEDpin,HIGH); // Light up LED while (Serial.available()) { incomingByte = Serial.read(); // 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.
|
|
|
|
|