Show Posts
Pages: 1 2 [3] 4 5 ... 66
31  Using Arduino / Programming Questions / Re: reset static variable on: July 20, 2014, 06:33:06 pm
Not sure if that is what you are doing, but if you write in the EEPROM every loop(), the cells where this long is written, will be ruined very quick and it will fail to read from or write to it.

Quote
The EEPROM memory has a specified life of 100,000 write/erase cycles, so you may need to be careful about how often you write to it.

Maybe show your code so we can understand what you want to do.
32  Using Arduino / Programming Questions / Re: Callback function to serial avaiable. on: July 20, 2014, 04:43:06 pm
Hello,

You want to increase speed, yet you are using delays and while loop... smiley

Read this: http://gammon.com.au/serial

And also read about "Blink without delay", for non blocking code.
33  Using Arduino / Programming Questions / Re: reset static variable on: July 20, 2014, 04:37:55 pm
Why make it static if you want to change it's value? I don't understand what you want to do..
34  Using Arduino / Programming Questions / Re: Fonts on: July 20, 2014, 04:17:04 pm
I think I can help you

Take for example number 0. In ASCII, it's decimal value is 48. Now look in the font file, where it say "//48". Convert these hex numbers of this line, into binary, using the Windows calculator or whatever.

It gives this:

Code:
11111100
00000010
00000010
00000010
00000010
11111100
00001100
00010000
00010000
00010000
00010000
00001100

You see the pattern? If not, remove the zeroes:
Code:
111111
      1
      1
      1
      1
111111
    11
   1
   1
   1
   1
    11

Combine the first half with the second half, you got your 0, (rotated to 90° for some reasons) smiley-wink
Code:

    11111111
   1        1
   1        1
   1        1
   1        1
    11111111

Do the same thing for the 5 now, fix the "drawing" as you like, then convert back from bin to hex, tadaa it's fixed smiley-wink
35  Using Arduino / Programming Questions / Re: find value in long table. on: July 20, 2014, 08:36:40 am
What?
36  Using Arduino / Programming Questions / Re: Using switch case on: July 19, 2014, 10:17:25 am
Serial.read() return a char, not an int. so in the switch, use '1' instead of 1, etc. smiley-wink

Edit: sorry, Serial.read return an int, but it will be the ASCII decimal value of the character that was received. Still, the solution is to use '1', or it's ASCII decimal value: 49
37  Using Arduino / Project Guidance / Re: Small Bluetooth Device on: July 18, 2014, 09:39:12 pm
Hello and welcome smiley

With a cheap BT module such as the HC-07 (search on ebay), you just need to power it with 5VDC and it will be detectable by your phone.




To configure it, the easiest way is to use a USB to Serial adapter: search ebay for "PL2303". It's a little tricky to install it's driver if you use Windows 8 64bits, so PM me if you have problems with it.



You connect the HC-07 to it ( RX to TX, TX to RX, VCC to 5V, GND to GND ) then plug into your computer, then you open the Arduino IDE's Serial Monitor (or any other Serial terminal) on the corresponding Port and at 9600 bauds, and send AT commands.

Default password is 1234, and here is details of the available AT commands for the HC-07:

Quote from: some chinese vendor
1, test communications
Send: AT
Return: OK
 
 
2, change the Bluetooth serial communication baud rate

Send: AT + BAUD1
Returns: OK1200
 
Send: AT + BAUD2
Returns: OK2400
......
1 --------- 1200
2 --------- 2400
3 --------- 4800
4 --------- 9600
5 --------- 19200
6 --------- 38400
7 --------- 57600
8 --------- 115200
9 --------- 230400
A --------- 460800
B --------- 921600
C --------- 1382400
 
Not recommended for more than 115200 baud rate, signal interference make the system unstable.
Set with more than 115,200 machine is unavailable, use microcontroller programming at higher than 115 200 in order to use this baud rate and re-issued AT command set low baud rate
AT command to set the baud rate, the next power to use without re-set, you can power down to save baud rate.
 
 
3, change the Bluetooth name

Send: AT + NAMEname
Returns: the OKname
Parameter name: To set the current name, the Bluetooth name to be searched. 20 characters or less.
Example: Sending AT + NAMEbill_gates
    Return OKname
    To changed bill_gates Then the Bluetooth name
    Parameters can be powered down to save, simply modify the time. PDA-side refresh you can see the Bluetooth name changed.
 
 
