Loading...
  Show Posts
Pages: 1 ... 19 20 [21] 22 23 ... 66
301  Using Arduino / Programming Questions / Re: Arduino and Raspberry Pi through Serial on: March 25, 2013, 08:02:52 pm
Well try 115200 and see what you get then.  Maybe it will be a login screen. 

Anyway, it looks like all the initialization is for 115200.

Or go back and try working through the directions…

Cheers,

-br
302  Using Arduino / Programming Questions / Re: Arduino and Raspberry Pi through Serial on: March 25, 2013, 07:56:43 pm
Out of thoughts here except to try 115200 instead of 9600, if you haven't already.

You did go through the Disable Login and Disable Bootup Information procedures at that link, right?

-br
303  Using Arduino / Programming Questions / Re: Need help with basic code problem on: March 25, 2013, 07:52:41 pm
After you increment buttonCounter, you might want to check to see if it's greater than 7 and set it back to 0 so it goes through your cases again. 

You probably want code to handle the 0 case, too.

-br
304  Using Arduino / Programming Questions / Re: Arduino and Raspberry Pi through Serial on: March 25, 2013, 07:47:00 pm
It sure looks like you still have to eliminate a baud rate mismatch.

How are you sending data from the Pi (post the code?), and how have you confirmed the baud rate it is using?

-br
305  Using Arduino / Project Guidance / Re: Help LED dim on: March 25, 2013, 07:44:09 pm
Code:
     digitalWrite(ledPin, brightness);

Does it work any better if you use analogWrite here? smiley

-br
306  Topics / Home Automation and Networked Objects / Re: Gauge controlled with Ajax shows Not A Number error on: March 25, 2013, 02:52:11 pm
Unless I'm mistaken, this javascript code, which runs in the browser, is trying to call GetPoolTemp(), a function from the Arduino C code.  Which isn't possible, right?
Code:
data-onready="setInterval( function() { Gauge.Collection.get('gauge1').setValue(GetPoolTemp());}, 800);"
Is the intention to send the actual temperature as part of the data-onready attribute?  If so, you'll need to call GetPoolTemp() on the Arduino and insert its value into the page you send somehow.

-br


307  Using Arduino / Programming Questions / Re: help talking to arduino using python 3 and pyserial on a raspberrypI on: March 24, 2013, 07:35:40 pm
This may help: try time.sleep(2) after opening the serial port and before writing to it.  This will allow the bootloader to time out and ensure the message goes to your program instead of the bootloader.

-br
308  Using Arduino / Programming Questions / Re: Does Arduino have an automatic time-out? on: March 24, 2013, 12:35:50 pm
Your constants are being evaluated as 16-bit int variables,and some of the values are too large to fit.

Marking your large constants with UL to make them unsigned long might help:

Code:
  delay(50398200UL);

-br
309  Using Arduino / Programming Questions / Re: Unsigned Longs cast as Ints during multiplication on: March 23, 2013, 08:16:09 pm
I don't see the bug in what you have there, but isn't this an easier way to generate powers of two?
Code:
unsigned long iPow(int power) {
    return 1<<power;
}

-br
310  Using Arduino / Programming Questions / Re: UDP packet Proccesing on: March 23, 2013, 11:55:09 am
Look into "strcmp()" and post your code if you want more than a guess for help.

-br
311  Using Arduino / Project Guidance / Re: New to Arduino on: March 22, 2013, 08:34:04 pm
May I offer some opinions? 

1. Trying to "learn the language" in the abstract is hard and often not the best approach.  At least not for me, and I've learned a few.

Learning a language "in practice", which is to say as a side effect of getting a project done, has a nice way of prioritizing the learning into just what you need at the moment.  So, find a project, get stuck, hit Google, do a little just-in-time learning, repeat.

2. When you have a project in mind, your first stop should be Google anyway, to find out what else has been written on the same  topic.  Read all the code you can find - you get better much faster reading well-written, working code than by reading reference material.  Finding a sample or reference sketch to start from can be very helpful.

3. A word on workmanship.  Take the time to study coding styles, and pick one to use as your own.  Apply it carefully in everything you write so your eyes will learn to spot discrepancies; this will save you half of your debugging time.  Nothing says "newbie" more than code that looks like an unmade bed, and bugs love to grow in poorly laid out code.  The compiler cares about every single character and so should you.

4. Debugging is as important as coding.  Unfortunately, it is twice as hard, so if you write something so clever you don't really fully understand it, you won't have a prayer of debugging it.  Favor simplicity in what you write and learn to use Serial.print() to confirm what's going on.  It's cheaper to think about "How am I going to know whether this is working?" when you write it than later when you're debugging it.

