text:
I want to build a radar alert system with Arduino
I'm new to all this. I bought an Arduino Uno recently and an Ultrasonic distance sensor. My mom's cats keep walking down into the basement and doing their... business. Anyhow, I want to create a radar system which detects movement past this door. I'd like to have an alert sent to my computer or Android. Is this within a basic Arduino level? Other than the Arduino what else might I need?

The widely available ultrasonic modules are more suited to detecting object presence (ie distance) than specifically motion, but they are at least cheap and easy to experiment with.  You could also consider an IR beam-break for presence.  In terms of an alert, would a local audio transducer be workable?  If not you can look at bluetooth, or wifi, perhaps even running your project on an Arduino-ified ESP8266 instead of an actual Arduino in the latter case.

That would be a sonar, not a radar.

Of course, you could do what I did when my kids were babies ... put a gate across the stairs.

I think that's quite possible. As mentioned, not technically radar. I don't know if cats could hear it, but then if it scares them off, job done, right?
I don't know if sending the alert to a PC would help or not - you might just consider an audible alarm using a cheap 8-ohm speaker. Otherwise, USB, bluetooth, wifi, or SMS for notification. A PC or phone (on all the time) to receive the data. Some thought about what you will do with it.
As a deterrent, a water pistol is ideal, you'd need a motor - solenoid? - to fire the water pistol. Harmless, but very distasteful to cats.
https://www.youtube.com/watch?v=lxmRYRlgreo
Update: Inspired by @SDSolar, I checked it out - yes, cats can hear that frequency.

Cats have excellent hearing and can detect an extremely broad range of frequencies. They can hear higher-pitched sounds than humans or most dogs, detecting frequencies from 55 Hz up to 79 kHz.

(from https://en.wikipedia.org/wiki/Hearing_range#Cats )
This means they will probably learn to associate the sound with the water pistol (yes, cats CAN be trained, if they are motivated). This means if you remove your device, they will probably come back, but if you leave the sensor (active), but remove the water, then it will continue to work!

Cats can't hear 40 KHz.

According to wiki (as per my update), they can. Citation?

I stand corrected.  I am very surprised.  I didn't know any animal could hear that except maybe bats.  But I found this reference that confirms what Wikipedia says, sort of.  This one says up to 59 KHz:  http://pets.thenest.com/frequencies-cats-hear-8238.html  TNX for the info.  Learn something new every day.  So perhaps the mere presence of the sensor would be a deterrent?  Probably not for cats, unless the water pistol or a loud noise is triggered when they get in the critial range.

I'm not convinced an ultrasound detector will detect a cat.  They're fluffy and (usually) soft, so the ultrasound might not bounce off.
Instead I suggest you just try a gadget that annoys cats and keeps them out of the area.  It's an ultrasound emitter, and the noise is claimed to be objectionable to cats.  I've seen them sold in gardening stores, for keeping cats away from the bird table:
Opinions on cat scarers

Ultrasound should detect a cat - the question is more, if it will detect a cat amid background clutter at similar ranges.  Generally for the cheap pulse-in/pulse-out sensors, you have to arrange the situation so that the first substantial reflection is the object of interest.

If the other side of the stair provides a reliable reflection, then the reading would change with any obstacle in the way.

Ultrasonic sensors can only measure the distance to the nearest object in their cone. Are you sure you can detect a "small" thing like a cat?
I think the only feasable way is to use optical recognition (motion sensor with a camera - even a webcam - and a board like a raspberry pi).

As a project building a cat detector sounds interesting, but as a cat owner I can promise you that if you actually go through with it the cats will see it, play with it and trash it within 5 minutes.  If it is successful and you do manage to scare them out of the basement they are just going to find somewhere else to 'do their business' and that could be in your bed.
However, your sensor will need to scan a large field of potentially rapidly moving objects.  A beam wouldn't be suitable because they could step over or under it.  I think PIR would be best for this task, but PIR sensors might not be sensitive enough to detect the little darlings.
Another idea maybe a gas sensor based project to provide an audible warning when a human enters the area that there are 'landmines' in the proximity and extreme caution needs to be used, if you know what I mean :)

Sounds like you want the Arduino-Fart-O-Meter - http://www.instructables.com/id/Arduino-Fart-O-Meter/  -- which I found doing this Google search:  https://www.google.com/search?q=arduino+gas+sensor+for+cat+poop

ANSWER BASED ON YOUR TITLE:
Here is a microwave RADAR motion-sensing module that you might find useful.  You could mount it right by the stairs.
http://www.ebay.com/itm/262662221979
LFS-DC04 2.7GHz Microwave Radar Module DC 5V 360 Degree High Level Signal New

Product Introduction:
1.Model:LFS-DC04
2.Frequency:2.7GHz
3.Size:40*22mm
4.Input Voltage:DC 5V
5.Output Type:level signal output
6.Connection Method:VCC,GND connect with positive negative input, OUT,GND signal connect with output
7.Installation Height:1-3.5m
8.Sensing Ditance:5-8m
9.Delay Time:30s(quick testing mode is 4s)
10.Sensing Angle:360 degree
11.$1.59 price via the slow boat

ANSWER BASED ON YOUR TEXT:
Ultrasonic can work - you will want to position it so your software can tell whether there is a cat/no cat, like pointing it across a step.  With no cat it would give a reliable distance reading from something on the other side of the step.   With the cat in the way, that reading would change.
Yes, this is in the realm of Arduino, for sure.
Here is a Google search to get you started:
https://www.google.com/search?q=arduino+with+ultrasonic+sensor
To tell the difference between a cat an a human you would want a second sensor, above the cat's height, also.
Or you could use a DS3231 RTC module to decide when it is night-time so you wouldn't need to discriminate between cats and people at all.

Or there's an off-the-shelf solution: Innotek ssscat is a bottle of compressed air and a motion detector. The spray is harmless but it sounds like a hiss, which is Cat for GTFOuttaHere!

That is cool.  A bit pricey but I would love to see one in action.  If they were a quarter of the price I would use them as perimeter guards around my solar arrays to keep the critters away, including the family dog.  Upvote.


text:
Sending struct from Arduino to Raspberry Pi - wrong types
I'm using Raspberry Pi and Arduinos for my home automation project where Raspberry Pi is the controler of Arduino nodes.
I use nRF24 wireless transceivers to communicate.
My problem is that when I was sending a structure like following
struct TempSensorData

{
      uint32_t result;
      uint32_t temperature;
      uint32_t humidity;
    };
From Raspberry to Raspberry everything went fine but now when I use Arduino as sender I get very strange results:
received: status: 335544320, temperature: 754974720 degrees, humidity: 0%

While on Raspberry it was
received: status: 0, temperature: 22 degrees, humidity: 44%

Can this be a problem with types? Or with different type of architecture (like different sizes on 3-2bit and 64-bit arch)?
EDIT:
Code on Raspberry:
if (radio.available())

{
        // dump the payloads until we've got everything
        Message receivedData = {0};
        radio.read(&receivedData, sizeof(Message));
        TempSensorData data = receivedData.msgData.tempSensorData;
        std::cout << "received: status: " << data.result << ", temperature: " << data.temperature << " degrees, humidity: " << data.humidity << "%" << std::endl; //TODO here we have some strange numbers - check if we have proper types
    }
Before that I have:
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(0x4c);
radio.openReadingPipe(1, RASPI_READ_ADDR);
radio.openWritingPipe(RASPI_WRITE_ADDR);

radio.enableDynamicPayloads();
radio.setAutoAck(true);
radio.powerUp();
radio.startListening();

And on Arduino:
Header header = {thisNodeId, thisNodeType, 0, static_cast<uint8_t>(MsgType::TEMP_SENSOR_DATA), 12345, Status::ok};
TempSensorData dhtData;
dhtData.result = DHT.read11(DHT11_PIN);
dhtData.humidity = (int)DHT.humidity;
dhtData.temperature = (int)DHT.temperature;
Message message = {0};
message.header = header;
message.msgData.tempSensorData = (dhtData);
radio.stopListening();
radio.write(&message, sizeof(message));
radio.startListening();

I also use a common header with defined structures for both Arduino and Raspberry, which contains:
#define RASPI_WRITE_ADDR 0xF0F0F0F0F0LL
#define RASPI_READ_ADDR 0xF0F0F0F0E1LL

struct TempSensorData {
  uint32_t result;
  uint32_t temperature;
  uint32_t humidity;
};

enum class Status : uint8_t

{
        ok,
        error,
        fail
    };
enum class MsgType : uint8_t {
    INITIALIZATION,
    RESET_REQUEST,
    ACK_NACK,
    TEMP_SENSOR_DATA,
};

struct Header {
  uint8_t nodeId;
  uint8_t nodeType;
  uint8_t location;
  uint8_t msgType;
  uint16_t checksum;
  Status status;
};

union MsgData {
  InitMsgData initMsgData;
  AckNack ackNack;
  TempSensorData tempSensorData;
};

struct Message {
    Header header;
    MsgData msgData;
};

radio is an item of RF24 class from https://github.com/TMRh20/RF24/
Unfortunately the RF24 repo is 64 commits ahead of what I use.
EDIT2:
Maybe the problem lays in that
enum class Status {};

which I use in both files.
I must add that I use g++-4.7 when compiling on Raspberry and when compiling on Arduino I use avr-g++-4.8.2

Can you post the arduino send code and and the raspi receive code?

I second that - posting the code will help the most.

I added code...

@yeti - "Tags should help to describe what the question is about, not just what it contains." The nrf chip is merely background context of the question, the actual issue is a difference of structure padding between the two C environments which has no dependence on the communication channel, so adding that tag (at least as a 3rd party edit proposal) is not appropriate.

It is not a size problem: uint32_t is always 32 bits. Converting the
numbers to hex gives:

Raspberry to Raspberry: 0x00000000, 0x00000016, 0x0000002c
Arduino to Raspberry: 0x14000000, 0x2d000000, 0x00000000