4, change the Bluetooth passkey

Send: AT + PINxxxx
Returns: the OKsetpin
Parameter xxxx: To set a passcode, 4 bytes, this command can be used from the machine or the host. The slave adapter or mobile phone pops up to enter the passkey window, then manually enter this parameter can be connected to the slave. Host with the master Bluetooth module with digital cameras, digital cameras from the machine, find the password of the camera pair, and then set up the White Bluetooth module, the master Bluetooth module can automatically connect the camera.
Example: Sending AT + PIN8888
    Return OKsetpin
    At this time the Bluetooth pairing password to 8888, the module at the factory default passkey is 1234.
    Parameters can be powered down to save, simply modify the time.


Note that you can also use your Arduino to configure it, but it's more work for you, I don't recommend it.
38  Using Arduino / Programming Questions / Re: PC Application for controlling Arduino on: July 18, 2014, 09:34:10 pm
It's fairly easy to write this kind of program with C#, try it smiley-wink
39  Using Arduino / Project Guidance / Re: Power supply question on: July 14, 2014, 09:22:27 am
The Arduino require between 7-12V if you use the plug, but you can power it with 5V if you use the Vin 5V pin (which I don't recommend).

I use a 12V 5A power supply ( KY-60W-12-L, 7€ on ebay), on which I have some step downs to output different voltages (7.7V for the Arduino so the onboard voltage regulator is cold).

It all depend what you really need. If you may need to power 12V devices, then choose a 12V power supply.

If I understand, your pump require 300mA. I recommend at least 500mA for the Arduino. So it's 0.8A. Add a good safety margin, so buy a power supply that can deliver at least 1A smiley-wink

40  Using Arduino / Project Guidance / Re: Power supply question on: July 14, 2014, 08:16:13 am
Yes this could work but are you sure 0.6A is enough current to power both arduino and your pump ? I really doubt it.


By the way, if you use step down module like this one:


Their output is limited to 2A (up to 3A if you add a heatsink on the LM2596) but this should be more than enough for your pump.


The question is: how much current is required by your pump? Any marking about current or power?
41  Using Arduino / Programming Questions / Re: why do we use int instead of long on: July 13, 2014, 03:19:34 pm
Who "we"? Bad practice from the examples on the playground and on the forum.

I always use the appropriate variable type, even if I use an Arduino Mega 2560. Even then, I try to optimize as much as possible, such as using bitwise operations to store for example 2 numbers ranging between 0 to 15 in a single byte, or 8 booleans in a single byte...
42  Using Arduino / Programming Questions / Re: why do we use int instead of long on: July 13, 2014, 01:55:36 pm
Hello and welcome,

Long take twice more memory than int, on devices with limited memory you have to consider using the smallest variable possible smiley-wink

For example if you are sure your number will range between 0 and 255, then you should use a variable of type byte (or "uint8_t", same thing) which take one byte. An int take 2 bytes, a long take 4 bytes.
43  Using Arduino / Programming Questions / Re: Gps coord to gsm sms on: July 10, 2014, 04:42:04 pm
Hello,

Try something like this:

Code:
mySerial.print( "AT*EAPP=0,0,\"" );
mySerial.print( myChar );
mySerial.println( "\"" );

Or you try sprintf, or strcat, whatever.. smiley-wink
44  Using Arduino / Installation & Troubleshooting / Re: ide error message "avrdude stk500_getsync(): not in sync: resp=0x00" on: June 30, 2014, 04:22:39 pm
Ahhh n00b ! J/K smiley-wink
45  Using Arduino / Programming Questions / Re: Make something happen only once with a digital input on: June 30, 2014, 01:01:36 am
Hello,

Read this carefully first:

http://gammon.com.au/switches

Especially the parts Detecting transitions, and Debouncing Without Delay


Then you will have to do something like this:
Code:
//top of your code
uint8_t sequenceId = 0;

//when button is pressed
if ( button_was_pressed )
{
  // increase sequenceId, and reset if greater than 2 (so it goes 0, 1, 2, 0, 1, 2 etc... )
  if ( ++sequenceId > 2 )
    sequenceId = 0;

  // here is where you should clear and write the matrix.
  // this is a good idea to use a switch statement here, instead of your multiple if statements
}
Pages: 1 2 [3] 4 5 ... 66