How to send a number as a number or How to rule an LED

2011-02-04 Thread Thomas McGrath III
I am having a problem communicating with an LED. (Never thought I'd hear myself say that!) I have code in LC in a slider: -- We are open driver ... for text update on mouseUp put the thumbPosition of me into tValue doUpdate(tValue) end mouseUp on doUpdate tValue put gThePort into theP

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread form
Try: write numtochar( tValue ) to file thePort This will only work for values less than 256, however. You can increase that range by breaking the number down into individual bytes and sending those in sequence. What you should do instead is send the number as ascii as you are now, but end it wit

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread form
On Fri, Feb 4, 2011 at 12:18 PM, form wrote: > > else > ++bufloc; // next read will go in the next buf char For safety's sake... else { ++bufloc; // next read will go in the next buf char if ( bufloc > 255 ) { // ERROR - buffer overflow -

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Nonsanity
On Fri, Feb 4, 2011 at 12:18 PM, form wrote: > sscanf( buf, "%s %i", &cmd, ¶m ); sscanf( buf, "%s %i", cmd, ¶m ); ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, un

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Thomas McGrath III
Well, Thank you very much the numtochar worked perfectly. SInce most of these are either two or three numbers being sent for motor/stepper and LED and will not be more than 255 I will stick with the numtochar() for this. I will still try to come up with a parser for the Arduino for passing comma

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Thomas McGrath III
Is this right? char cmd[255]; int param = 0; char buf[255]; int bufloc = 0; while ( true ) { buf[ bufloc ] = Serial.Read(); if ( buf[ bufloc ] == 13 ) // CR EOL { sscanf( buf, "%s %i", cmd, ¶m ); if ( !strcmp( cmd, "LED" ) ) // if cmd == "LED" DoLed( param );

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Nonsanity
Glad it helped. Though as a longtime hardware serial interface user, I DO strongly suggest going the ascii route. That Arduino function should work as-is (with the bug fixes). Couple it with really simple code on the LC side and you're done. write ("LED" && tValue & CR) to file thePort ~ Chris

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Nonsanity
As long as you have DoLed( int ) and DoBeep( int ) functions, that looks right to me now. It should be clear how to modify that to your needs, and if not, feel free to contact me off-list and I'll give you a hand. :) ~ Chris Innanen ~ Nonsanity On Fri, Feb 4, 2011 at 12:38 PM, Thomas McGrath I

Re: How to send a number as a number or How to rule an LED

2011-02-04 Thread Mark Wieder
Tom- Friday, February 4, 2011, 8:22:28 AM, you wrote: > I send out a 125 but I get back three lines: > 1 > 2 > 5 > but the analogWrite is looking for 125 I had that problem when I was bringing up the MakeBoard as well. I was trying to send a decimal 192 to the board to initialize it. It took mor

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Claudi Cornaz
Hi tom, I am working with the same. What I undersrtand and have found on forums etc you need to use atoi() to convert from type char to int. You send out 3 chars when sending for instance, 125. The arduino seial.read routine will fetch 3 chars (125) I use a startChar 1 or more data chars and then

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Thomas McGrath III
Mark, I know what you mean. I spend so much time, sometimes, tracking down a problem in my code that I just want to join the army and charge up a hill screaming "Kill, kill, kill" until someone jumps up and shoots me in the shoulder and the force of the shot spins me around and now I'm falling

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Thomas McGrath III
Claudi, What is your atoi() code like? Why tDataStr[8] ? is that the number of chars you can read in? can that be more? What if we want to send "<13-125>" can we parse that to separate out the 13 for Pin 13 and the 125 for brightness? What about "<13-1-125>" and "<13-0-1>" for pin 13 output 12

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Richmond
On 02/05/2011 06:32 PM, Thomas McGrath III wrote: Mark, I know what you mean. I spend so much time, sometimes, tracking down a problem in my code that I just want to join the army and charge up a hill screaming "Kill, kill, kill" until someone jumps up and shoots me in the shoulder and the for

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Thomas McGrath III
Yeah, R, that's why it's a nightmare! I don't wanna be Rambo or Carrot Top. So why do they keep coming into my nightmares Just Askin! -- Tom McGrath III http://lazyriver.on-rev.com 3mcgr...@comcast.net On Feb 5, 2011, at 12:37 PM, Richmond wrote: > Um? One wonders how a Sylvester Stallone

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Richmond
On 02/05/2011 08:21 PM, Thomas McGrath III wrote: Yeah, R, that's why it's a nightmare! I don't wanna be Rambo or Carrot Top. So why do they keep coming into my nightmares Just Askin! Speaking as a person with red hair (that's going grey quite quickly) . . . the answer to the second on i

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Calvin Waterbury
Hi, I'm not a real big fan of the "muscular morons," but it might improve your opinion of Sylvester Stallone if you were aware that he not only starred in the "Rocky" series, but he wrote and directed too! My family just did an experiment for an exercise in film criticism (acting like critic

Re: How to send a number as a number or How to rule an LED

2011-02-05 Thread Claudi Cornaz
Tom, Yeah, yeah, that's all certainly possible. At last I am getting somewhere, a relaiable connection and communication with the arduino with all kinds of data. At the moment I work on a demo which has 2 sensors attached to the arduino and a led on the arduino >From LC I can send data from a

Re: How to send a number as a number or How to rule an LED

2011-02-06 Thread Claudi Cornaz
Hi all, Sorry for the wrong link I posted yesterday night. ( the arduino scetch instead of my demo stack) It was late and I was tired from constantly testing and crashing. Killing LC about 100 times in a couple of hrs. So please forgive. (The stack wouldn't have worked anyway something sneaked

Re: How to send a number as a number or How to rule an LED

2011-02-06 Thread Claudi Cornaz
Tom, There defenitly is hope. We can win that hill. It's also our's and we deserve to be there. It looks like I have assembled quite a stable setup. A kind of basic framework which will first establish contact between the arduino and LC and for both sides the routines to recieve and deciever