There seems to be an offset between the two. You may just have lost one
byte when the Arduino is the sender. There may be also a byte order
issue, but your test is not sufficient to say. You can, e.g., send a
series of 0x12345678 to know for sure.
You need to devise a way of synchronizing the communication, i.e. to
identify, in the byte stream, which is the first byte of the packet.
Edit: Let me illustrate how this can happen both with and without
and endianness issue. I'll assume you are transmitting
{status: 0, temperature: 20, humidity: 45} and the first byte(s) of
the first packet are lost. On the receiving side, you combine the
remaining bytes of the first packet with the first byte(s) of the second
packet, and interpret the whole as a single packet. You get:
{status: 335544320, temperature: 754974720, humidity: 0}.
In a little endian to little endian scenario, you only need to loose one
byte:
original data:     0x00000000, 0x00000014, 0x0000002d
transmitted bytes: 00 00 00 00 14 00 00 00 2d 00 00 00
received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00
received data:     0x14000000, 0x2d000000, 0x00000000

In a big endian to little endian scenario, you get the exact same result
if you loose 4 bytes:
original data:     0x00000000, 0x00000014, 0x0000002d
transmitted bytes: 00 00 00 00 00 00 00 14 00 00 00 2d
received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00
interpreted data:  0x14000000, 0x2d000000, 0x00000000

Off-by-a-byte synchronization issues can be a big challenge when working with streaming channels like UARTs, but the nRF24L01 is at least natively packetized, so I wouldn't expect that to be an issue here, unless the code driving it wraps the native behavior in a streaming abstraction that can split data across packets.   Another potential concern might be misaligned access on the pi side; would have to check if that throws a fault, aliases oddly to an aligned address, or gets fixed in software emulation.

I found out that adding "attribute((packed))" to all structs I'm sending helped! Thanks @EdgarBonet - your answer made me think and helped resolving this issue..

This answer is fundamentally wrong - in fact it is a size issue, specifically an alignment one where a multi-byte type follows a smaller type.  The pi wants the larger type aligned, the Arduino doesn't care.

I believe this could be because the Raspberry pi is big endian and the arduino is little endian.
Learn about Endianness here!

It's definitely not just an endianness problem since 0 appeared as a different number.

Without code detailing how the logistics is implemented, it could realistically be anything. It is important to factor in endianness however.

Are you sure about the Pi? I've read in several places it's little endian by default. AVR based Arduinos are little endian too. I do not know about the Due.

This is incorrect.  While the pi's hardware may be capable of running in a big endian mode, and there are people who have tried to do that http://raspberrypi.stackexchange.com/questions/7279/big-endian-distribution-for-the-raspberry-pi Most normal Raspberry Pi Linux distributions are little-endian

@ChrisStratton, thanks for the insight. I generally use Big Endian with the Pi out of habit - it sort of stemmed from ignorance in an operating systems Uni project years ago, and I have just sticked with it. I guess I jumped the gun and didn't even consider that the OP was probably using a *nix distribution. You're absolutely right!

You may have multiple problem.
First of all the structure get align to be efficient on the specific architecture, to avoid those filling you have to tell the compiler to pack the structure. There are different way to pack depending on compiler used.
Then endianess is different, so the byte composing the value has to be swapped.
Finally there may be a desincronization or a bus error. In those case a sync message (normally 2 byte before each transmission) and a CRC are used to fix the issue.

No, endianness is not different here.

I said "may". i listed the common mistakes, and the first one was actually the one that fixed the problem:<<I found out that adding "attribute((packed))" to all structs I'm sending helped!>>

The problem is that you made a false declarative statement in its own paragraph - if you did not mean to falsely argue that the endianness was different, you need to edit your post.  And even then, suggesting as a possibility something that is not true in the given case would be unhelpful and misleading.

yes, you are righr about phrasing, but english is not my maon language. If you propose an edit i can accept it.
About the answer, given the problem that is wat could be realistically the problems; this will be helpful to people having similar issue, but an other of the possible other cause

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
How to program LCD shield?
So I'm using the DFRobot LCD Keypad shield to make a text-based game. Can someone give me an example? Let's just say i want to make the LCD display "text1" and then press up then select, it displays "text2". If I press down then press select, it displays "text3".

File -> Examples -> LiquidCrystal -> HelloWorld

The program isn't running.

I clicked upload and nothing happened.

You probably have to tailor the pin settings for your specific shield.  RTFM.

Wait will I need to solder for this?

No, you need to read in the manual for your LCD which pin is which and put them in the constructor for the Liquid Crystal object.

I tweaked the pins and still nothing.

Attach the shield to arduino then run the following code to check if everything is ok.
Wiring is made default.
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

int read_LCD_buttons(){               // read the buttons
    adc_key_in = analogRead(0);       // read the value from the sensor

    // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
    // we add approx 50 to those values and check to see if we are close
    // We make this the 1st option for speed reasons since it will be the most likely result

    if (adc_key_in > 1000) return btnNONE;

    // For V1.1 us this threshold
    if (adc_key_in < 50)   return btnRIGHT;
    if (adc_key_in < 250)  return btnUP;
    if (adc_key_in < 450)  return btnDOWN;
    if (adc_key_in < 650)  return btnLEFT;
    if (adc_key_in < 850)  return btnSELECT;

   // For V1.0 comment the other threshold and use the one below:
   /*
     if (adc_key_in < 50)   return btnRIGHT;
     if (adc_key_in < 195)  return btnUP;
     if (adc_key_in < 380)  return btnDOWN;
     if (adc_key_in < 555)  return btnLEFT;
     if (adc_key_in < 790)  return btnSELECT;
   */

    return btnNONE;                // when all others fail, return this.
}

void setup(){
   lcd.begin(16, 2);               // start the library
   lcd.setCursor(0,0);             // set the LCD cursor   position
   lcd.print("Push the buttons");  // print a simple message on the LCD
}

void loop(){
   lcd.setCursor(9,1);             // move cursor to second line "1" and 9 spaces over
   lcd.print(millis()/1000);       // display seconds elapsed since power-up

   lcd.setCursor(0,1);             // move to the begining of the second line
   lcd_key = read_LCD_buttons();   // read the buttons

   switch (lcd_key){               // depending on which button was pushed, we perform an action

       case btnRIGHT:{             //  push button "RIGHT" and show the word on the screen
            lcd.print("RIGHT ");
            break;
       }
       case btnLEFT:{
             lcd.print("LEFT   "); //  push button "LEFT" and show the word on the screen
             break;
       }
       case btnUP:{
             lcd.print("UP    ");  //  push button "UP" and show the word on the screen
             break;
       }
       case btnDOWN:{
             lcd.print("DOWN  ");  //  push button "DOWN" and show the word on the screen
             break;
       }
       case btnSELECT:{
             lcd.print("SELECT");  //  push button "SELECT" and show the word on the screen
             break;
       }
       case btnNONE:{
             lcd.print("NONE  ");  //  No action  will show "None" on the screen
             break;
       }
   }
}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
bi-directional nrf24 communication
The central arduino

The 1st node

The 2nd node

I want the central to send to the first node the rgb code like a string on the loop

"rgb: 255000255"

but when it detects something to PIR to send a string to central.
In addition every some seconds the 2nd node to send a string to the central the temperature.
As i mentioned in my previous questions i have some problems when it comes to the bi-directional comunication. I have tried a lot of code. Can someone show me how to achieve what i want to do if not with code, with steps. Please help me!!

