Show Posts
Pages: 1 ... 435 436 [437] 438 439 ... 581
6541  Using Arduino / Programming Questions / Re: Serial and RFID - Comms on: January 11, 2012, 11:50:15 pm
Serial.print(integer) does not print leading zeroes.  If you want them you have to insert them yourself:
Code:
if (value < 16)
    Serial.print("0");
Serial.print(value, HEX);

Checking for 3 or more characters in the input buffer is a good idea:
Code:
    if (mySerial.available > 2)
        {
        result[0] = mySerial.read();
        result[1] = mySerial.read();
        result[2] = mySerial.read();

        }

        }
6542  Using Arduino / Audio / Re: MIDI playback/sequencer with finely controlled beat timing? on: January 11, 2012, 11:41:21 pm
The timing in the Arduino is typically done in milliseconds (delay() and millis()).  The code you have seen probably converts whatever time interval they care about into milliseconds.  If you want more precision, just specify milliseconds directly.  If interval values are being stored in a byte, you may want to increase the length of the time values to int or long so you can get more than 0.255-second events.  An unsigned int should allow for events up to 65.535 seconds.
6543  Using Arduino / Project Guidance / Re: Is this possible? on: January 11, 2012, 04:01:25 pm
The hard part will be maintaining a good count.  It is not easy for a sensor to detect the difference between one person entering and two people entering close together.  Perhaps a multi-touch pressure-sensitive mat near the door(s) could count feet entering and leaving.  That could get confused by rolling luggage or bicycles.

Perhaps you should build a turnstile.  smiley
6544  Using Arduino / Installation & Troubleshooting / Re: avrdude: stk500_getsync(): not in sync: resp=0x00 [Please Read] on: January 11, 2012, 03:54:48 pm
Sounds like the problem is in the PC.  The Uno and Duemilanove use different USB drivers and have separate USB hardware.

Did you try a different USB port?  Did you try rebooting the PC. Are you sure you selected the correct serial port under Tools? Are you sure you selected the correct board type under Tools?

If you can get one Arduino working you can use it to refresh the firmware on the other Arduinos.
6545  Using Arduino / Project Guidance / Re: RFID reader won't do what I'm telling it to! on: January 11, 2012, 01:48:58 pm
Code:
SoftwareSerial RFID(2,3);

Connect the TX of the RFID to D2 and the RX of RFID to D3. Then use RFID just like Serial:

Code:
RFID.begin(9600);

if (RFID.available())
   int input = RFID.read();
6546  Using Arduino / Project Guidance / Re: New First Project on: January 11, 2012, 01:44:52 pm
Code:
void loop()
    {
    if (RF.available())
        {
        int press = get_button_press();

        switch (press)
            {
        case 2:
            mode = (mode + 1) % MAX_MODE;
            break;
            }
        }

    switch (mode)
        {
    case 0: // Initial state
        //  Code for the first mode
        break;

    case 1:
       //  Code for the second mode
       break;

    .
    .
    .

    case MAX_MODE-1:
        // Code for the last case
        break;
        }
    }
   
6547  Using Arduino / Programming Questions / Re: looking for a guide on number formats on: January 11, 2012, 01:36:44 pm
is there any way to do the conversion without creating a new variable?  say i have a value stored in x, and then make x itself the new variable? or is that illegal.

You can't change the declaration of a variable.  As Mike says, either use a 'cast' to change the interpretation of the variable or create a new variable with a different type and name and copy the old variable to the new variable.
6548  Using Arduino / Project Guidance / Re: RFID reader won't do what I'm telling it to! on: January 11, 2012, 01:31:07 pm
When you have the serial pins connected to the RFID device correctly the RFID fights with the USB-to-Serial for control of the pins.

Try using SoftwareSerial.h to talk to your RFID device so you can use the hardware serial port for upload and debugging.
6549  Using Arduino / Project Guidance / Re: Beginner help with IR and Motors on: January 11, 2012, 01:26:40 pm
The single quotes are for a character constant, not a string constant.  It takes at most two characters and puts their character codes into an integer.

'1' == 0x31 == 49
'2' == 0x32 == 50
...
'9' == 0x39 == 57

12597 = 0x3135 = '15'

Use double-quotes for string constants.
6550  Using Arduino / Audio / Re: help w/ pocket piano on: January 11, 2012, 01:19:22 pm
http://www.arduino.cc/playground/Learning/4051

Most chips have the power and ground on opposite corners.  In this case 8 is Ground and 16 is Vcc.
6551  Using Arduino / Project Guidance / Re: New First Project on: January 11, 2012, 01:15:41 pm
Ah...  "fr" meant RF, not IR as I had guessed.  Should not be a problem.

If you have an RF transmitter/receiver that can turn the Arduino ON/OFF then that's not something the Arduino would be doing.

You can use a basic Arduino to easily provide brightness control for 6 LED's and ON/OFF control for up to an additional 12.  The Mega can control a LOT more.

What you are trying to do is fairly easy so you should go ahead and play with it.
6552  Using Arduino / Programming Questions / Re: looking for a guide on number formats on: January 11, 2012, 12:48:16 pm

Standard Conversions:

http://msdn.microsoft.com/en-us/library/aetzh118(v=vs.80).aspx
6553  Using Arduino / Project Guidance / Re: RFID reader won't do what I'm telling it to! on: January 11, 2012, 12:45:52 pm
A bug in your first code:

'hasrun' is local to the function so it gets initialized to 0 each time loop() runs.

Giving the name SSRIDV1.1 is not sufficient.  Nor is a picture of the device. Google can't find any info on "SSRIDV1.1" or "SSRID V1.1" or any reasonable variant such as "SSRFID V1.1".

Please provide a pointer to the specification of the device AND give some indication of how you wired it to the Arduino.
6554  Using Arduino / Microcontrollers / Re: Small Linux Box? on: January 11, 2012, 12:34:18 pm
BeagleBone (~$90)
6555  Using Arduino / Project Guidance / Re: Beginner help with IR and Motors on: January 11, 2012, 12:30:23 pm
You would probably be better off keeping the value an unsigned long integer rather than converting to a string:

Code:
switch (results.value)
    {
case 0x18E7C03F:  // left
    // code for left
   break;

case 0x18E740BF: // right
    // code for right
    break;
    }

If you REALLY want to use strings (which take up more memory space) try  ir_code = String(results.value, HEX);
Pages: 1 ... 435 436 [437] 438 439 ... 581