Show Posts
Pages: 1 ... 34 35 [36] 37 38 ... 86
526  Using Arduino / Programming Questions / Re: Question about hex codes on: July 12, 2013, 06:04:41 pm
The numbers you have listed are all 16 bit integers. The number you showed separately (0x02FD48B7) is a long value (32 bits).

Each hex digit takes 4 bits (0-F), so it is easy to work out the data types you need to store the values. Up to 2 hex digits fits in a uint8_t, up to 4 in a uint16_t and up to 8 in a uint32_t.
527  Using Arduino / Programming Questions / Re: Pointers / Data types (LCD4884) on: July 04, 2013, 09:11:50 pm
A % followed by another % character will write a single % to the stream.
528  Using Arduino / Programming Questions / Re: Pointers / Data types (LCD4884) on: July 04, 2013, 08:33:51 pm
Just to add to PaulS response, if you want to have leading zeroes for single digits, use %02d. This will keep the string exactly the same length.
529  Using Arduino / Programming Questions / Re: Calling functions from another file on: July 04, 2013, 04:59:42 pm
You can include a .h or a .cpp file, that would be clearer than the .ino.

A .cpp without objects (just functions) should also work as long as you have a separate header file with function prototypes so that the file ordering doesn't get in the way. Haven't tried this, but it should work.
530  Using Arduino / Sensors / Re: Least lines for 8 switches on: July 04, 2013, 04:52:21 pm
A parallel to serial input converter like the 74HC165 is cheap, available and uses 3 lines to interface as many of these chips as you need (they cascade). Lots of examples (code and circuits) on how these are used. Each chip takes 8 bits in parallel and squirts them out as a serial stream that you can assemble into a byte at the Arduino end. Datasheet here

The reverse comms is done using the 74HC595 chip.
531  Using Arduino / Displays / Re: Why is there a pot connected to the lcd? on: July 02, 2013, 07:21:31 am
Usually it is used to adjust the contrast for the display. Different lighting conditions can mean that you can't see the LCD so adjustment may be necessary.
532  Using Arduino / Sensors / Re: Sensor for stringed instruments on: July 02, 2013, 07:19:06 am
Electric guitar pickup?

I have also seen suggested that a piezo disc can be used to detect the vibration of the string.
533  Using Arduino / Programming Questions / Re: Pointers / Data types (LCD4884) on: June 30, 2013, 10:04:14 pm
A pointer is just a memory address. In this case the memory address of the start of the string, but in general ANY memory address.

To get the address of a variable you use the '&' operator (ie, &fred gives you the address of the variable fred). For arrays, this is technically the address of the first element (&var[0]), but the convention is that a reference to an array variable name is the same as the address of that array (ie, 'var' is the same as '&var[0]'). A character string is an array of characters, so the name is the address.

In your case, declaring a variable of 14 characters in size (option 2) creates a memory space that you can use and modify as you need. Just declaring a pointer to a 'constant' string, does not allow you to modify that string, as you do not know where the string is stored. In either case you can use the name of the string (option 1 because it is a pointer, option 2 because it is the first element of the array).

Personally I would use option 2 if you need to change the string.
534  Using Arduino / Displays / Re: Character LCD: print a filled block without using custom characters on: June 27, 2013, 10:19:50 pm
One of the characters in the ROM is a filled in block. Google is your friend here, the character set is on a large number of web sites. Look for "LCD hitachi HD44780 datasheet pdf" and something should land.

Alternatively, just print every characters from 9 onwards and see which one it is. A lot of them above ASCII 127 will be Japanese.

BTW, you have to use lcd.write(255) to get the ascii character, not print().
535  Using Arduino / Displays / Re: How to display "big" numbers on a character LCD on: June 27, 2013, 05:04:27 pm
I have done soimething similar but I think my code is a bit more compact. See the link below for my repository if you are interested.
536  Using Arduino / Storage / Re: Reading .txt files from SD card on: June 27, 2013, 04:57:18 pm
You really don't need to have any structure to the file if all you are doing is saving a bunch of numbers, as how you read them in creates the structure in the code. I would not bother with the '[' and ']'. I am assuming you know how to open a file for reading or can at least find out.

I would start by
for (uint8_t i = 0; i<ROW_SIZE; i++)
  for (j=0; j<COL_SIZE, j++)
    array[i,j] = readValue();

Then just write a readValue() function that reads the next element of data from the file. The logic for the function looks something like this:
if end-of-file return(0);
read characters while they are not a number
num = character - '0'; // this creates a single digit number from the ASCII character
while the characters are numbers
 num = (num * 10) + character - '0';

You may also find a function in the SD library that you are using that could read the next number for you - that depends on the library.

To write the numbers is very similar - use the loop and write the values instead of reading them.
537  Using Arduino / Programming Questions / Re: decimal operation on: June 26, 2013, 11:19:34 pm
1. If you are using floating point numbers then you need to write expressions like
to make sure that everything is treated like a floating point number and no intereger conversions are creeping into the calculations.

2. Casting is used to change the value to an integer. Make sure you pick the correct size integer.
int x;
float f=1234.0;

x = (int)f;
538  Using Arduino / Audio / Re: HELP ME!!! I need some advice for a Piezo-MIDI Arduino project on: June 26, 2013, 11:11:59 pm
What code have you already written?

The steps you describe are bascially correct, except that you need to deal with more than one piezo and you need to make sure that all the piezo's are serviced (so no using delay() anywhere).

Each Piezo has a small circuit associated with it (1 MOhm resistor and a 5.1V zener) to make sure you don't blow up the AVR port. Lots of examples of these if you Google. I assume that your drum kit thing is just a few of these, and I woudld bet they have sample code for processing a piezo on their web site.

Once you have the magnitude of a the hit from analogRead() you need to convert that into a velocity. The drum that is hit determines the type of instrument that you want for that input. The two together will get you your MIDI message parameters, which you output through a serial port.

On the MIDI side you need to make sure that you initialise the right parameters and according to MIDI rules (typically I shut down all the sound, select GM map 0, etc). Remember that you are writing to MIDI channel 10 (or 9 when it is in the MIDI message, as the ports are actually zero based) which is the default percussion channel.

Enough to get you started? As per above, Google is your friend here. This has been done many times before.
539  Using Arduino / Sensors / Re: Water level control on a model live steam boat on: June 24, 2013, 07:14:10 am
What about a mechanical float that is either connected to a water valve or a pot? If the pot is used as the pivit for the float it will give an analog signal depending on the level of the float.
540  Using Arduino / Displays / Re: Degrees symbol on lcd? on: June 22, 2013, 09:08:40 pm
The reply has already been given, which is character 0xdf.

This Wikipedia article has a link to the datasheet for the display that has a map of all the characters

All of the Hitachi controller LCDs I have seen are the type with the ROM set to the Japanese character set. The characters cannot be changed unless you can change the ROM on the display, which is a factory function and not dependent on the Arduino libraries.

Also has been suggested that you can define your own characters, but this is limited to just 8 (ASCII 0-7) and there are a lot of examples of how to do that on the forum and just using Google.
Pages: 1 ... 34 35 [36] 37 38 ... 86