You cannot (easily) have all nodes on the network with the same address.
There are ways of doing it but they aren't easy.  They basically involve creating a "broadcast" facility in your network, and that has certain caveats involved with it.
The nRF24L01 modules have an "auto-ACK" mode to give reliable communications.  This only works with 1:1 addressing and cannot work with broadcast.  If you want to (as most people do) use the auto-ACK facility then you have to have each node with its own unique address.  After all, if you're sending the ACK to a station, and there are multiple stations with that address, which one will ACK?
So you have to think about if what you are trying to achieve is really the right way of going about it.  It sounds like you want to just program another node with the same code as an existing node without making any changes to that code and "just have it work".  That's a very advanced topic and one that even I would spend quite some time implementing it.  Yes, you can do unreliable communications (i.e., no auto-ACK) then you could have all the remote stations with the same address, but I would certainly keep the master as a unique address.  Better would be for each node to start up with a pre-defined address which it then uses to ask the master for a unique address (a-la DHCP) and the master then keeps a list of what is connected on what address.  From then on it can use reliable communications to send and receive data to each node as it needs to.
A system I wrote for the chipKIT boards gives each node two addresses - its own unique address which you have to provide manually, and a more global "broadcast" address.  They are each on different pipes within the nRF24L01.  To communicate with an individual node you send to its unique address.  To broadcast to all nodes you send to the broadcast address.  If you're sending to the unique address you can then turn on auto-ACK. If you're sending to the broadcast address you don't turn on auto-ACK.
Note that using auto-ACK is a whole topic in itself and requires careful design planning to get it to work properly.
Also you have to think about what happens when you send a broadcast packet out and it's received by other nodes - how do they handle that data? Sending temperature data out globally, it will be received by the RGB receiver, which may try and interpret it, causing problems.  You need to come up with a way of identifying just what it is you're sending out and only having the right nodes responding to the right data.  That means coming up with a strict packet format.  Luckily the nRF24L01 chips communicate in fixed packet sizes (incidentally, all nodes on the network will have to be set to use the same packet size or it just won't work) up to 32 bytes, so implementing a packet structure over that is easy enough.  Just sending strings of data is both hard to interpret and incredibly inefficient.  You should be sending the data as actual data values in variables as part of the packet structure.

Try the RF24Network library from maniacbug. If you don't have too many nodes it's easy to use. It comes with examples easy to test and extend. It also uses different channels for sending and receiving so you should have no collisions.

I want all nodes to have the same transmitting address in order to ad more in the future without changing the code. Is that way any solution?


text:
Can all Arduino Due pins be used as digital input/output?
I am using an Arduino Due for a project. I am running out of digital pins, using 22 to 53. Can pins 0 to 13 and SCL1, SDA1 be used as digital inputs?
How about analog pins (A0 to A11) and DACs?
Thanks!

Bear in mind that this has nothing to do with "Electrical Engineering".
This simply is an arduino question. And should be asked on arduino Stack Exchange.
Yes.
They can be used as input/output pins. [Simple 'tutorial']
If that even isn't enough or not working on your type of arduino, you can use I/O expanders or shift registers.
Check them out on the internet. [I/O expanders]

See also the first paragraph of the official docs on Ardunio:
https://www.arduino.cc/en/Tutorial/DigitalPins

Yes, sort of. All the Analogs/digitals can be used as digital outputs with the following exceptions. TX0/RX0 (unless you are aware of what you're doing), SPI buss (SCK/MOSI/MISO), SDA1/SCL1, & CANRX/CANTX. DAC0/DAC1 may be used but be aware the min/max those two pins can output is ~0.55 to 2.75V.
And these exclusions are only for an arduino DUE. Other Arduino's will have more/less exclusions.
Correction:  I was able to use CANRX and CANTX as alias pin names to declare these two lines as digital outputs, and set the pin values high/low in the normal way.

With the min/max of ~0.55 tot 2.75V, do you mean that those outputs can't be 0V? Or that ~0.55v is at least required tot read a logic high?

That's what the Datasheet stated for those two pins, my guess is that the DAC outputs are part of an internal R2R DAC network so Vss and Vdd may not be achievable on those two pins.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How do I connect this SPI serial display to an Arduino?
I've recently purchased a screen on DX without really thinking about it, because I have no idea how to connect it to my Arduino.
It is this screen:

The description says that it uses the SPI serial protocol but I don't know how to connect that ribbon to my Arduino, is soldering cables to it the only way?

I believe that this may be the specification: http://www.elecfreaks.com/store/18%E2%80%99%E2%80%99-tft-lcd-tft0118sp-p-671.html

There are a ton of pins coming out of that LCD.
I could imagine that it needs some kind of driver chip (which might be controlled through SPI).
I've recently ordered one (which looks rather similar) but with a "breakout" or driver board (http://www.sainsmart.com/sainsmart-1-8-spi-lcd-module-with-microsd-led-backlight-for-arduino-mega-atmel-atmega.html/).

That kind of connector is most commonly directly soldered on to a PCB.  You can buy adaptor boards with the various different pitch pads on them for soldering it to.

Also there is no mention of what chip the screen uses (I am unfamiliar with "XS057" as a chip, so that is probably the model of the screen not the chip).  At that resolution it's probably an ILI9163, but without being sure all you can do is stab wildly in the dark and try different drivers.

That looks like exactly what I need! Thanks.
And I did find the datasheet on this website, so once I get that PCB I can most likely find my way. Thanks again!

You might find this useful: https://www.youtube.com/watch?v=R698z9QaypY

Ah, it's an ST7735. That would have been my second choice.  Same basic chip as is used on the adafruit 1.8 shield: http://www.adafruit.com/products/802

On the datasheet I found this specification, so that means I need an adapter for 0.40mm correct?

No, that's the pad width.  The one you are interested in is the "P+1.0 * 23 = 10.40", but that makes little sense to me.  The 10.40 is key though.   My calculations say that if you have 20.90 full width, with 5.25 gutter each side, that leaves 10.40 for the connector width (correct). With 14 pads that's then 13 spaces between them (from the center of the first to the center of the last), which is 10.40 / 13 = 0.8mm pitch.

if you have the pinout you should be able to solder the hookup wires directly to the pins if you know how to use solder paste and a heat gun and skill if you are a beginner you need to put it in a box and order something from other suppliers more friendly to newbes.


text:
Arduino Mega2560 clone responding slowly
I am using an Arduino Mega2560. Using Arduino Mega as ISP to burn sketch, I had loaded the bootloader from Arduino IDE.
I uploaded the blink LED code to the Mega. But the LED is responding slowly. Same with Serial code. Delay of 0.1 second acting as 1 second on my board. In code serial communication baud-rate is 9600 but I am getting proper value when I set the baud-rate to 4800 in serial monitor.
Could anyone point out the problem?

If Your Clone is slow. Then Replace it..Clones are very cheap to replace.

Either your fuses are wrong (set to 50% the real speed of your crystal / ceramic resonator), you're using the internal oscillator instead of the expected external one, or you have the wrong board with the wrong F_CPU value selected in the IDE.
Check all of those carefully.

thanks Can you let me know the fuse values, coz i had not change any thing in boot loader. also can you let me know how to choose external or internal oscillator

http://www.avrfreaks.net/forum/fuse-bits-mega2560-arduino


text:
Beginner Arduino Project: Drumming Robot
So, I've got a music degree, 5 years programming with Ruby and 7 with Pure Data. I've also got hold of an Arduino and a Raspberry Pi.
Anyway, I've seen a number of Arduino projects which involve firing events which cause a stick to hit a drum, but I really don't know where to start.
I have a wicker penguin that I want to have play the drums:

What components do I need to produce this kind of one-off percussive event?
Can I trigger these events from Ruby?

Welcome to Arduino SE! I edited your question a bit, removing the request for tutorials. Stack Exchange is a repository of information, not a repository of links. If you have any questions, please feel free to reply to this content. Thanks! (Also, penguins are awesome :-D)

I'm not sure about removing the last sentence, as it explains what the penguin image is for, but it appears I can't edit that part of it with a rep of 101.

Fixed that, apologies.

I think the most challenging part of this project will be coming up with an electro-mechanical mechanism which moves the arms in a good drumming motion, without depending on an expensive, power hungry industrial servomotor and driver.  A sensor-equipped brushless motor off a large RC car might work well, but finding or creating a suitable controller could be a challenge.

On a smaller scale you could try a solenoid and a spring... unless you happen to have one of the huge ones from a mainframe removable-platter hard disk mechanism (I once saw such driving a rocking chair!)   Some combination of a motor, cam, arm with a return spring, and an encoder for position and speed feedback might also work.

The approach I would take for the arms is to use a servo motor as these are fairly cheap and are closed loop so you don't have to add any extra sensors to check where the current position is.
Types of Motors:

Stepper motors are a type of motor with a special arrangement of coils that allows you to turn a fraction of a degree by sending pulses to the motor. For example, you can buy a 200 step stepper motor that turns in increments of 1.8 degrees. These are somewhat expensive and require somewhat expensive drivers (usually $5-10 per driver). Often used in CNC machines and 3D printers. Continuous rotation.
General DC motors (two types: brushless and brushed, but I won't get into that in here) are a type of motor. Their drivers are often cheaper than one for a stepper motor, but you have little control over their rotation (instead of "take one step which is X degrees," you say , "turn at 25% power clockwise," where you don't know the actual speed). These are sometimes used with rotary encoders or potentiometers to control the speed and position of the spindle. Continuous rotation.
Servo motors are actually not their own type of motors; they are DC motors (not steppers) with a potentiometer built in along with the driver. You send pulses to it (you can use the Arduino servo library for this) to tell it the exact degree to go to. Can only go a limited range: usually either 90 or 180 degree, although you can get special ones that can turn much longer ranges than that.

Using a Servo Motor:
You can hook it up like this:

From this Arduino Tutorial

And then some very simple code to use the motor:
#include <Servo.h>

Servo myservo;

void setup() {
  myservo.attach(9);
}

void loop() {
  myservo.write(10);
  delay(500);
  myservo.write(0);
  delay(500);
}

Talking with Ruby:
Your best option is to use the serial port on your computer. Figure out how to access a COM/serial port in Ruby. You can then send messages from your computer to the Arduino, but you'll have to figure out a way to structure the messages.

This may work for limited purposes, but a typical RC servo has a relatively slow transit time which will limit achievable tempo.  I'd also be concerned about damaging the gears unless there is a fair amount of flex in the mechanism - which may be needed also in order to let the stick or mallet spring back enough to avoid deadening the sound.

@ChrisStratton the stick height would have to be pretty small (although that may make it to quiet, although I doubt many people would have an objection to a drummer wicker penguin being quiet). Also, I don't think it's the OP's expectations to have it play thirty-second notes at 150 BPM, but you're right that a more powerful servo will be needed. In addition, the OP might want to have it "grip" the sticks towards the middle so it doesn't have as much pressure as the sticks act as levers.

I really don't think they would get much sound without a whipping action from driving a longer, flexible stick.   I will grant they are faster than I remembered though: say .2 seconds each way, so with care to time the commands just right 120 BPM quarter notes might be achieved.

Thanks, this looks like a really handy primer for motor components. On the Ruby interaction part, does this mean I should create functions in the arduino syntax, upload them to the arduino, then trigger them from Ruby using the serial port?

@ChrisStratton .2 each way would yield eighth notes at 150 clicks (60 seconds per minute / .4 seconds per hit = 150 hits a minute with 2 sticks = approx. 150 BPM eighths)

It may be possible to get it above 120, but I was leaving some allowance for the fact that the device commanding position doesn't know when the previously commanded position has actually been achieved.  It will vary with voltage though, so running the servo at the highest specified voltage may help.  And of course there are faster servos available at a premium.  I do worry about the gear noise.

to move the arms: look for tutorials about arduino controlling a motor (either step od DC).
to control the arduino from a PC (or the PI) - that's what it means when you say Ruby - check how to remote control over serial port

If you want to have a look, I did something similar in python.
Ii emulates a USB keyboard, but you can add more commands to support the control of the motors.
https://github.com/01org-AutomatedFlasherTester/pem

I'm not sure if this is the answer yet, until I can spend a bit of time on it, but it looks like the serial port control is probably going to be the correct approach.


text:
How to measure whether air is flowing through a pipe?
I'm looking for a way to check the air-flow from an aquarium air pump. I need something that can test whether air is flowing or not and I'm not bothered about measuring flow speed. The air will be flowing through a pipe but if required I can have the sensor on the end of an additional pipe just used for measuring.

Did you consider a barometric sensor deployed inside the pipe?
The pressure should be higher when the pump is active.

The issue is that the sensor is very big and the pipe is 1/4"

As it was commented below, you can use various means to make the measurement, either by duplicating the path or by using a mechanical sensor, however there is also a more creative approach.
If you know (you can measure it once) the profile of power consumption of the pump, you can measure it over time and verify that it behaves as it should. This of course is an indirect measurement and implies trust that the system is not leaking air after the pump. But it might be less invasive.

Flow sensors tend to be expensive. However, there are many pressure sensors that provide a simple analog voltage input and others with easy to use digital interfaces.
As Igor Stoppa points out, these can be used to infer flow. Some can be purchased with tube ports that allow the user to mount the hose directly to the sensor. This would only require a "T" connector and some additional hose to connect to the air pump.
Aquarium air pumps may be pulsatile. So be sure to use an average pressure.
Average Pressure:

above a certain point may indicate blockage
between certain values indicates correct flow
below a certain value indicates no flow

.

Grab yourself something like this

Butcher it to get inside it, and add three small magnets to the fins (should be simple enough - just keep it balanced).  Then glue it all back together again.
Add a hall effect sensor to the outside, and Bob's your uncle.
Or, since the principle of that unit is so simple, you could make your own from scratch.

Even simpler: if that thing is transparent, one can add a photodiode/photo transistor pair around it and detect pulses (interrupts) on the transistor.

Good idea :) I hadn't thought of that obvious one.

Love that the linked page header says "enema flow indictors" (sic) - is that in, or.. out?

authors: عبد الر ضا البديري


text:
Failed to read DHT22 sensor using Arduino Uno
why do I end up with the display "Failed to read from DHT sensor!" in the serial monitor in most cases when I run the code given below?? In case I reduce the delay to 1000ms the reading shows 0.00 for both temperature and humidity which, as well, is pretty much false......Any help would be highly appreciated...
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:
//DHT dht(DHTPIN, DHTTYPE, 30);

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(hi);
  Serial.println(" *F");
}

