Show Posts
Pages: [1] 2 3 ... 7
1  Forum 2005-2010 (read only) / Troubleshooting / Re: how to send once then stop sending? on: March 10, 2010, 04:15:23 am
You could use the following:
Code:
touchXOld = 0
if(touchX > 127 && touchX <> touchXOld){
  touchXOld = touchX;
  MIDI.sendControlChange(22,0,1);   //needs to be sent only once
} else {
  MIDI.sendControlChange(22,127,1);   //needs to be sent only once
}  

Which triggers when touchX is greater than 127, and then again only when touchX is greater than 127 and different to the previous value.
2  Forum 2005-2010 (read only) / Troubleshooting / Re: uploading error in my first sketch on: February 05, 2010, 11:30:15 am
Have you installed the FTDI Drivers?

Have you set the right COM port in the IDE?

Looks like the IDE can't find the arduino hardware.

Have a look at the Troubleshooting guide for more suggestions:

http://www.arduino.cc/en/Guide/Troubleshooting
3  Forum 2005-2010 (read only) / Troubleshooting / Re: Stray ## on: September 28, 2009, 03:52:11 am
Looks like the problem is the first line from the error:

Line 1 -##main.pde

Remove it and see if it then compiles
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Odd Behavior on: August 01, 2010, 07:20:09 pm
The problem comes because the byte data type can only hold a number from 0 to 255. When it reaches 255, it rolls over to 0, and so never becomes 256 and as a result the loop will never stop.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Can pulseIn() function be applied to HW INT pin on: March 09, 2010, 11:44:57 am
Usually to do this you can read the counter direct, to get a measurement of the time between pulses. You read the counter value, store it, and then read it again on the next interrupt, and you can then work out the interval, before resetting the counter or storing the counter value. You need to make sure you check the overflow flag to see if the counter has overflowed (and consequently started from the beginning again) during  the period whilst waiting for the interrupt. Also make sure you have a sensible prescaler value, that matches the period of the interval that you want to measure.

Have a look through the ATMega datasheet, and it explains the counter registers and how they operate. It's not the easiest thing to get your head around, but very powerful when you do.
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Easy code question for an RFID reader..... on: March 08, 2010, 04:40:46 pm
The string library at:

http://arduino.cc/en/Tutorial/TextString

may also be of use to you.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Where is the code for analogWrite function on: March 06, 2010, 08:33:15 pm
If you're looking for the actual source code for the function, it's in the file:

arduino-xxxx\hardware\arduino\cores\arduino\wiring_analog.c
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Unusual serial data from RFID reader on: March 04, 2010, 06:00:05 pm
I`m not sure, as I don't know how the Parallax reader spits out data (i`ve only worked with the raw signal data), but I would imagine that those id's you're getting are hex ascii codes

so

32373030333932384633

would become:

32 = 2
37 = 7

30 = 0
30 = 0
33 = 3
39 = 9
32 = 2
38 = 8
46 = F
33 = 3

Giving:

Customer ID: 27
Customer Data: 003928F3

That would give the 10 bytes, and looks like it could be a valid tag
code
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Unusual serial data from RFID reader on: March 04, 2010, 04:53:49 am
The cards output 64 bits in the following order:

9 x 1 bit (to signal start of data)

10 bits - customer id (of which the 5th and 10th bit are parity check)

40 bits - user data (of which every 5th bit is parity check)

4 bits - column parity check

1 stop bit

= 64 bits

When you strip off the parity info and start and end markers, you are left with:

customer id: 8 bits

customer data: 32 bits

In hex you'll get something like:

customer id: 22

customer data: 00 06 8E 4D

Have a look at the EM4102 datasheet at:

http://www.emmicroelectronic.com/webfiles/Product/RFID/DS/EM4102_DS.pdf

10  Forum 2005-2010 (read only) / Syntax & Programs / Re: True C code help. Example inside. on: October 29, 2009, 10:36:32 am
Quote
either is kind of useless

I don't think it matters for the particular application it's being used for, which is essentially just showing random bars of colour on the screen, which change frequently. It gives a random-ish output, which is all they want, so the fact that some bits are being lost isn't a problem.
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: True C code help. Example inside. on: October 29, 2009, 06:25:09 am
The code is very simple, first of all:

Code:
DDRD = B11111111;

Sets PORT D to be all outputs, with DDRD being the Port D Data Direction Register. See:

http://www.arduino.cc/en/Reference/PortManipulation

Next:

Code:
PORTD = analogRead(0);

This reads the value from Analog pin 0 and converts it to a digital value, and then outputs it to Port D (which will be sent to the monitor)

See:

http://www.arduino.cc/en/Reference/AnalogRead

12  Forum 2005-2010 (read only) / Syntax & Programs / Re: Random max & min/max function C code on: November 11, 2009, 06:43:28 pm
In avr-libc there is already a rand() function which you can use with the attiny devices:

http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ge23144bcbb8e3742b00eb687c36654d1
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: Blinking and Serial Monitor on: September 29, 2009, 04:43:54 am
The problem comes from:

Code:
void loop() {
  ledState = digitalRead(ledPin);
  
  if (ledState == HIGH){
    Serial.println("on");
  }
  else if (ledState == LOW );{
    Serial.println("off");
    }
  {
  digitalWrite(ledPin,LOW);    // set the LED off
  delay(1000);                  // wait for a second
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(1000);    // wait for a second
  }
}

If you go through the program, it first checks the state of ledPin, and prints the value, high or low.

You then set ledPin low, wait, set ledPin high, and then wait again.

The problem comes because you are setting ledPin low then high each time. This means that each time the loop starts after the first iteration, ledPin will always be high (as that was the last state setting).

What you need to do is something like:

Code:
void loop() {
  ledState = digitalRead(ledPin);
  
  if (ledState == HIGH){
    Serial.println("on");
    digitalWrite(ledPin,LOW);
  } else {
    Serial.println("off");
    digitalWrite(ledPin,HIGH);
  }
  delay(1000);
}

This only toggles the state of ledPin once per loop, so each time round the loop it will have a different state to the previous iteration.
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino Mega on: September 09, 2009, 10:59:27 am
You could always use an external EEPROM chip, which are really cheap and easy to work with using the Arduino.

Something like the 24C256 for example which gives 256Kbits (32K), and only uses a couple of arduino pins.

http://www.datasheetcatalog.org/datasheets/228/160402_DS.pdf
15  Forum 2005-2010 (read only) / Interfacing / Re: Direct reading of a PORTD bit on: February 23, 2010, 10:22:20 am
I take it by "wiggling" you mean "toggling"  smiley ie 1 becomes 0 and 0 becomes 1

You can do this with an AND operation, because only 1 and 1 = 1 , so as soon as you get a 0 in there, the output will always be 0, it will never flip back to 1 again.

You need an XOR operation eg

PORTD ^= BV(5);

Will flip Bit 5

Pages: [1] 2 3 ... 7