My $.02.  Good luck on your journey.


-br

312  Topics / Home Automation and Networked Objects / Re: control without port forwarding on: March 22, 2013, 06:54:52 am
The BitlashRedisClient example that ships with Bitlash might be a useful source of ideas, even if you don't use the code, which is here: https://github.com/billroy/bitlash/blob/master/examples/BitlashRedisClient/BitlashRedisClient.pde (and more about Bitlash here: http://bitlash.net)

Here's how it works.  Redis is an in-memory database server with publish/subscribe capabilities.  You set up a Redis instance somewhere (on your web server, or maybe a free one from http://RedisToGo.com).  Your Arduino connects to the database and listens for commands (by subscribing to a command channel).  Then your PHP web application connects to the database and sends commands to the command channel as needed.  Any arduinos connected to the channel receive the commands to be executed.  (There are libraries that make this easy on the PHP side.)

The key feature that allows this to work around firewall issues is the persistent outbound TCP connection from the Arduino to the database.  Unlike an HTTP connection which comes and goes for each request, the TCP connection can hang around as long as you like, so the arduino is in effect always listening for another command.

In the BitlashRedisClient example, the data that moves over the wire is Bitlash commands, but of course it can be anything.

Hope this is helpful; good luck with your project.

-br


313  Using Arduino / Programming Questions / Re: Unions+Functions+serialWrite = Error on: March 21, 2013, 05:07:03 pm
I think you were being bit by some variant of the "precompiler rearranges your sketch" bug. 

I got your last code to compile by adding a line defining SendMidiMsg(); see below. 

I got there by looking at the .cpp that is actually compiled for the project, which you can get from rummaging around in the build folder, which you can identify by turning on verbose builds in Preferences.  The precompiler phase moved the definition of SendMidiMsg above the definition of the union, which made the compiler unhappy.  It seems better here with the patch.

-br

Code:
#include "arduino.h"

#define _C4 0x30
#define _Cs4 0x31
#define _D4 0x32
#define _Ds4 0x33
#define _E4 0x34
#define _F4 0x35
#define _Fs4 0x36
#define _G4 0x37
#define _Gs4 0x38
#define _A4 0x39
#define _As4 0x3A
#define _B4 0x3B
#define _C5 0x3C
#define NoteOn 0x7B
#define MaxVel 0xFF

typedef union {
struct {
    uint8_t Command;
    uint8_t Channel;
    uint8_t Data1;
    uint8_t Data2;
  } Msg;
  uint8_t Raw[4];
} MidiMsg;
void SendMidiMsg (MidiMsg* Message);  // this is the magic line


void setup() {
Serial.begin(31250);
}

void SendMidiMsg (MidiMsg* Message){
Serial.write(Message->Raw, sizeof(*Message));
}

void SendNoteOn (uint8_t Note, uint8_t Velocity, uint8_t Channel){
MidiMsg Message;
Message.Msg.Command=NoteOn;
Message.Msg.Channel=Channel;
Message.Msg.Data1=Note;
Message.Msg.Data2=Velocity;
SendMidiMsg(&Message);
}

void SendScale (int ValveState){
uint8_t Vel=MaxVel;
uint8_t Ch=0x00;
switch (ValveState) {
case 0: SendNoteOn(_C4,Vel,Ch); break;
case 1: SendNoteOn(_D4,Vel,Ch); break;
case 2: SendNoteOn(_F4,Vel,Ch); break;
case 3: SendNoteOn(_E4,Vel,Ch); break;
case 4: SendNoteOn(_A4,Vel,Ch); break;
case 5: SendNoteOn(_B4,Vel,Ch); break;
case 6: SendNoteOn(_G4,Vel,Ch); break;
case 7: SendNoteOn(_C5,Vel,Ch); break;
}
}
void loop(){
SendScale(0);
}
314  Using Arduino / Programming Questions / Re: Unions+Functions+serialWrite = Error on: March 21, 2013, 04:42:39 pm
Also, what happens if you change:
Code:
Serial.write(*Message.Raw, sizeof(*Message));
to:
Code:
Serial.write(Message->Raw, sizeof(*Message));

-br
315  Using Arduino / Project Guidance / Re: running bitlash scripts from the arduino on the arduino without serial input on: March 20, 2013, 08:18:57 pm
How cool is that.  Thanks!

-br
Pages: 1 ... 19 20 [21] 22 23 ... 66