I am having the same problem. would it be possible to share the sketch and library that works for you?

Please provide me the solution for this problem as i am also getting this type of error.. -Thanks

Make sure you define the digital pin number, I didn't and I got that error // Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain #include "DHT.h" #define DHTPIN 12 // what digital pin we're connected to

Have you tried loading the Adafuit_Sensor library before DHT?

what changes occurr if i use LM35 instead of DHT22.
Anyone would help...

If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review

Please share the sketch that you have used and worked. - Tharani

I suggest you to modify the following lines of code to check which reading has issue.
if (isnan(h) || isnan(t) || isnan(f)) {
   Serial.println("Failed to read from DHT sensor!");
   return;
}

Have you put a  4.7kOhm  resistor between data pin and Vcc on the dht22? i had problems with a reading until i did. see this
HTH

Yeah, I have that 4.7k plugged in but it didn't quite work....now I have made it work using a different sketch and library altogether( courtesy Rob Tillaart)....


text:
How to call a file from the arduino?
I am aware of the simplicity of the question.  Nevertheless...
I need to code into the arduino the execution of a file.  More precisely a .exe.
To put things in perspective.  I have little to no knowledge of coding.  Yet I need to put together a photocabin.  I have the arduino to count the coins inserted to my coin collector and I need to take a picture when the precise ammount is reached.  Then reset the ammount to avoid taking more pictures.
here is what my code looks so far: (taken from the examples on the arduino page)
const int coinInt = 0;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.

    volatile float coinsValue = 0.00;
    //Set the coinsValue to a Volatile float
    //Volatile as this variable changes any time the Interrupt is triggered
    int coinsChange = 0;
    //A Coin has been inserted flag

void setup()
{
  Serial.begin(9600);
//Start Serial Communication
  attachInterrupt(coinInt, coinInserted, RISING);
//If coinInt goes HIGH (a Pulse), call the coinInserted function
//An attachInterrupt will always trigger, even if your using delays

}

void coinInserted()

//The function that is called every time it recieves a pulse
{
  coinsValue = coinsValue + 0.05;
//As we set the Pulse to represent 5p or 5c we add this to the coinsValue
  coinsChange = 1;
//Flag that there has been a coin inserted
}

void loop()
{
  if(coinsChange == 1)
//Check if a coin has been Inserted
  {
    coinsChange = 0;
//unflag that a coin has been inserted

   if(coinsValue >= 0.30)
  {
       here goes the code to open a file, then the code to reset coinsValue

  }
  }
}

Thanks a million.

There is no way the Arduino can run a .exe on your PC. At most it can send some kind of signal to say "Hey! PC! It's time to run the program!". Simplest thing would be to send it through the serial port. You need some process on the PC side listening for this signal and acting accordingly. How you do that is more a Windows programming issue than a real Arduino question.

How do you tell apart different type of coins?
What do you use to take the picture?

That was not your original question and is probably best as a question in itself.

@igor I use a coin colector sending out pulse signals to tell different coins apart. from sparkfun.com I will be using either a webcam software or eos utility I have not yet decided.

First of all you need to develop a windows app. You can achieve this by downloading visual studio express for windows desktop from here. Then you must create a project in your language of your preference. You will have to add a serial port component and set the properties to match your arduino serial ones. Then from the event that handles the "data available" of your serial port you can check if there is an incoming character from your arduino and create an if statement that runs the .exe file. Then you must add serial.print('c') to your code when there is a coin inserted. By doing so, you will manage to communicate between arduino and your windows app.
More info and full guide can be found here

Tried the solution and have managed to implement it so thank you.

I used the following code to run a program, not from the arduino, but from software listening to a specific character sent from the arduino.  Thanks for your help.  I share the code that I used.  It doesn´t need to print the character, but I copied it exactlyy from microsoft help pages (lost the link). I just aded the if statement and the start.process part (I got this from a stackoverflow answer).  Without any further delay:
using System;
using System.IO.Ports;
using System.Diagnostics;

class PortDataReceived
{
    public static void Main()
    {
        SerialPort mySerialPort = new SerialPort("COM3");

        mySerialPort.BaudRate = 9600;
        mySerialPort.Parity = Parity.None;
        mySerialPort.StopBits = StopBits.One;
        mySerialPort.DataBits = 8;
        mySerialPort.Handshake = Handshake.None;
        mySerialPort.RtsEnable = true;

        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

        mySerialPort.Open();

        Console.WriteLine("Press any key to continue...");
        Console.WriteLine();
        Console.ReadKey();
        mySerialPort.Close();
    }

    private static void DataReceivedHandler(
                        object sender,
                        SerialDataReceivedEventArgs e)
    {
        SerialPort sp = (SerialPort)sender;
        string indata = sp.ReadExisting();
        Console.WriteLine("Data Received:");
        Console.Write(indata);
        if (indata == "c")
        {
            Process.Start(@"C:\Users\Laptop\Desktop\print.ahk");
        }
    }
}


text:
What is the type parameter on the NRF24NetworkHeader member
Link of the member
What is the character parameter in the above member of the class NRF24Network
I cannot understand the use of it.

It's to identify the type of packet.  Apparently that code supports types of 0-127, and I guess (impossible to tell without digging into the code) that what you use them for is entirely up to you.  Basically it would typically define what is in the rest of the packet - again something which is up to you.

Yes but i have to put a char but it takes types 0-127. What does that mean

Hint: 'a' is 97. '8' is 56.  ASCII.

Oh now I understand. And for example if I want to parse rgb code I will send 3 packets with -for example- type r,g,b ?

Or one packet with 'c' for colour and three values in your packet...

Nice and one last question how can someone parse 3 values in one packet? Can that be achieved by sending 3 variable values or somehow else.

Use a struct and send them as one single compound variable.


text:
Smallest package possible reading microSD
I have a project running on an arduino nano, and as part of it, I'd like to read from and write to a microSD card.  My problem is that the microSD shield for it doesn't fit my form factor (think slightly larger than a pen; definitely handheld).
I've purchased a PJS008-2003-0, and I'm wondering, assuming I have the soldering chops, is there any real reason I can't connect this directly?  What does the breakout board get me other than nicer connection points and a blinking light?  Do the example SD sketches rely on anything the shield provides, or will they work for me?

You could always take the adventurous step of moving away from Arduino and explore the PIC32-o-sphere.  The Fubarino SD would be perfect for you.

Thank you for the suggestion.  I will evaluate it as a possibility.

Running your processor at 3.3v would simplify things.  Also consider if you actually need a microSD card - how much storage do you need?  In the realm of megabytes rather than gigabytes there are spi flashes which are smaller and will cost you less than a card + socket.

I will run at 3.3v.  I did purchase the Fubarino, but I can't find any specs on its size.  I guess I will see if it will work when it gets here. @Majenko, you may want to turn that into an answer, if it isn't too large, I'll go with it.  I haven't heard of spi flash before, but I will look into that if SD doesn't work for me.

@MBurke You can get a better idea of scale with it on a breadboard: http://hackaday.com/2015/05/21/unix-on-your-breadboard/

How about an ATtiny85 in a surface mount package on a little single-layer board with the card socket?  Or even a DIP ATmega with the card off to one end.  There are of course processors which are smaller (and much more powerful) overall, but you won't get much narrower than the surface mount tiny's until you get into the harder to work with leadless packages - the relatively easy to solder TQFP's are going to be wider than a DIP, especially if you have to route them on one or two layers.

SD card need 3.3v for power and logic level. So most breakouts have a buffer chip to convert the logic levels from 5v to 3.3v.
PS, you could use an microSD to SD adapter, and solder some wires to its pads, if you are unable to solder the tiny pins on the part you ordered.

I am planning to run at 3.3v, the nano can run on and output this voltage.  I have also considered the SD adapter, but it is still fairly large, and it looks like its only advantage is convenience.

In that case you can just connect the SD directly to the 3.3v nano. Good luck soldering the SD socket. Shouldn't be a problem if you have some soldering experience. Rather odd 1.1mm pin pitch though. Otherwise you could use an adapter pcb board to make life a bit easier.

If your willing to be adventurous and step away from Arduino (as in AVR chips) and try out some of the myriad of other offerings there are around now, then you may find a better board that fits your needs.
One popular example is the Fubarino SD:

It gives you a PIC32 chip (128KB RAM, 512MB Flash, 80MHz) with a microSD card slot already on the board.  And it measures just 2.5cm x 7cm.
Of course, you may need to tweak your programming a little to get it working as you want - the IDE (MPIDE) is a bit old and the Arduino API compatibility is slightly behind the times (but catching up gradually). It's also fully supported by my UECIDE programming environment.

2.5cm wide?  That's huge.  Even a .3" DIP IC is narrower.  If the uSD card remains that will determine the minimum width at around or slightly over half that, with moderate care on the MCU side resulting in something no wider.

@ChrisStratton They do a smaller one without an SD card and a smaller chip (PIC32MX250). You can't get much thinner and still have an SD card on there...

On the contrary, you can.  This is almost twice as wide as it needs to be, on account of that row of holes along each edge well outside the uSD holder.

Well, you could sacrifice some IO pins (and hence some functionality) if you wanted to dedicate it to just SD, yes, or make it much longer.  Of course, you'd want to switch to a QFN instead of the TQFP to allow the whole board to be narrower - and that narrowness may come at the cost of needing to go 4 layer, which will make the whole thing more costly.  So it's a compromise between cost, size, and functionality. Slightly larger but keep the costs down and keep it as useful as possible.  Or are you just dissing it because it's not AVR?

I'm dismissing it because it is larger than other solutions which would not requires any platform change.  A "boarduino" type device with an uSD socket hanging on the end of it in an area where there are no pins would be around 60% as wide and better fit the asker's pen-like form factor.

So why don't you recommend one to the OP then?  Oh - maybe there isn't one...!  Stop whingeing that this doesn't meet with your utopian ideals when there is nothing better on the market (that I can find at least).  If you can find better then recommend it. If not, then **** off.  And I have pens that fat!

I'm afraid that is bigger than I'm looking for.  I don't think this will work, but I will explore it for other projects.

Most likely you will have to add at least some pullup/pulldown resistor. I would recommend having a look at the schematics of the shield.
For example this shield:
http://freematics.com/store/index.php?route=product/product&product_id=74
And it depends on which mode you want to use (SPI?):
http://en.wikipedia.org/wiki/Secure_Digital#Transfer_modes

Yes, my plan was to use SPI.


text:
DC Motor not behaving reliably
Using an Arduino Mega. I have a motor hooked up exactly like the picture below. Using a BC548B transistor, 1N4001 diode, 220 ohm resistor and a 9V battery. I'm driving the motor in code by using PWM analogWrite to value 255. Weird thing is, if hooked up to USB (5V), the motor will only start to move after a certain amount of time, seems like it needs some initial "drive" to get started. If using the 9V battery it starts up quicker, but still not directly, as I would expect. Also, if I set analogWrite to some value less than 255, it will not move at all - is the transistor limiting? Can I change the resistor value to compensate? Thanks for any advice.
int motorPin = 3;
int interval = 10;
int walkingTime = 7.5;
bool walking = false;

void setup() {
  pinMode(motorPin, OUTPUT);
}

void loop() {
  delay(interval * 1000);
  if (!walking) {
    startWalk();
    delay(walkingTime * 1000);
    stopWalk();
  }
}

void startWalk() {
  walking = true;
  analogWrite(motorPin, 255);
}

void stopWalk() {
  walking = false;
  analogWrite(motorPin, 0);
}

First off, you need to ensure the transistor you use fits with the motor you want to drive; you did not mention any spec data about that motor, so it is not possible to answer your question. Second, a 9V battery is never adequate to drive a motor as it is very limited in energy (measured in mAh). Finally, changing the resistor value will certainly not compensate for anything power-related, 220 Ohm is a rather adequate value for this kind of usage.

I don't think there is any diode with PN2222 reference, it seems you confuse with a transistor reference. Typical diode references are 1N100X (replace X with a digit).

Although I don't think the problem is with your code, it might still be useful to post it also so that we can definitely remove any issue with coding.

Sorry for the confusion, it's a 1N4001 Diode. The motor is packed within a plastic enclosure and I can't read any info on it but will try to use a multimeter to find out how much it draws and report back. Will update the question with the code now.

It won't solve this problem, but you really should get a capacitor in there. The motor may have a high starting current, especially if there's a load on it. Adding a capacitor between Vin and GND on the breadboard will help dampen any large current draws being inflicted upon the board. 220uF, rated at 16V minuum is a good starting point. Better still, if the motor is going to be drawing quite a lot of current you should consider connecting the yellow wire of the motor and the blue wire of from the transistor directly to the + and - of the battery, respectively.

Summary:
Your transistor is the wrong way round.
Rotate it 180 degree (so that collector and emitter are swapped) and it should work.
There are much better transistors available for this job, but this one should work when correctly connected.
Swap, test, report back.
The blue wire goes from emitter (right hand lead) to Arduino ground.

Longer:
The transistor is almost certainly "backwards" as above. More on that below, but first some comment on the actual transistor used and a superior alternative.
While it should work better than you describe, the BC548 is not a very good transistor for motor driving. It's maximum collector current is 100 mA. While you do not state the required motor current, within sensible limits a good guide is that the more a transistor can handle the better it will work, all else being equal. A 500 mA rated part would work better. An excellent pair of small transistor for "playing" are the BC327-40 (PNP) and the complementary BC337-40 (NPN). These have guaranteed current gains (effectively current amplification factor) of 250 and typically of 400. They are typically rated at 45V and 500 mA.
The Fairchild versions data sheet here from Digikey have an absolute maximum 800 mA rating. While the part was originally a European one it is widely available in the US and Asia and is usually about the same price as transistors with substantially inferior specs. eg see Digikey pricing below for BC548B and BC337-40 in 1, 10 and 100 quantity. The BC337 costs 1 cent more per transistor in each case. The BC337 comes in 3 versions with suffixes -16, -25 and -40. This relates to the current gain. The -40 part has an average Beta or current gain of 400. This is better (higher) than most alternatives and costs little or no more than the lower gain -16 and -25 parts.
BC548B datasheet here
BC337-40 datasheet here
BC548B pricing
1 10 100 prices are 22 / 20 / 11 cents each.
BC337-40 pricing
1 10 100 prices are   23 / 21 / 12 cents each.
According to that the pinout is CBE (collector base emitter) left to right looking at flat front with pins down. There are occasionally variations between manufacturers (but should not be) but if the datasheet matches your transistor it is "in backwards".
Swap C & E by rotating 180 degrees and report back.
With C&E swapped it acts like an NPN withj very low current gain.
Note: Presumable where you saay digitalWrite you meant analogWrite?

Will try turning the transistor around later today and report back! And yes, I meant analogWrite instead of digitalWrite.


text:
Merging two codes, one for speaker one for LCD clock (Arduino Uno)
I have two different codes. The first one makes a LCD screen count the time and print it, then when one of the buttons on the LCD shield itself is pressed, it prints the time on the top line that it was pressed. That's the one below, I apologize that it has a lot of notes though it so unless it's in the Arduino program it looks confusing.
/*--------------------------------------------------------------------------    ------------
 Includes
 --------------------------------------------------------------------------------------*/
#include <Wire.h>
#include <LiquidCrystal.h>   // include LCD library
/*--------------------------------------------------------------------------------------
 Defines
 --------------------------------------------------------------------------------------*/
// Pins in use
#define MILLIS_OVERFLOW 34359738
#define BUTTON_ADC_PIN           A0  // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN         3  // D3 controls LCD backlight
// ADC readings expected for the 5 buttons on the ADC input
#define RIGHT_10BIT_ADC           0  // right
#define UP_10BIT_ADC            145  // up
#define DOWN_10BIT_ADC          329  // down
#define LEFT_10BIT_ADC          505  // left
#define SELECT_10BIT_ADC        741  // right
#define BUTTONHYSTERESIS         10  // hysteresis for valid button sensing           window
//return values for ReadButtons()
#define BUTTON_NONE               0  //
#define BUTTON_RIGHT              1  //
#define BUTTON_UP                 2  //
#define BUTTON_DOWN               3  //
#define BUTTON_LEFT               4  //
#define BUTTON_SELECT             5  //
//some example macros with friendly labels for LCD backlight/pin control, tested and can be swapped into the example code as you like
#define LCD_BACKLIGHT_OFF()     digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON()      digitalWrite( LCD_BACKLIGHT_PIN, HIGH )
#define LCD_BACKLIGHT(state)    { if( state ){digitalWrite(     LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }
/*--------------------------------------------------------------------------------------
 Variables
 --------------------------------------------------------------------------------------*/
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds = 0, minutes = 34, hours = 8;

byte buttonJustPressed  = false;         //this will be true after a          ReadButtons() call if triggered
byte buttonJustReleased = false;         //this will be true after a         ReadButtons() call if triggered
    byte buttonWas          = BUTTON_NONE;   //used by ReadButtons() for     detection of button events
        /*--------------------------------------------------------------------------------------
     Init the LCD library with the LCD pins to be used
 --------------------------------------------------------------------------------------*/
       LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );   //Pins for the freetronics 16x2 LCD     shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7 )
/*--------------------------------------------------------------------------------------
     setup()
     Called by the Arduino framework once, before the main loop begins
 --------------------------------------------------------------------------------------*/
    void setup()
    {
  //button adc input
      pinMode( BUTTON_ADC_PIN, INPUT );         //ensure A0 is an input
      digitalWrite( BUTTON_ADC_PIN, LOW );      //ensure pullup is off on A0
  //lcd backlight control
  digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is         high (on)
  pinMode( LCD_BACKLIGHT_PIN, OUTPUT );     //D3 is an output
  //set up the LCD number of columns and rows:
  lcd.begin( 16, 2 );

  //Print some initial text to the LCD.
  Serial.begin(9600);
  lcd.begin( 16, 2 );

}
/*--------------------------------------------------------------------------------------
 loop()
 Arduino main loop
 --------------------------------------------------------------------------------------*/
void loop()
{
  setClock();
  byte button;

  button = ReadButtons();

  /**
   * After set clock now you have 3 int variables with the current time
   */
  //seconds
  //minutes
  //hours
  lcd.setCursor ( 0, 1);
  lcd.print(hours);
  lcd.print(":");
  lcd.print(minutes);
  lcd.print(":");
  lcd.print(seconds);
  lcd.print(":");
  lcd.print(elapsedMillis);

      //get the latest button pressed, also the buttonJustPressed,     buttonJustReleased flags

  //blank the demo text line if a new button is pressed or released, ready for a new label to be written

  //show text label for the button pressed
   if(buttonJustPressed || buttonJustReleased)
  switch( button )
  {

  case BUTTON_LEFT:
    {
      lcd.setCursor( 0, 0 );
               lcd.print(hours);
               lcd.print(":");
               lcd.print(minutes);
               lcd.print(":");
               lcd.print(seconds);
               lcd.print(":");
               lcd.print(elapsedMillis);

      break;

    }
  default:
    {
      break;
    }
  }

  if( buttonJustPressed )
    buttonJustPressed = false;
  if( buttonJustReleased )
    buttonJustReleased = false;
}
     /*--------------------------------------------------------------------------------------
     ReadButtons()
     Detect the button pressed and return the value
     Uses global values buttonWas, buttonJustPressed, buttonJustReleased.
 --------------------------------------------------------------------------------------*/
        byte ReadButtons()
    {
  unsigned int buttonVoltage;
  byte button = BUTTON_NONE;   // return no button pressed if the below         checks don't write to btn

  //read the button ADC pin voltage
  buttonVoltage = analogRead( BUTTON_ADC_PIN );
  //sense if the voltage falls within valid voltage windows
  if( buttonVoltage < ( RIGHT_10BIT_ADC + BUTTONHYSTERESIS ) )
  {
    button = BUTTON_RIGHT;
  }
  else if(   buttonVoltage >= ( UP_10BIT_ADC - BUTTONHYSTERESIS )
    && buttonVoltage <= ( UP_10BIT_ADC + BUTTONHYSTERESIS ) )
  {
    button = BUTTON_UP;
  }
  else if(   buttonVoltage >= ( DOWN_10BIT_ADC - BUTTONHYSTERESIS )
    && buttonVoltage <= ( DOWN_10BIT_ADC + BUTTONHYSTERESIS ) )
  {
    button = BUTTON_DOWN;
  }
  else if(   buttonVoltage >= ( LEFT_10BIT_ADC - BUTTONHYSTERESIS )
    && buttonVoltage <= ( LEFT_10BIT_ADC + BUTTONHYSTERESIS ) )
  {
    button = BUTTON_LEFT;
  }
  else if(   buttonVoltage >= ( SELECT_10BIT_ADC - BUTTONHYSTERESIS )
    && buttonVoltage <= ( SELECT_10BIT_ADC + BUTTONHYSTERESIS ) )
  {
    button = BUTTON_SELECT;
  }
  //handle button flags for just pressed and just released events
  if( ( buttonWas == BUTTON_NONE ) && ( button != BUTTON_NONE ) )
  {
    //the button was just pressed, set buttonJustPressed, this can optionally be used to trigger a once-off action for a button press event
//it's the duty of the receiver to clear these flags if it wants to detect a new button change event
    buttonJustPressed  = true;
    buttonJustReleased = false;
  }
  if( ( buttonWas != BUTTON_NONE ) && ( button == BUTTON_NONE ) )
  {
    buttonJustPressed  = false;
    buttonJustReleased = true;
  }

  //save the latest button value, for change event detection next time round
  buttonWas = button;

  return( button );
}
void setClock()
{
  currentMillis = millis();
      /**
   * The only moment when currentMillis will be smaller than previousMillis
   * will be when millis() oveflows
   */
  if (currentMillis < previousMillis){
    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;
  }
  else {
    elapsedMillis += currentMillis - previousMillis;
  }

  /**
   * If we use equals 1000 its possible that because of the mentioned loop     limitation
   * you check the difference when its value is (999) and on the next loop its value is (1001)
   */
  if (elapsedMillis > 999){
    seconds++;
    elapsedMillis = elapsedMillis - 1000;
  }

  if (seconds == 60){
    minutes++;
    seconds = 0;
  }
  if (minutes == 60){
    hours++;
    minutes = 0;
  }
  if (hours == 24){
    hours = 0;
  }

  previousMillis = currentMillis;
    }

The next code is to control the speaker and makes it play happy birthday when the a proximity sensor is set off. I need to somehow merge the two codes so that when the proximity sensor is set off the speaker plays the sound, but so that the clock continues to still count. Does anyone know how I can do this?
#include <Wire.h>
#include <LiquidCrystal.h>

int timer = 1000;
int C = 262;
int D = 294;
int E = 330;
int F = 349;
int G = 392;
int A = 440;
int B = 494;
int Bflat = 466;
int Chigh = 523;

LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
const int analogPin = A1;    // pin that the sensor is attached to
const int threshold = 400;

void setup()
{
     // initialize serial communications at 9600 bps:
     Serial.begin(9600);
     pinMode(10, OUTPUT); // Red LED
     pinMode(12, OUTPUT); // Yellow LED
     pinMode(11, OUTPUT); // Green LED
     pinMode(13, OUTPUT); // Speaker
         lcd.begin(16, 2);
 }
void loop()
{
 int analogValue = analogRead(analogPin);

  if (analogValue > threshold) {

tone(13,C,timer/2);// Happy Bday to You
delay(200);
tone(13,C,timer/2);
delay(200);
tone(13,D,timer/2);
delay(400);
tone(13,C,timer/2);
delay(400);
tone(13,F,timer/2);
delay(400);
tone(13,E,timer);
delay(750);

 }
else {
}
}

Step one is to do away with all those horrible delay() calls

Just change if (elapsedMillis > 999){ to while (elapsedMillis > 999){ and add the loop code of the music to the loop code of the lcd. The only downside is that the display will not update while the melody is playing. But it will update after the 5 tones are played. But it won't miss any seconds.


text:
Arduino ligths on/off clapping hands
I'm new to Arduino and I'd like to realize a system using Arduino One and SparkFun Electret Microphone Breakout (BOB-09964) to turn on/off lights clapping my hands. https://www.sparkfun.com/products/9964
What are the components I need? I'm going to buy them and I don't want to buy components which I will not use soon (so no starter kits but only a breadboard, resistors, LEDs, etc...).
Sorry for this basic question but as I said I'm new to this world.

If you start from the beginning of the project, instead of trying to jump in half way through, you'll know precisely what components you need.
Your first step shouldn't be trying to order components, but to identify (through research) how the technology works.
Second is to find out how it can be implemented, by looking at existing schematics and designs that other people have created.
Third is to design your own schematic.
Fourth is to prototype it.  It's only at this stage that you should be thinking about what components to order.
Go back to stage one and do the research. Thanks to the likes of Google it'll probably only take you a few minutes.

See the Arduino tutorial for a Sound Sensor Example.
This is a very similar project that shows the breadboard layout and code needed for a clapping sensor based on an electret microphone breakout board.
The website listed above has a list of parts needed, the circuit diagram as well as the code needed.

I was able to get this project working. I built just the sound sensor side, and used the onboard LED instead of building an LED circuit. At first I had problems getting a clear analog signal, due to poor connections to the microphone breakout board. After soldering the header pins to the breakout board the connection was good and the system worked.


text:
TX light not flashing, screen.print works sometimes.. UNO
I've got 2 Analog accelerometers and a Gyro/Acc/Mag connected to my arduino and it's been working and reading fine until a few hours ago.
I've got the arduino sending data over the serial connection and Unity reading the values and interpreting.
#include <Wire.h>
#include <LSM303.h>
#include <L3G.h>

LSM303 compass;
L3G gyro;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
  gyro.init();
  gyro.enableDefault();
}

void loop() {

  /* Accelerometers: */

  int sensorValueA = analogRead(A0);
  int sensorValueB = analogRead(A1);
  //Serial.flush();
  Serial.print(sensorValueA);
  Serial.print(",");
  Serial.println(sensorValueB);
  delay(10);

  /* Accelerometer + Magnometer: */

  compass.read();
  //Serial.flush();
  Serial.print(compass.a.x);
  Serial.print(",");
  Serial.print(compass.a.y);
  Serial.print(",");
  Serial.print(compass.a.z);
  Serial.print(",");
  Serial.print(compass.m.x);
  Serial.print(",");
  Serial.print(compass.m.y);
  Serial.print(",");
  Serial.println(compass.m.z);
  delay(10);

  /* Gyro: */

  gyro.read();
  //Serial.flush();
  Serial.print((int)gyro.g.x);
  Serial.print(",");
  Serial.print((int)gyro.g.y);
  Serial.print(",");
  Serial.println((int)gyro.g.z);
  delay(10);

}

If I have it unplugged for several minutes then replug it, the print will work for a min or two then just stop completely. I've checked wires several times and it hasn't moved since it was working this morning.
As I said, which I think is probably of importance, the TX light is off when not printing.

Acc1: GND - GND | VCC - 3.3v | Y - A2
Acc2: GND - GND | VCC - 3.3v | Y - A3
Gyro: VIN - 5v | GND - GND | SAO - A4 | SCL - A5
Thanks

My guess is your I2C communications are locking up.  We'd need to see your setup though (schematic, pictures, etc) to be able to help further though.

Are you able to reproduce the problem with only 1 sensor attached?
If you can, that makes debugging much simpler.

Include a counter variable that increments once per pass of loop(). Dump the value before you start all the printing commands, then see if the lockup is happening after a similar running time. I've had this happen before with a straightforward "breathing LED" sketch: my cheap Chinese Uno was fine but my genuine version would hang after 90-120 seconds. Never got to the bottom of it!


text:
DHT22 Does not update
Good evening :)
I am fairily new to coding the fabulous Arduino UNO. My project right now are consisting of reading Temperature from a DHT22 (AM2302) and writing to a 4-digit 7-segment display. I have got the display to work, but the system does not update the temperature at all. Just the first reading are displayed
#include <DHT.h>
  #include <TimerOne.h>
  #include <SevenSeg.h>

  #define DHTPIN 4    //Defines the temp-pin

  /* DHT22- Pin1 (left) - 5V/3.3V
  Pin2- DATA
    Connect a 10K res from pin1 to pin2
  Pin3 - NC
  Pin4 - GND
  */

  //#define DHTTYPE DHT11   // DHT 11
  #define DHTTYPE DHT22   // DHT 22  (AM2302)
  //#define DHTTYPE DHT21   // DHT 21 (AM2301)

  DHT dht(DHTPIN, DHTTYPE);

  SevenSeg disp (13 ,2 ,3 ,8 ,5 ,6 ,7);
  //            (11, 7, 4, 2, 1, 10, 5)
  const int numOfDigits =4;
  int digitPins [ numOfDigits ]={9,10,11,12};  // uten transistorer
  //                            (12,9,8,6) Alle med 220 Ohm seriemotstand
  //int digitPins [ numOfDigits ]={12,11,10,9};  // med transistorer

  void setup ()
  {
    Serial.begin(9600);
    Serial.println("DHT22");

    disp . setCommonCathode();  // uten transistorer
    //disp . setActivePinState(HIGH,HIGH);  // med transistoere
    disp . setDigitPins ( numOfDigits , digitPins );

    Timer1.initialize(15);   // 0.015 sek
    Timer1.attachInterrupt(loop);
  }

  void loop() {

    dht.begin();

    delay(300);
    float t = dht.readTemperature();

    disp.writeFloat(t);
    Serial.println(t);

  }

How do I get the Sensor to update regularly?

Try moving dht.begin(); to setup().
The DHTs are pretty slow and need some time (of the order of seconds!) between consecutive reads. In dht.begin() an internal timer is reset that is used in readTemperature() to ensure that reading data from the DHT is not attempted in shorter intervals than supported. By calling dht.begin() every 300 ms you're making this meachanism inoperative. You're supposed to call dht.begin() only once at start-up.
Edit: And please also remove the Timer1 that calls loop. loop is already an infinite loop, so no good in calling it additionally from an interrupt...

Yaay, It worked!! And makes completely sense :D Thanks :D

Try this in your loop method
The while loop will read the temperature, write to the display and write to the console.
void loop() {
  dht.begin();
  float t;
  while(1)
  {
    t = dht.readTemperature();
    disp.writeFloat(t);
    Serial.println(t);
  }
  delay(300);

}

Thanks for a quick answer :D Buuut it did not do any difference

Do you get anything on the console?

@Gerben , I did get the first reading repeated over and over again


text:
Hall sensor noise removal
I am using Arduino Duemilanove and a hall effect sensor to calculate the speed of a motor.  When I used sensor out directly to Interrupt0, the rising edges of noise were also detected. So the speed calculation went wrong.
So now  sensor is connected to A0.and a threshold is put. Pin No 13 is connected to Interrupt 0(Pin 2). I use the following code.
volatile byte count;
 const int analogPin = A0;
 const int digitalPin=13;
 const int threshold =20;
 unsigned int rpm;
 unsigned long starttime;

 void setup()
 {
   pinMode(digitalPin,OUTPUT);
   digitalWrite(analogPin,HIGH);
   digitalWrite(digitalPin,HIGH);
   Serial.begin(9600);
   attachInterrupt(0,sense,FALLING);
   rpm=0;
   starttime=0;
   count=0;
 }
 void loop()
 {
   int sensorValue = analogRead(analogPin);
   Serial.println(sensorValue);
   if (sensorValue < threshold)
   {
     digitalWrite(digitalPin,LOW);
     if (count>=20)
     {
       rpm=60*1000*count/(millis()-starttime);
       starttime=millis();
       count=0;
       Serial.println(rpm,DEC);
     }
   }
   else
   {
     digitalWrite(digitalPin,HIGH);
   }

 }
 void sense()
 {
  count++;
 }

But I get actual speed only in between. The speed changes back . I feel there is some problem with the sampling or rpm updation. Looking forward for help

You could try adding an RC filter to filter out the noise, before feeding it into the INT0 pin.

I don't see the point of using attachInterrupt here since this is your code that artificially triggers interrupts by writing to digitalPin. Hence I think your sense function is not called as many times as you would expect. Also, where does the value 20 for threshold come from?

It sounds like you need a debouncing circuit.
You can do it in code, but you are then trying to execute more code in you interrupt handler.
I would go for a hardware version.  I don't have the circuit to hand but if you search for a 'Schmidtt Trigger' based debouncing circuit.  You can implement it with 5 resistors, a capacitor, a LM386 OpAmp and a CMOS XOR IC (Inverts the signal which the inverting Schmidtt trigger inverts).
What happens is the Schmidtt trigger goes low when the input passes a certain voltage.  It remains low until the voltage passes the low voltage threshold at which point it goes high.  The CMOS XOR IC (I think its a 4004??) takes two inputs and inverts them.  It also adds extra hysteresis which further damps the bouncing.
The values of your resistors affect the thresholds, but there are plenty of calculators on the web that will solve the values for you.
The LM386 has two channels and the CMOS usually has 4 so it becomes quite easy to debounce multiple signals.
Hope that helps.

       rpm=60*1000*count/(millis()-starttime);

Since rpm is an unsigned int (which has a maximum of 65535) you will almost certainly overflow if count is more than 1, which will give you negative numbers, or incorrect positive numbers.
Plus, outputting to serial constantly will cause the program to lock up waiting for the serial buffer to empty, which will throw out any timings you are doing.
I suggest making rpm unsigned long (or float as you seem to have done already) and only display the RPM every second or so.

Also see my page Using the Arduino Analog Comparator. This is a much faster way of detecting an analog signal merely passing some threshold. This only takes a few microseconds compared to 104 µS for a single analogRead. In the ISR then you just add one to a counter (which is the number of times it passes the threshold). Every second take this counter, and work out the RPM, then zero it. Make sure you make a copy of the counter in a protected way as shown on my page about Interrupts.

A possibility I am toying with for a similar problem is realizing that there will always be a delay between valid sensor readings.  For example, imagine you had a maximum speed of 10 revolutions/second.  That would mean that there would be a maximum of 10 sensor inputs/second or 1 interrupt every 100 msecs.
If you changed your interrupt processing logic to something like:
if (millis() - timeOfLastSensorReading >= 10) {
   count++;
   timeOfLastSensorReading = millis();
}

Then your logic would become "Only register a sensor change if at least 10 msecs has passed since the last reading".
You might have to tune the values based on your real situation ... but it might go a long way to eliminate some aspects of false readings.


text:
Incremental encoder code
can somebody tell me what`s wrong with my code, i am using it to calculate rpm using incremental encoder
long counter=0;
 long  rpm = 0, z =0;
 long  ini_time = 0;
long  end_time=0;

void setup(){
  attachInterrupt(0, A_RISE, RISING);

  Serial.begin(115200);
}//setup

void loop(){

    Serial.println(rpm);
}

void A_RISE(){
  counter ++;
  if (counter == 1)
    ini_time = micros();
  else if (counter>470){ //470 is ticks per revolution
    z = counter;
    rpm_counter(z);

    counter =0;
  }
}

void rpm_counter(int x){

  end_time=micros()-ini_time;
  rpm=(60*10^6)/end_time;

}

You need to tell us more about: what currently happens with your program, what you would expect instead.

it does not give any output in serial monitor @jfpoilpret

Can you clarify your wiring: which Arduino pin did you wire your encoder to?

i attached encoder`s channel A to digital Pin 2 on arduino which is interrupt 0.

What is weird is that you mention there is NO output on the serial monitor, which would mean thzn loop() is not even called? I suspect, your motor runs very fast and may generate too many interrupts which would prevent loop() from running.. Could you first try to add a delay in your loop (1 second would be fair) and see what happens?

Also, you could chnage the init order in your setup() to first Serial.begin(...), that would give time for serial init before triggering encoder interrupts.

Volatile.
Essentially any variable declared within global scope (anything you declare before you get to setup()) MUST have the volatile qualifier if you want to use it within an interrupt service routine otherwise it will not be correctly utilised/implemented/instantiated.
As your code stands, you need to add voltatile to all four of your global variables:
volatile int counter = 0;     // if you're stopping at 470, int is all you need
volatile long rpm = 0;
volatile long z = 0;          // this isn't necessary, see below!
volatile long ini_time = 0;
voltaile long end_time = 0;

Your ISR includes some wasteful instructions, which will increase the time it takes for the routine to complete. As @jfpoilpret suggested, you may be constantly interrupting loop(). Cutting the time down may solve this:
Firstly, z = counter; rpm_counter(z); . Pointless, if I'm honest. Why not just call rpm_counter with counter?
Secondly, rpm_counter() function... it doesn't use the arguement you sent! "x" is not used anywhere within the function, so why are you sending it?
Thirdly, even if my second point wasn't valid rpm_counter() doesn't really need to be a function in its own right. Unless you're going to be calling it from lots of different places, just inline the contents of the function to into A_RISE():
else if (counter>470)
{ //470 is ticks per revolution
    end_time = micros() - ini_time;
    rpm = (60*10^6) / end_time;
    counter = 0;
}

That could save a great deal of execute cycles.

“any variable declared within global scope [...] MUST have the volatile qualifier if you want to use it within an interrupt service routine”. This is incorrect. The volatile qualifier is needed if the variable is going to be used both in the ISR and in the main program. OTOH, if the variable is only used inside the ISR, it should be static local rather than global.

Could this be what's wrong with the code in my question here: https://arduino.stackexchange.com/questions/88812/variable-getting-set-to-zero-nondeterministically?noredirect=1#comment202751_88812


text:
Cheapest Arduino GPRS or 3G solution
I am looking at creating a fleet of low power, Arduino driven devices.
I would need some kind of GPS on them all (or could triangulate through phone network?) plus a connection to the internet - just for HTTP POST requests. GPRS or GSM would do but 3G would be better.
What are the best (price is a major factor because I'm trying to do a fleet) GSM, GPRS or 3G modules that I can use with Arduinos? As I said, I need their location so one with GPS built in would be great.
EDIT:
The amount of devices in the fleet will change, so the entire network needs to be dynamic which is why having a GPRS/GSM module on each one would work so well.

I've seen people start with a cheap smartphone.

@Gerben any recommendations?

From what I remember it was an FirefoxOS phone. I think Alcatel One Touch Fire or something. I'm unable to find the related article.

So you need position awereness?
Does this count for the complete fleet, or every single arduino in the fleet?
What accuracy are you looking for? 100m, 10m, 1m, 10cm?
What do you want to achieve with the POST requests? They shouldn't be used for the communications between arduino (I believe).
GSM-modules aren't that "low-power" when connecting to the network (around 2A peaks are possible) though yea, they won't draw 2A all the time.

@FuaZe Each arduino. <= 1m would be great. The POST requests are just for updating a web server.

"From numerous tests the typical GPS receiver will achieve an accuracy of 1-5 meters." This is tested on Iphone 3's actually according to this:  http://communityhealthmaps.nlm.nih.gov/2014/07/07/how-accurate-is-the-gps-on-my-smart-phone-part-2/
If you want to use the GPS to avoid the fleet clashing into eachother, you should use other sensors.
But how do you want to achieve communication between the arduino's then?

@FuaZe I'm not planning on using it to avoid collisions, just for seeing their location.

You could consider making one of the arduino's the "fleet leader", this way only one arduino needs to have GSM/GPS

Ah good idea but the thing I forgot to mention is that they amount of devices in the fleet will change which is why it needs to be dynamic.

Not many possibilities (for the phone part, I suggest a GPRS/3G shield), but not wanting to discourage you, if you are thinking about "a fleet", forget about:
low power (the phone radio needs power, some say you need > 1A for both Arduino plus the shield, depending on your distance to the antenna). you must add the GPS part. Even if you communicate just a fraction of the time, you need instant power for feeding the radio.
low price (gprs shields are not cheap, starting at some 25€, and gps shields about 20€). and don't forget that you need a SIM card with a data plan for every unit....

Depending on what are you trying to achieve, I'd try with less expensive (RF communications, for example) to avoid carrier costs and hardware costs, at the price of a more complex development. If you want to publish to a web service, you can always make your minions transmit to a centralized Raspberry PI, for example, that would take the task of bridging with the Internets, or your mastermind...:-D

Can you give me a link to one for 25€? I started with thinking about a RF network with a Pi as the gateway but it'd need meshing and RF isn't cheap either.

look for "gprs shield arduino" at ebay or aliexpress. They can be used with the RPis without problems, as they work with the MCU or RPi via serial port using AT Commands.

would this be ok? http://www.ebay.co.uk/itm/SIM900-GPRS-GSM-Shield-Development-Board-Module-For-Arduino-High-Quality-/271621338401?pt=LH_DefaultDomain_3&hash=item3f3de4b521

According to the product description, yes. You just need to power it with an appropriate power source (I suggest a 2A one) and link it with your RPi via a serial connection. Look for "SIM900 AT Command reference"

2A?! It has a big orange capacitor on for that (or so it says)?

You might be best off with a phone battery of some sort. GSM modules require immediate and big power spikes. A big ass capacitor is often a good choice (or even multiple) as they can respond to the power need very fast. Keep wires/traces short and low resistant.

Though esp8266's can cost ~35$ for 10pcs, which would be the price of one GSM module. You're going to have to do some tradeoffs though.

If you are finding Cheapest and working module you can you SIM800L less then 4$.

aliexpress.com/item/Free-Shipping-Smallest-SIM800L-GPRS-GSM-Module-MicroSIM-Card-Core-BOard-Quad-band-TTL-Serial-Port/32708504554.html

You can find many other cheap alternative but they does not work properly.
Sim800 have good support and you can find many examples to use this with arduino.
Many other model also available in market as per your requirements.

BUT you need to supply it with at least 2Amps.

a few new ones have hit the scene recently. There's one by the folks that made the particle board (the electron supports 2G and 3G). There is also a kickstarter by sixfab that made one for the pi-zero footprint (but it's a standard raspberry pi GPIO and also has USB connection support or you can bread-board it to an arduino). They make a more expensive plate on standard RPi footprint that supports laptop-style WWAN modules (bought separately) so it can do 3G or 4G/LTE.
One of the better one's I've seen recently is actually part of the AT&T offerings (I believe avtel is the one that put the packages together for them). If you google AT&T IoT starter kit, they have four different offerings, with the lowest being $59. (it's apparently used as just a modem and can be connected via gpio style pins or via usb) It comes with a sim with 300Mb and 300 SMS messages good for up to 6 months from date of activation.
There are a few higher end chips coming out with LTE and 4G support also from Simcom (the makers of the Sim900 based devices core chip). Boards I have seen built on their LTE based devices run in the $80-120 range so, unfortunately they don't qualify as cheap.
As of yet, I haven't seen anything with 3G or higher under the $40 mark though. Most of them start above $50 and go up. Maybe by the time 2G is completely phased out, LoRa will be well saturated?

Welcome to Arduino Stack Exchange.  Be sure to take the tour at https://arduino.stackexchange.com

May I suggest reformatting this a bit?  Use the edit button and break up the concepts into separate paragraphs.  It is hard to read so much all at once.  TNX.


text:
Connecting GSM Dongle to Intel Galileo-Gen 2
I have tried to connect a GSM dongle to a Intel Galileo Gen2 board and test the functionality of sending and receiving SMS through it.I know that it is easier to use a GSM shield to do above, but I'm currently doing a project in the way i mentioned above.Basically in Linux, we should know the serial port(like ttyACM0 in /dev directory) correspond to the device to communicate with it(Using AT commands).
but when i tried it in Galileo board it doesn't show such a serial port.but it detect device because lsusb command shows the device.
does anyone can help me to solve this matter?

It may detect it as a USB device, but does it know what it is? Check dmesg when you plug it in, and also run usb-devices to see if it has a driver attached.

Many of these have to be kicked out of their initial mode of emulating a CD rom with windows drivers into a different mode which exposes USB-serial like devices.  There's a program called usbmodeswitch which sends the necessary SCSI commands.  This is probably off topic for the arduino site.

Try updating the firmware. I'm not sure if this affects also ACM type serial ports, but the initial version of the firmware was not even creating standard /dev/ttySx, rather some weird proprietary interface.
Luckily this was fixed later on. So, in case you are still running the FW that the board came with, chances are you are having these weird serial ports.

In case my previous observation doesn't help, check the udev rules. It might simply miss the one for creating the appropriate type of character device.


text:
Transferring OV7670 data with SPI port
I bought an OV7670 camera and I would like to use the following code:
https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno
But I wonder whether it is possible to use SPI instead of I2C when I transfer the image data through Arduino to other breakout boards.

I2C is not used to get the pixel data. That is used only to configure the ov7670. You can read the pixel data by reading the IO PORTS and then send the data via SPI.


text:
Arduino resets when I call network.begin()
I have included the RF24Network library in my project. I tried to use the Simple Transmit/Receive example from here but when it calls the network.begin() my arduino restarts. I placed some Serial.println() in order to understand where is the problem. This problem appears only in my Arduino Mega 1280. I tried the same code on my Arduino Pro mini and it works like a charm. What causes this? How to fix that? It is very important to use the specific library. Thanks in advance.

tmrh20.github.io/RF24 is the new and updated library that should fix the problem.

The problem was that the RF24Network library is not compatible with the version of Arduino IDE I have. I downloaded Arduino IDE v1.0 and now it works like a charm. I will send an email to maniacbug to tell him about the problem.

tmrh20.github.io/RF24 is the updated fork.


text:
Arduino 1.6.4 not showing any /tty/ options in Serial ports
hej guys,
recently I upgraded to Arduino's 1.6.4 IDE just to find out, that I can't seem to upload anything to my board. More specifically: The 1.6.4 IDE is not giving me the option to select the /tty/ board from the serial port list. I am avid Sublime Text 2 user, so obviously I tried to select the port in Stino and voilá: I was able to upload it to my boards.
Since I wanted to sort out if this is a software or hardware problem, I started to experiment with all my boards:
(all of them official boards, no clones)

2 x Arduino Micro
1 x Arduino Uno r3
1 x Arduino Duemillanove
1 x Arduino Mega 2560 r3
12 x Teensy 3.1
a bunch of different USB cables.

none of these boards were registered by the Arduino 1.6.4 IDE, even after restarting the software and the computer several times. i'd only get this in my port selection:

funny enough, my terminal told me the /tty/ device was there. here with the uno connected:
Dash:~ julianh$    ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem
/dev/tty.usbmodemfa131

I also tried to re-install FTDI drivers, with no results.
only when I installed the old (trusty) 1.6.1 version, I was able to upload again.
all of the boards are also working fine. I just used my uno and mega another machine a few days ago for some side projects.
can someone confirm this problem with the new IDE 1.6.4 on OSX Yosemite 10.10.3? or is there any solution available online?
thanks!

What exactly happened when you tried to upload with the cu.* device?

I had the same problem when updated to 1.6.4, but with a Spark fun Pro micro.
Did a "reset to bootloader" on the pro micro, and hit upload, and it worked
 out nice and it still does!


text:
Arduino UNO/ZERO PRO, enough computing power for PID-controller?
I am currently working on a project, where I design a PID-Controller for a 2-axis stabilization with brushless-propeller-motors.
My question is: Does an Arduino UNO have enough computing power to perform this task in a useful manner? Arduino UNO Specs
And secondly: If the UNO was really too slow for this task, would the newly released Arduino ZERO PRO perform at an acceptable rate? Arduino ZERO PRO Specs
Thanks for your help and inputs in advance!

what bandwidth do you require?  that's the real question. Can you complete the accumulation tasks before your next sample is due to satisfy your system bandwidth

JonRB is exactly right! And don't forget about any processing which needs to be done on the sensor inputs before getting to the PIDs. Also note: on the UNO a floating-point PID implementation will be much slower than a 'long' PID implementation.

PID is a relatively simple algorithm. You probably only need something like 50 updates per second at the most (wild guess). So my guess, on the limited amount of info given, is that the uno will do fine.

@Jay J floating point math is not that much slower than fixed on the UNO. In my experience the time savings (if any) have not been worth the extra work to do fixed point safely.

Assuming you're not doing anything too fancy, yes, it should be fine.
There's even a library to do all the work for you: http://playground.arduino.cc/Code/PIDLibrary

Also look for the ospid project which is a full hardware/software arduino based pid