text:
How to: soil moisture measurement with WaterMark?
I am new with Arduino, and i cant find documentation about how to connect Arduino with Watermark successfully.
I would like to connect my Arduino UNO with a watermark like this:
http://guideimg.alibaba.com/images/shop/72/08/19/4/watermark-soil-moisture-sensor-w-15-cable_3234944.jpg
Does anyone know any schema or documentation about how to do it? Have anyone tried it before?
I have found this: https://oceancontrols.com.au/datasheet/davis/ECS-014_07395-158_IM_06440_6470.pdf
but still not clear how to do it in Arduino.
Thanks you for your time.

The link to the PDF is not found, and the only other thing provided is a JPG image of the sensor, which is not helpful.

You can google
"Arduino-based system for soil moisture measurement"
and the author about this paper is "Vuk Radman" .

Now, I am also try to find the method using Arduino to connect WaterMark 200ss Sensor. The paper I share to you is what I have found from GoogleScholar, but I haven't used this method yet. Nevertheless, I think the method mentioned in the paper is feasible. Hopefully, this information can help you.


text:
Question about infrared receiver with metal shell to detect heart pulse rate?
I'm newbie to the world of arduino and environmental sensing. I have been searching for a while about how can I measure the heart pulse rate, I came through the following tutorial:
Click Here
I have the following Arduino IR Receiver with metal shell module that I want to use as the previous tutorial suggesting, but, the IR receiver used in the tutorial has no metal shell, so, my question is if they are both functioning the same way?
Can I position my IR Receiver exactly as the one in the tutorial or do I need some workaround to reach my goal based on the fact that it has a metal shell?
Thanks in advance.

"Proper" oxygen meters use a bimodal LED - red + IR - so there will be limitations to this. They also have a piece of copper foil wrapped around the sensor & heavily earthed, so your shielded sensor has, already, an advantage!
You should be able to use your receiver exactly the same way. If you can ground the shield, do so.

source: Stack Exchange

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

sort: votes


text:
Why is the atmega chip reset three times during programming?
I'm trying to understand the auto reset process and why a capacitor hooked up between DTR and Reset works so I ran it through my logic analyzer and I'm seeing the chip reset three times during the programming process. Does anyone know why it's done three times and not just once?
You can see in the picture the top pin is the DTR and the bottom two are attached to reset (digital/analog). When DTR drops low the reset pin does too for between 200-500us but it does it three times in around 1 second.

How are you programming it?

Using the Arduino IDE and and FTDI cable.

It does it to "force" a reset.
Historically, when you open the serial port on an FTDI interface, the DTR will automatically go LOW.  However, recently FTDI decided it'd be a good idea to change their driver so that when you open the port the DTR line doesn't go low - you have to manually tell it to go low.  But this is only on the FTDI official drivers.
If you have a driver that is newer than a certain date (no idea what date) then just running avrdude by itself on an FTDI interface may not work properly since DTR isn't being lowered.
To get around that Arduino have included a forced toggling of the DTR line as part of the programming sequence to make the target board reset.
But of course, if the driver is old enough, or not the "official" FTDI driver (i.e., you're in Linux for instance) then the lowering of the DTR by avrdude works fine.
So what you are seeing there is first a brief toggle of DTR by the IDE to force a reset, then avrdude opening the port and DTR going low, then finally the IDE toggling DTR again one last time to force a final reset.
And to me that says you're either not in Windows, or you have an FTDI driver while does toggle the DTR line automatically.
I also have a feeling that avrdude may also have started including manual control of the DTR line within it - so if avrdude is new enough, even with a new FTDI driver that doesn't automatically, you will still see the repeated action of DTR.
It's what we call belt and braces.  Use every method possible to get the board to reset, so no matter what you hardware and software arrangement the board has a very good chance of being reset into the bootloader.

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


text:
Pro Mini 3.3v + Neopixel not working when disconnected from USB
I'm doing a project using an Arduino pro mini 3.3v and Adafruit's Neopixel.
I've flashed an example (strand example) from the Adafruit Neopixel's library sketch into the Arduino using the FTDI Basic Breakout 3.3v and everything went fine.
But when I disconnected the FTDI Basic Breakout from my laptop, the LEDs stop working. They light up with some different color and the animation stops.
I tried with other example sketches and everything seemed to work fine. I never experienced anything like this and I had no success searching for this issues in forums or google.
What might be the problem and how can I solve it?
Thanks!

How are you powering the board and the LEDs?

I've tried two solutions, both gave same results.
5v to the strip and to the Arduino on its regulated RAW pin.
3.6v (with three 1.2 NiMh batteries) to the strip and to the Arduino RAW pin.


text:
Port manipulation using C code
I'm trying to manipulate the ports of Arduino using C code. I have attached an LED to pin 8 and a tact switch to pin 13 (with a pull down resistor). The code works fine, and the results are printed on the screen. So, when the button is pressed, the byte PINB & (1 << PB5) equals 32, or 0b00100000.
However, if I try to use
if( PINB &(1<<PB5) == 32){

or
if( PINB &(1<<PB5) == 0b00100000){

the LED doesn't respond.
Here's the full code:
void setup() {
  DDRB |= 0b00011111;
  Serial.begin(9600);
  }

void loop() {
  Serial.print("PINB &(1<<PB5)");
  Serial.println(PINB &(1<<PB5));

  if( PINB &(1<<PB5) ){
    PORTB |= (1<<PB0);
    }
  else{
    PORTB &= ~(1<<PB0);
    }
  }

What am I missing?

Are you saying the full code you've posted works, but it fails if you add == ...?

That's right , it fails with ==                             .

== has higher precedence than &, which means that your comparison will be performed incorrectly. But that doesn't matter, since you don't need to check if the port has a specific value, just if the appropriate bit is set.

You are right. If I use my_byte = PINB &(1<<PB5) and   if( my_byte = 0b00100000 ){ it works fine. Nevertheless, could you explain how the comparison with == and & works? Thank you.

Not really sure what needs to be explained. a & b == c is equivalent to a & (b == c).

That's what I wanted to know. Thank you again.

I found another solution based on your last remark. if(  (PINB &(1<<PB5) ) == 0b00100000){   works too

Eh. Like I said, you don't need to care about the exact value.

That's right, I just want to understand how it works

What @IgnacioVazquez-Abrams is trying to say, is that you can remove the == part all together. Just use if( PINB &(1<<PB5) ){ . As all values other than 0 are truthy.


text:
Seeedstudio Wifi shield v1.1 Not working with Arduino Mega 2560
I have been trying use the Seeedstudio wifi shield v1.1 with Arduino Mega 2560 as part of my project but I could not make the WiFly library provided on the wiki work with the Mega. I tried to run the example sketch wifly_test but it did not work I tried some troubleshooting and found that the write commands to the shield were not successful. After a few hours of searching on the internet, I found out the problem and was able to solve it. I am posting my solution below. Anyone is welcome to add to my solution.

Sooo, there's no question then? If you can find the answer on the internet and already did, I fail to see why you would post this on here.

I figured the problem as a result of my search and not the solution. Please refer to my solution below

The WiFly library provided at the Seeedstudio wiki uses the software serial to communicate with the WiFi shield. All the example files provided by the WiFly library use pins 2 and 3 as the Rx and Tx of the software serial. Moreover, the Wifi shield only allows pins 0-7 to be chosen as Rx and Tx by using different jumper combinations.
The SoftwareSerial library, on the other hand, has the following limitation for the Arduino Mega

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

Thus, as a workaround, I jumped pin 2 of the shiled with pin 10 (Rx of Software Serial) and pin 3 with pin 11 (Tx of Software Serial) using connecting wires and used the jumper setting given on the wiki. Finally I made the following changes in the example code
// Pins' connection
// Arduino       WiFly
//  10    <---->    TX (via connecting pin 2 to 10 on wifi shield)
//  11    <---->    RX (via connecting pin 3 to 11 on wifi shield)

SoftwareSerial uart(10, 11); //change software serial pins for Mega

This allowed the Mega to communicate with the Wifi shield successfully using the WiFly library.


text:
Why are MOSFETs only giving 8.1V for LEDs, not 12V?
I'm using three PWM outputs from an Arduino Mini Pro to drive the R/G/B parts of some strips of LEDs. The circuit is basically this:

I've got a single 12V power supply, rated at 200W, to light the LEDs and to power the Arduino via the RAW pin, and there are 5 metres of 60LEDs/m RGB LEDs, i.e. a total of 300 LEDs, which should be drawing ~72W according to the spec sheet (14.4W/m).
The problem is that even when the sketch says digitalWrite(9, 255); digitalWrite(10, 255); digitalWrite(11,255), the LEDs are considerably dimmer than when connected directly to the 12V supply. My cheap, digital volt meter measures ~8.1V between GND and the PWM pins across the LEDs, not the 12V that the transformer is supplying.
Am I doing something wrong? Does the MOSFET really cause such a large drop in voltage? Is there anything I can do to mitigate it? (It's important to get as much brightness as possible from the LEDs for this project).

Which MOSFET are you using? And what voltage is the MCU running on?

Sorry, should have said — I've got three STP36NF06L MOSFETs.
As for the MCU (I take it that means "the Arduino", yes?) — as I said, I'm supplying it with the same 12V as the LEDs, via the RAW pin (the right-most pin on the bottom row of this picture, which I think the Arduino steps down to 5V to use on board.

The pwm pins should only be 5 volt at the most. Or are you referring to the drain of the mosfet? Can you post a picture of your wiring?

Gah, sorry, the 8.1V is measured across the LEDs, not at the Arduino's PWM pin (which is obviously, as you say, at ~4.8V). I've just edited my post to show the correction. I added a circuit diagram at the same time. [I've actually used pins 9, 10, 11 rather than 3, 5, 6, but otherwise my circuit is as shown.]

By my calculations you are sinking 6 amps:
72 W / 12 V = 6 A

I have some doubt that the Arduino board is designed to handle that amount of current through its ground plane. Try running a separate ground wire to the MOSFET sources.
I would also be concerned about the gauge of wire you are using, and whether the prototyping board can handle that amount of current.

+1 Absolutely - the Arduino board is not built for supplying that much current, even as a 'pass through'. Connect the 12V supply (both +Ve and GND) directly to the MOSFET/LED portion.

Your MOSFETs may not be appropriate for driving from a 5V device. I had a similar problem and someone suggested I need to use a MOSFET with a low turn-on voltage, specifically IRLB8743 (http://www.irf.com/product-info/datasheets/data/irlb8743pbf.pdf) which is fully enabled at 4.5V. You might also find that your MOSFETS are getting warm because they are acting as resistors if not fully engaged.
In the above datasheet it says "Very low RDS(on) at 4.5V" meaning low resistance when VGS (arduino output voltage) is at 4.5V or more.
Your datasheet is here http://pdf.datasheetcatalog.com/datasheet2/8/0iyt26iogeofcyaowtrx4z7iwiky.pdf and I'd love to be able to tell you how to compare but I'm not sure which values to look at :/
The breadboard itself may also be introducing resistance. If you wiggle the mosfets around and the lights change brightness this is likely.
LEDs have a set forward (turn on) voltage. You can expect to see that voltage drop over LEDs and not more, which does not indicate the problem (current).


text:
How do I change the Console colour of Arduino IDE?
Leading on from the question Can I change font Color and/or Type for IDE 1.5.6r2?, in 1.6.0, or 1.6.11 it does not seem to be possible to change console.color or console.error.color. To be precise, you can change the settings in the preferences.txt2 file, but they appear to be ignored when the IDE is restarted. Have these become hard coded?  I see from the preference.txt example file that
# Some colors have been hardcoded into the source in app/ in order to ensure
# consistency with the images distributed and stored with the application.
# They have been commented out below so that users who install an old
# version of the software will not get incorrect colors left-over from this
# config file.

However, the settings to which I refer are not commented out, and so would led me to believe that they can be changed. Orange text on black is just horrific to read.
For example:
console.error.color=#FFF000
console.color=#FFCCCC

but I still get white/orange(red?) text for the output and error messages respectively.
I am making the edits while the Arduino IDE is not running.

1 In 1.6.3 the ignored console.color etc. lines appear to have been removed from the preferences.txt file.
2 C:\Users\username\AppData\Roaming\Arduino15\preferences.txt

It turns out that the theme.txt configuration file is not located alongside the preferences.txt file, but alongside/under the Arduino application's .jar files. Thus, for the current version (1.6.3):

on OS X, .../Arduino-1.6.3.app/Contents/Java/lib/theme/theme.txt
on Win7, C:\Program Files\Arduino\lib\theme\theme.txt
on Linux, .../arduino-1.6.3/lib/theme/theme.txt
on Windows 10, when installed as an App, C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\lib\theme\theme.txt, however it does not seem possible to edit it - it can be opened in notepad++ but a save fails.

See an associated Github issue, IDE Background and print color options needed, for a little more discussion.

Thanks for that. BTW, the Windows path is C:\Program Files\Arduino\lib\theme\theme.txt.  It does beg the question why are the console.error and console.color lines in the preferences.txt file if they are ignored. The Arduino IDE truly is a shockingly terrible piece of software. However, having said that, I notice that in version 1.6.3 the lines appear to have been removed.

If you've put those lines in preferences.txt (as I did), then they'll still be there after the IDE has read and re-dumped the properties, even though the IDE ignores them. Myself, I don't much like the IDE editor, so I use an external editor (setting the appropriate preference), and just use the IDE to compile and upload – for that, for me, it works well enough. Anyone out there who can add the path to the theme file under Linux?

I've added the Windows and Linux paths to your answer. Hope you don't mind.

@Greenonline Looks great!

Download the Dark Theme of Jeff Thompson from Github: jeffThompson/DarkArduinoTheme

Screenshot:

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


text:
How to monitor 12 V LiPo charging from Arduino
What's the safest way to determine a lithium-ion polymer battery's discharge and charging state using an Arduino?
I see a ton of 12 V LiPo batteries like this being sold on eBay and elsewhere.

They have a built-in charger, and I'd like to use one to power an Arduino, but the Arduino needs to know "when" the battery needs to be charged, and "when" the battery is fully charged. Unfortunately, the battery doesn't expose any pins or LEDs or other outputs that I could tap into.
I've found a few LiPo charging circuits specifically designed for the Arduino, but they all can only handle 3.7 V cells.
I'd like to avoid having to disassemble the battery or modify it to allow me to monitor its state. Is there an easier way, like connecting a battery lead to an analog pin and measuring voltage, or using a coulomb counter?

You can use 2 resistors to form a voltage divider, and safely measure the battery voltage using an analog pin.

I ASSUME they use an internal converter or regulator. 4 LIPO = 12V to 16.8V. 3 LIPO = 9V to 12.6V. ANY LIPO charger worth it's salt will charge the unloaded battery until full then stop. If it does not it's dangerous rubbish. | Something like this gives you access

Resistor divider allow current monitoring. If quiescent drain matters a high side transistor can turn off divider and a low side transistor drives the high side. 3 resistors and 2 transistors plus divider.

@Gerben, I'm not sure that'll reliably work in this case. It might work when the battery is unplugged from the charger, but when plugged in, the voltage will probably spike to 12V even if the battery isn't fully charged yet.

@RussellMcMahon, I agree, but I'm not concerned about the built-in charger being at fault. For my application, the device needs to take action depending on battery state. e.g. notify the user over wifi when charging is complete or when it needs to be charged.

@Cerin It will indeed only be reliable to measure battery-charge, while not charging.

@Cerin  Note my point above that you are probably dealing with a boost converter's  output  - if so the 12V will give minimal to no indication of battery state of charge or when charging is complete. ie you are trying to interpret battery state from the behaviour of a boost converter whose characteristics vary by manufacturer and/or wind direction. If you used ones like I linked to that have an separate low voltage power supply you could add a low-side sense resistor and easily monitor charging. This requires no battery pack modification. At worst an adaptor between plug pack and battery.

@RussellMcMahon, I don't understand. The battery I linked to likely does not have a boost converter. Google it. People have disassembled them. They're just 3 * 3.7V cells wired in series. The "12V" in the title is a misnomer, and most descriptions claim it'll output somewhere between 10-12V. Also, the product you linked to appears to be almost identical to the one I linked to, just at a lower mAh rating. When charging, won't the output cable will always read 12V, even if the battery is nearly depleted, since the power's then coming from an external source, making divider meaingless?

@Cerin The extra information is useful - providing it initially would have helped, and copying it into the question now would be a good idea. The photo you showed adumbrated that a mains AC power cord was the input. If it's the same as mine, and if it contains 3 x LiPo cells, then a complete solution is easy. | For voltage monitoring use a divider as I suggested above. | For charge monitoring use a low side sense resistor (as above). This allows you to measure CURRENT by dropping a small voltage across it. | And, no, charge voltage when fully 'flat' will start at 9V and rise to 12.6V max ...

... all at constant current (if the charger is any good at all) and will then taper to a reduced current and then stop charging. The transition from "some current" to "no current" signals end of charge. | Summary: Resistor divider of battery voltage to get V in ADC range. If desired a high side switch to turn off divider. Charging can be by monitoring a low side current sense resistor (some minor complications need addressing) OR charge will be easy enough to spot by watching battery voltage when charge terminates. A high side transistor can probably be used to detect some/no charge current.

The above could be made an answer with circuit etc if it was clear it would be worth the effort (attitude, not rep) and if all information was provided. The original "They have a built in charger" was wrong and majorly misleading. They have an external ~= 12V charger and that makes a vast difference. ... | The info re "~= contains 3 x LiPo cells, people have opened them" makes a vast difference too. Answer can only be as good as information available and the better the question the easier it is to give good answers.

@RussellMcMahon, Interesting. But what do you mean by "low side current sense resistor"? I understand what that is, but doesn't that  require a differential amplifier in order to measure the voltage drop? Is that another component I'd have to add or is there anything built-in to an Arduino that could fill the role? Sorry for the earlier confusion. And yes, this would be better placed in an answer :)

@RussellMcMahon, Also, if the true battery voltage can be measured while charging (and I'm still not completely convinced that'll be the case), then why would you want to also measuring current flow to determine when charging is over? Couldn't that be determined by battery voltage? e.g. if Vbatt=12.1V then charging is probably complete.

... (and I'm still not completely convinced that'll be the case)... ... ie nothing ever needs to be taken on faith, but if you do not want to take the advice as is you can easily do some web research to persuade yourself one way or the other.

Last try: Read this page from Battery University on Charging Lithium Ion batteries . Understand what it says about battery terminal voltage during CC (constant current) and CV (constant voltage) stages. Confirm as much as you wish from any reputable topically related site that this is THE standard way to charge LiIon (and LiPo are functionally identical).
| Read what I've written above in the light of what you have learned OR hold whatever theories you wish re spiking to 12V etc. Which would be a  shame.

@RussellMcMahon, Thank you. That link answered my question. I didn't realize that lipo voltage doesn't accurately reflect the battery's charging state, while current flow does. Although I'm still not sure how to easily measure this with an Arduino.

In the CC mode (1st stage of charge up to 70%+- (see their chart) the voltage is a good measure of charge. When you reach CV mode (usually 4.2V/cell) the V is constant and I tails UNDER BATTERY CONTROL until terminated by the charger at K x Imax where K is a design decision (see their page) but from 50% to 10% usually. 50% gives long life and slightly lower capacity. 10% give noticeably shorter cycle life and  slightly higher capacity. Stopping when V =just reaches 4.2V gives say 70%-80% of capacity but much greater cycle life. ...

...  If you put a very small resistor in ground lead of battery you can tell when the charger suddenly cuts off.Voltage drop must be very small. A Hall sensor can do this at minimal V drop or a resistor with mV range drop. Arduino 5V ADC 10 bits is about 5 mV/bit so a 50 mV drop at full current is detectable. ie need to allow say 5 counts to be safish as 0.0 V  will not read 0 count on ADC. There are other ways. .

@RussellMcMahon, So if I'm using a voltage divider to measure the battery's voltage, I could also use that to detect current drop/charge completion by detecting a very small voltage drop?

Note that what you hav suggested re charge completion is not what I suggested. The answer to what you suggest is maybe/probably.

If you want to buy something off the shelf that will provide power for an Arduino, try a power bank - they have USB out, and are also charged via USB. I found that I had to put a 100 Ohm resistor to stop mine going to sleep, but it's +5V native.
A 100 ohm resistor (0.25 watt at least!) draws 50mA, so a 5200mAH powerbank like http://www.dx.com/p/universal-5200mah-external-li-ion-battery-charger-power-bank-w-led-indicator-usb-cable-pink-362725#.VQneCnWjlIc would leak it empty in 104 hours. If you use at least 50mA at all times, then this isn't needed - I think an Arduino draws 35mA already, so you should get away with a 300 Ohm resistor, drawing 16mA. Some experimentation might be needed.

But again...these don't allow you to monitor the battery. Also, your link is to a case, not a battery...

Fixed link to point to battery, not case. You might be able to hack it, since it obviously has a monitor in there; at least you'd be able to pick up the status lights.

Use a 10V zener diode. Check it’s voltage drop, and use that in your analogRead logic.
Get the full voltage with a DMM, and also the low cut-off voltage.


text:
Integrating Shift Registers into 7 Segment LED Circuit
I'm trying to implement a shift register(s) into my circuitry and program to control two seven segment LEDs that would count up from 00 - 99. So far I have a fairly straightforward code (at least, I think. It's my first time experimenting with creating my own void functions) that controls the 7 segs in this manner, but I end up using every single digital pin on my Uno. Here it is:
const int led1a = 13;
const int led1b = 12;
const int led1c = 11;
const int led1d = 10;
const int led1e = 9;
const int led1f = 8;
const int led1g = 7;
const int led2a = 6;
const int led2b = 5;
const int led2c = 4;
const int led2d = 3;
const int led2e = 2;
const int led2f = 1;
const int led2g = 0;

void setup() {
    pinMode(led1a, OUTPUT);
    pinMode(led1b, OUTPUT);
    pinMode(led1c, OUTPUT);
    pinMode(led1d, OUTPUT);
    pinMode(led1e, OUTPUT);
    pinMode(led1f, OUTPUT);
    pinMode(led1g, OUTPUT);
    pinMode(led2a, OUTPUT);
    pinMode(led2b, OUTPUT);
    pinMode(led2c, OUTPUT);
    pinMode(led2d, OUTPUT);
    pinMode(led2e, OUTPUT);
    pinMode(led2f, OUTPUT);
    pinMode(led2g, OUTPUT);
}

void loop () {
    led1_0();
    led2_run();
    led1_1();
    led2_run();
    led1_2();
    led2_run();
    led1_3();
    led2_run();
    led1_4();
    led2_run();
    led1_5();
    led2_run();
    led1_6();
    led2_run();
    led1_7();
    led2_run();
    led1_8();
    led2_run();
    led1_9();
    led2_run();
}

void led1_0() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1e, HIGH);
    digitalWrite(led1g, HIGH);
    digitalWrite(led1f, LOW);
}
void led1_1() {
    digitalWrite(led1a, LOW);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, LOW);
    digitalWrite(led1e, LOW);
    digitalWrite(led1f, LOW);
    digitalWrite(led1g, LOW);
}
void led1_2() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1e, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1c, LOW);
    digitalWrite(led1g, LOW);
}
void led1_3() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1e, LOW);
    digitalWrite(led1g, LOW);
}
void led1_4() {
    digitalWrite(led1a, LOW);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1g, HIGH);
    digitalWrite(led1e, LOW);
    digitalWrite(led1d, LOW);
}
void led1_5() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1g, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1b, LOW);
    digitalWrite(led1e, LOW);
}
void led1_6() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1g, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1e, HIGH);
    digitalWrite(led1b, LOW);
}
void led1_7() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, LOW);
    digitalWrite(led1e, LOW);
    digitalWrite(led1f, LOW);
    digitalWrite(led1g, LOW);
}
void led1_8() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1e, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1g, HIGH);
}
void led1_9() {
    digitalWrite(led1a, HIGH);
    digitalWrite(led1b, HIGH);
    digitalWrite(led1c, HIGH);
    digitalWrite(led1d, HIGH);
    digitalWrite(led1g, HIGH);
    digitalWrite(led1f, HIGH);
    digitalWrite(led1e, LOW);
}
void led2_0() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2e, HIGH);
    digitalWrite(led2g, HIGH);
    digitalWrite(led2f, LOW);
}
void led2_1() {
    digitalWrite(led2a, LOW);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, LOW);
    digitalWrite(led2e, LOW);
    digitalWrite(led2f, LOW);
    digitalWrite(led2g, LOW);
}
void led2_2() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2e, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2c, LOW);
    digitalWrite(led2g, LOW);
}
void led2_3() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2e, LOW);
    digitalWrite(led2g, LOW);
}
void led2_4() {
    digitalWrite(led2a, LOW);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2g, HIGH);
    digitalWrite(led2e, LOW);
    digitalWrite(led2d, LOW);
}
void led2_5() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2g, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2b, LOW);
    digitalWrite(led2e, LOW);
}
void led2_6() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2g, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2e, HIGH);
    digitalWrite(led2b, LOW);
}
void led2_7() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, LOW);
    digitalWrite(led2e, LOW);
    digitalWrite(led2f, LOW);
    digitalWrite(led2g, LOW);
}
void led2_8() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2e, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2g, HIGH);
}
void led2_9() {
    digitalWrite(led2a, HIGH);
    digitalWrite(led2b, HIGH);
    digitalWrite(led2c, HIGH);
    digitalWrite(led2d, HIGH);
    digitalWrite(led2g, HIGH);
    digitalWrite(led2f, HIGH);
    digitalWrite(led2e, LOW);
}
void led2_run() {
    led2_0();
    delay(1000);
    led2_1();
    delay(1000);
    led2_2();
    delay(1000);
    led2_3();
    delay(1000);
    led2_4();
    delay(1000);
    led2_5();
    delay(1000);
    led2_6();
    delay(1000);
    led2_7();
    delay(1000);
    led2_8();
    delay(1000);
    led2_9();
    delay(1000);
}

So how would I reduce the amount of pins used while still keeping functionality? I have two 74HC595N shift registers at my disposal.
Thanks!

I have done exactly this, to great effect.
int clockPin = 4;
int dataPin  = 2;
int oePin    = 3;

// Here are the digits from 0 to 9, as bitmaps.
// You will need to work out which segments are which,
// according to your wiring, and make your own.
unsigned char digitmaps[]={0x7b,0x11,0xe3,0xb3,0x99,0xba,0xfa,0x13,0xfb,0xbb};

void setup() {
  pinMode(clockPin,OUTPUT);
  pinMode(dataPin,OUTPUT);
  pinMode(oePin,OUTPUT);
}

void sendnumber(unsigned int number, int oePin,int dataPin,int clockPin) {
   digitalWrite(oePin,LOW);
   shiftOut(dataPin,clockPin,MSBFIRST, digitmaps[(number/10)%10]);
   shiftOut(dataPin,clockPin,MSBFIRST, digitmaps[number%10]);
   digitalWrite(oePin,HIGH);
 }

void loop() {
  for (int i=0; i<100; i++) {
    sendnumber(i,oePin,dataPin,clockPin);
    delay(1000);
  }
 }

The crux of the matter is shiftOut, which shifts 8 bits out the dataPin, toggling the clockPin as it goes, high bit first (MSBFIRST), looking up the pattern in the table. dataPin goes to serial in on the FIRST shift register, clockpin to BOTH clocks, oePin to BOTH OE and another one, I think store register? Q7' or QH' (depending on your docs - it's the overflow pin) of the first goes to the serial in of the second, and +5v & GND, as per normal, and the 8 parallel out Q0-Q7 go to the pins on the 7-segment.
If there's anything unclear, or anything I've missed, let me know. My example shows 2 digits, but any number will work, up to the available power.
Things might be clearer if I convert the digitmaps to binary. The below compiles to the same thing as the one above.
unsigned char digitmaps[]={
   B01111011, // 0
   B00010001, // 1
   B11100011, // 2
   B10110011, // 3
   B10011001, // 4
   B10111010, // 5
   B11111010, // 6
   B00010011, // 7
   B11111011, // 8
   B10111011}; // 9

This is because, in my wiring, from left to right the bits represent in the 8 on my display: center,bottom left,bottom,right bottom,top left,decimal point/not used,top,right top. You can see that the digit "1" has 2 1's in it: the 4th (right bottom) and the last (right top). An 8 has all of the bits set to 1, except position 6 - because that's the decimal point. Send individual bits (e.g. B00010000) to see which segments shows up, make a map, and then combine them.

It looks like you may have a stray semicolon after your void sendnumber function, but other than that, it looks great! Thanks for this!

The code had a lot of other stuff in it, because obviously something that just counts to 99 repeatedly isn't that useful. I cut & paste bits, just quickly wrote the rest. Post edited to remove stray semicolon. I write in too many languages to keep them apart without a compiler to help me :)

Ahh, gotcha. Could you point me in the direction of a guide to learning how to express digits "as bitmaps" as you have done? I'm not finding any relevant answers online.

This is the same thing you are doing in your code, with 7 digitalWrite(ledXX, LOW);  statements, but do it all in one go. Try sending 1,2,4,8,16,32,64 and 128 to figure out which segment is which, then add them together - e.g. when you send a 1, it might light up the top-right segment, 16 might be the bottom right segment, so to display a 1, you can light both of these up  by sending 1+16=17. So, the number shown in my bitmap as 0x11 (the second one, as the first one is 0!), should be replaced by the number 3. I used hexadecimal as I am familiar with this; 0x11 is hexidecumal for 17.

You could also express the same number as binary - B00010001 - each 0 or 1 will represent one segment. Which segment is which depends on which pin on the chip you connect to which wire on the display.


text:
Flickering LCD when using > 5v power supply on a Pro Mini
I have a Pro Mini wired up to an LCD via an I2C board. At http://www.arduino.cc/en/Main/ArduinoBoardProMini it says the pro mini can accept up to 12v on the RAW pin as it has a voltage regulator on board. When I plug a 12v power supply into the raw pin, the LCD works fine initially, then slowly degrades into flickering more and more. It also does this with a 9v power supply. At 5v it works perfectly. Any ideas what's going on?

If the LCD has a backlight you are absolutely over heating the regulator on that board by running it at 9 or 12V: At 12V with 100mA for the backlight and using 175C/W thermal resistance for the regulator:
Tj = 25C + ((12V - 5V) x 100mA x 175C/W) = 147C
That regulator goes into thermal limit at 125C.


text:
Integrating an analog signal using Arduino Uno SMD
I need to integrate an analog signal using my Arduino Uno. I am sampling the input signal at 1 KHz using a delay command in my void loop() and adding up the values at the analog read at that specific time. Then I multiply my added output with 0.001 s to get my integration.
Since, I am new to Arduino Uno, I want some review on the code to check whether I am correct or not. Kindly help, I'll be indebted.
const int a=13; //my output pin
const int c=A0; //my input pin
int d=0; //my summation variable
int e=0; //my integration variable(integration as a summation)
void setup()
{
  pinMode(a, OUTPUT);
}
void loop()
{
  int b=analogRead(c);
  d=d+b; //my summation
  e=d*10^-3; //my integration as a summation, by sampling my signal at 1ms
  analogWrite(a,e); //writing my integration into my output pin

  //print the results to the serial monitor
  Serial.print("input=");
  Serial.print(b);
  Serial.print("\t output=");
  Serial.println(e);

  delay(1); //wait for 1ms as I want it sampled at that rate
}

Since you are using an int , d could overflow in as little as 32 measurements. Also analogRead does take some time, as does the code around it, so the time between measurements will be a bit more that 1 ms. I also don't see how you call dividing by 1000  integration.

Could you explain why you want to integrate in the first place? Integrating a positive signal will yield a diverging integral, meaning that, as your program runs, the result will increase without bounds. This is problematic. If your store the integral in an integer variable, even a long int, it will eventually overflow. If you store it in a float, it will loose precision as it grows and, eventually, the summation will have no effect, because d+b is exactly equal to d if d is a big enough float.

There are a couple of issues with your code.
First of all, 10^-3 is not a valid constant in C/C++ code. The correct syntax would be 1e-3, which means 1 × 10-3. But you have the further problem that you're working with integer variables, and 0.001 rounded to the nearest integer is just zero. You'll probably want to use float variables for this math.
Also, the values you get from AnalogRead() are all non-negative integers, so your summation will quickly overflow unless you subtract a constant from each reading in order to get both positive and negative values.
The second issue is about the delay() function, and trying to use it to determine the sample rate of your system. The delay() function is not all that precise. It really is just guaranteed to produce a delay of at least the number of milliseconds specified, but it can be more — sometimes much more.
Furthermore, the other operations in your loop take much longer than 1 ms anyway. For example, you're printing on the order of 25 to 30 characters to a serial port on every iteration, which is an overall rate of 25,000 to 30,000 characters per second. Unless you're running your serial port at an insane baud rate (430.8 kbaud or more), it simply won't be able to keep up, and it will end up increasing the period of your loop to whatever time it needs.
All of this means that the sample period of your loop is NOT 1 ms as you want, and in fact, it can vary quite a lot based on other things that are going on in the system, such as interrupts. For doing this kind of DSP, you will want to learn how to use a timer interrupt to control the sampling of the analog input, and you'll need to trim the amount of data transmitted for each sample to an amount your serial link can handle.

Thank you for your reply. It's valuable really, kindly help me with correcting my errors
1> Regarding the integer data types of d, b and e, I completely understand and hence I'll change them to float variables.
2> Regarding the AnalogRead being non negetive integers, is there any way to read floating value out of analog inputs?
3> Regarding the delay timer, could you direct me to some literature on using timer interrupts to sample my signal?
4> Is there any way around the problem, I mean some built in library functions to help with integration etc...

I'm not entirely clear on what you're trying to achieve mathematically. However, I can see a number of issues in your code which I'll try to address briefly.
Arithmetic
I suspect this line isn't doing what you intended:
e=d*10^-3

The ^ operator in C/C++ is actually a bitwise XOR (exclusive-or). There is no arithmetic raise-to-the-power operator.
There is a function called pow() for calculating exponents. However, there's no point using it for a fixed value. It would be better to explicitly write the number, i.e. 0.001.
Precision
The power issue notwithstanding, it's important to note that you're working with integers here, and the result of analogRead() is only in the range 0 to 1023. Dividing that by 1000 and storing the result as an integer will destroy your data -- most readings will effectively be 0. (That's not to mention the fact that an int has a limited range and will overflow quite quickly if you don't reset it.)
The simple solution would be to store the data using the float data type (floating point). You would need to declare variables b, d and e as float instead of int. That should let you divide down by 1000 without losing significant precision.
Output range
The analogWrite() function has a very specific output range. It will only accept values 0 to 255 (inclusive). I'm not entirely sure what you're hoping to do with it, but I suspect you'll need some way to map your integration calculation onto that output range, or possibly reset your summation periodically.
If you don't do that, you'll probably find that e ends up over 255 very quickly (within a couple of seconds). The result is that you won't see any change on the output PWM.

I'm trying to arrive at integration as a sum of discrete samples, dividing my 1000 I did because my time period was 0.001 seconds. Is there any way around this problem for analog integration, I'll be grateful for your help...

Here is an edited version of your code:
/*
 * Integrate a signal read on analog input 0.
 * Print the result every 2 seconds on the serial port.
 */

const int input_pin = A0;
unsigned long last_time_sampled = 0;
unsigned long last_time_printed = 0;

// The integral is in units of DN*us, 1 DN being the ADC step.
float integral = 0;

// Convert from DN*us to V*s, assuming a 5 V reference.
const float conversion = 5.0 / 1024 * 1e-6;

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    int sample = analogRead(input_pin);
    unsigned long now = micros();

    // Approximate the signal as a constant equal to the current sample
    // from the time of the previous sample until now.
    integral += sample * (now - last_time_sampled);
    last_time_sampled = now;

    // Print the results every 2 seconds.
    if (now - last_time_printed >= 2000000) {
        Serial.print("input = ");
        Serial.print(sample);
        Serial.print(", output = ");
        Serial.println(integral * conversion);
        last_time_printed = now;
    }

    // Limit the sampling rate to no more than 1000/s.
    delay(1);
}

The main changes I did are:

I renamed the variables to give them more meaningful names. This
single change makes the code a lot more readable.
I removed those comments made redundant by the better variable names.
I removed analogWrite(), since I couldn't make any sense out of it.
I compute the time between samples as time differences. Unless you
take your samples on some kind of timer interrupt, the delay between
samples will never be 1 ms.
I stored the integral as a float to avoid overflows.
I removed the summation variable, as it was redundant with the
integration variable. Instead, there is a conversion factor for
converting the integral from its “natural” unit (DN⋅µs) into a more
human-friendly unit (V⋅s).
I print the results only every 2 seconds, as nobody will read
something printed every millisecond.
I added some comments, most importantly for making explicit the
approximation used in computing the integral.

There is still one caveat with this code: once the integral is roughly
107 times larger than the samples, which should happen after
only a few hours, the integral is not incremented any more, due to loss
of precision.


text:
GSM Modem with MAX232 to Arduino Serial?
I have GSM modem that has MAX232 interface for RX/TX/GND on three pins.
Is it possible to interface Arduino in some way?
Tnx for help.

Yes, with another MAX232, or bypass the MAX232 somehow.

Tnx, should lines be exchanged on another max232? rx,tx->tx,rx

Of course. Otherwise you'll be transmitting to a transmit pin, not a receive pin.

Thank you for confirmation, something else doesn't work :)


text:
How to convert the 0-5V to a 4-20mA current loop?
I'm pretty clueless about electronics so everything has to be explained in simple terms to me.
I have an Arduino with a program which provides a value via the Analog output, so that is anything from 0-5V.
On the other side I have a PLC (programmable logic controller) with an IO card which allows to connect to a (4-20mA) current loop.
How do I convert from lets say 1-5V to the 4-20mA in a somewhat cheap and safe way (I don't want to destroy the PLC [and possibly the Arduino])?
Of course the Arduino and the PLC have separate power sources.

Most arduino's don't have analog outputs (DACs), only PWM outputs.

Volts (V) and Milliamps (mA) are not units you can convert between.  for an analogy using water flowing in a pipe Volts would measure the water pressure, while mA or A measures how much water is going thru the pipe.  As you can see one can effect the other, but they are not measuring the same thing at all.   Also be certain to bridge the grounds (or common) of the two power supplies.

Can you link to some documentation for the particular PLC you have?

Usually PLC are 24v be careful with that

If all you need is analog 4-20mA loop transmitter, then you need an op-amp, the transistors that its output drives, a sense resistor, and a few other resistors. Note that these are at least 1% resistors. This needs to be built on a printed circuit board, not a solderless breadboard.  Two of my coworkers at Maxim Integrated wrote an applications note about a 4-20mA current-loop transmitter: http://www.maximintegrated.com/en/app-notes/index.mvp/id/5610  see this figure:

Since you are already using a PWM (hopefully with an RC low-pass filter), you just need everything after the DAC output. (Performance will not be as good with an Arduino PWM as it would be with a 16-bit voltage-output DAC, but the general idea would still work.) For your purpose, you can also ignore all of the stuff about the HART modem -- that's an extra feature for sending digital information along the same loop. Only relevant if your PLC receiver was expecting it.
There are also numerous prebuilt 4-20mA transmitter boards available, this has been around many decades in the industrial control market. Since Maxim Integrated makes precision DAC chips, we don't make reference designs that take 0-5V (especially from a PWM!) and convert to 4-20mA -- but we do sell reference design boards that include the DAC. Such as our Monterey system board (MAXREFDES15#). http://www.maximintegrated.com/en/app-notes/index.mvp/id/5683
There's also a 4-20mA Current-Loop Transmitter from ti.com, XTR117: http://www.ti.com/lit/ds/symlink/xtr117.pdf
There's also a board from mikroElektronika, MIKROE-1296 (available through mouser.com) that uses an Analog Devices DAC (through SPI interface) to drive the 4-20mA transmit circuit. Again, this is an idea that's been around many decades, so a search for 4-20mA transmitter should yield lots of useful information.
So your best bet is probably to purchase one of these prebuilt 4-20mA transmitter boards, which most likely will include its own precision DAC. You'll have to modify your Arduino code to drive the SPI interface, specific to whichever DAC you end up using. Or, if you really want to use the PWM to drive 4-20mA (at reduced performance), be sure to at least use an RC low-pass filter to get it as close as possible to a stable DC level.

Here is an article which explain how you can use arduino and a 4-20mA current loop transmitter to generate 4-20mA signal. Its using a DAC and 4-20mA current generator.
https://ncd.io/interfacing-isolated-4-20ma-current-loop-transmitter-arduino/
So this is how it works
in this article they are using a 4-20mA current transmitter board with arduino, You can build it by yourself as well as you can get it from it from https://store.ncd.io/shop/?fwp_product_type=4-20ma-transmitter. it has a DAC and a XTR ( its a TI part which is used to generate 4-20mA signal) and signal and power isolator. In these application it is very important that you use isolation between device and your arduino or any other master device. Once you have all the hardware setup, you can send i2c commands and it will generate 4-20mA current loop signal. Lets say you have a device which provides 0-5V and you want to control a different device which needs 4-20mA signal in that case you can use arduino analog input to read the 0-5V and you can use this 4-20mA transmitter to convert that 0-5V into 4-20mA.
For more info checkout the above mentioned article.

Link only answer are not good, because of link rot. Please, copy the relevante information here.


text:
AVCC and AREF when using a reference voltage lower than 5V?
I'm designing a circuit that will use a 2.5v reference for the AREF. Should AVCC be powered from 5V or 2.5V?

AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that PC6...4 use digital supply voltage, VCC.

So it should be connected to 5V.


text:
Saving Arduino output to a text file in append mode
I used the code below to save output from an Arduino Uno to a text file.
The problem is whenever I run the code the old data in the text file is deleted.
I don't want the old data to be deleted, what should I change?
import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
   mySerial = new Serial( this, Serial.list()[0], 9600 );
   output = createWriter( "data.txt" );
}
void draw() {
    if (mySerial.available() > 0 ) {
         String value = mySerial.readString();
         if ( value != null ) {
              output.println( value );
         }
    }
}

void keyPressed() {
    output.flush();  // Writes the remaining data to the file
    output.close();  // Finishes the file
    exit();  // Stops the program
}

See this SO answer for an example.

I think the problem is with your file name it's the same every time as the same-named file with the same extension can not be stored. To solve you can add a variable before your file name that increments every time so your file name gets changed every time and you can store that variable in EEPROM for further use.

There are a couple of ways to append to a text file.

You can either read the entire file in a temporary variable, then append the new data to it and then write to file.

you can implement using printWriter instead like mentioned here:
https://processing.org/discourse/beta/num_1267767630.html

Let me know if it works.


text:
Cheap weatherproof ultrasonic range sensor?
What's an inexpensive ultrasonic range sensor that's reasonable waterproof or weatherproof that also interfaces easily with an Arduino?
I've used these kinds of ultrasonic range sensors, which are cheap and trivial to wire to an Arduino, but they're not very robust and are easily damaged since you can't cover them without that covering obstructing the soundwave.
Maxbotix sells a "Weather-Resistant" ultrasonic range sensor, but it's around $100, which is a little out of my price range.
I've researched those "parking sensors" used on cars, but I haven't seen anyone successfully interface them with an Arduino. It's also hard to tell how they're controlled. Some sites sell batches of the sensor for $3/each, but I don't think this includes the control electronics. Ebay listings that include what appears to be a bulky controller board seem to go for around $50-$100, which makes them a little pricey.

Those modules are just the ultrasonic transducers. You can see the two pin connector. You can probably get those cheap boards, de-solder the two transducers, and connect the wires from two of the water-proof ones.


text:
Razor 9DOF SMD Capacitor replacing
I just bought This IMU a while ago, and when I reached the point where I wanna connect it, I noticed that one of the capacitors have been removed by accedint, and since it took too long to check the product, I won't get to replace it or get any refund, so my question, how can I replace that SMD capacitor?
P.S. I have some Ultrasonic sensors might have the same SMD capacitors that I can take off and replace with if anyone can help.

You are looking for C22,  0.1uF capacitor, connected to smooth the 3.3v from the regulator. If you are not using the battery connector, you can probably just leave it out.
You could just get a capacitor with leads and connect it somewhere between 3.3v and ground. You can use the ISP header (2x3 holes on the right) for this. I think it's the top-right and bottom-right pin.

You are on a tough road. I hope someone can give you specifics.  Normally you would able to identify the capacitor from its parts designation, but that board does not have any. So you will have to match the schematic (assuming spark fun provides one) to the board layout to figure out what it is.  The cost of the part is probably over a penny, maybe even 2 cents. In other words, not an issue.
It will require hot air to desolder one from another board and to solder this one on. Someone might be able to do it with a fine tip solder  pencil, but not likely.
Bottom line; find someone who has experience repairing boards, or order another one. Amazon has breakout boards for the 6050 for $6. But I see this one has Serial, and a magnetometer, so it is not quite the same. But depending on what you plan to do with it, it could work.

C22,  0.1uF capacitor, connected to smooth the 3.3v from the regulator.

If you don't care about the donor board, you can just get a sharp knife and get under the copper, and lift it from the board. Then use a soldering iron to remove the bit of copper trace. It might take a couple of tries, so first try on some other components first.

The problem is I can't order another one, it would take over 1 month to reach me, someone else told me that I can power it through the pins, is that possible if I read it's datacheat or not?
I'm using it to stabalize a quadcopter, that why I can't risk not knowing too well, coz if I get wrong data it would waste alot of time to figure that out :\

Yes, @gerben answer sounded reasonable (I upvoted it)

Try using two soldering pencils, one in each hand. makes it easy to remove the capacitor from the donor board.


text:
Using A 4 Ohm Speaker With Arduino
I've salvaged a 4 Ohm, 1.5 Watt speaker from an old computer, and I was wondering how I'd go about getting it to work with my Arduino. I've heard of various amplifier circuits such as opamps, but I do not know which would be the best for my situation. I've also heard that using the speaker in certain ways (such as directly connected to a pin from the Arduino) could damage both the speaker and the output pin, so that is definitely something I'd like to avoid. I'm not looking for anything complicated; I'm just trying to get a feel for the general circuitry, programming, and speaker volume. Any suggestions?

5v, 4ohm, >1amp from a pin rated for 0.04amps; this isn't safe!
You would need a driver, but it would suffice to add a small transistor & a couple of resistors to drive it; here is a slightly more complex layout, there are many examples on the web.


text:
Different dht21 readings on different arduinos
First of all, let me begin by saying that I'm still pretty much a rookie.
I have a project with a dht21, an LDR and an ultrasonic distance sensor. I have 3 different arduino uno boards, namely:

A (supposedly) original arduino uno r3.
A chinese nhduino, arduino uno r3 clone.
And this one, sitting on top of this.

I've been playing around with the three boards for the last couple of months, testing a variety of sensors and having the same results with the three boards, as expected. But then, with the aforementioned setup, I'm getting very different readings on the DHT21 sensor. If I use the "regular" (first two) arduinos plugged in my laptop, the readings are consistent. But if I use the banana pi(duino), I get the temperature reading correct, but getting weird humidity readings... pretty most of the time a 5% humidity value.
Everything tested on the same room, same sensors and same protoboard. No external power supply.
I'm totally clueless here, any ideas of what could be the problem?
Thanks.

Do you have multiple DHT21's as well as multiple boards? If so, I assume the error still follows the board, not the sensor.
Is there another library you can use on the RPI, or maybe take the Arduino piece out of the loop, and interface the sensor directly with the pi.  Lets try to figure out which component is giving us the issues. (Sensor, Arduino, Pi, or code)

Only one DHT21, one LDR and one Ultrasonic. Same board, I just plug/unplug jumpers cables. It's not a software problem either, as the BPiDuino has been working like a charm so far with every other digital or analog sensor I've thrown to it. Except for the DHT21. But I think I've found the solution, because now I'm using a breadboard power supply and it's working no matter whether I power the PSU from the banana pi USB or from the barrel jack.

Problem solved. Using a ywrobot breadboard PSU and now it works. I haven't tested current in the circuit but looks like it was just too low. I wish I'd had datasheet for the board to look at. In a language different from chinese would have been ok, I guess.


text:
Arduino Program for Olimex ekg/emg shield to detect heart rate in bpm as well as show ECG in ElecGuru software
The manual of olimex ekg/emg shield provides a link for ShieldEkgEmgDemo code, it can show ecg in realtime in a software ElecGuru. The link to software is also provided in the manual. I need to get the numerical value of heart rate in bpm as well as the ecg. I want to implement this in a larger program where I can use something like this.
if(heartRate > 90){
        //do something
}

I have an Arduino UNO board and an Olimex ekg/emg shield with electrodes. I tested the shield with demo code and it worked fine. I got a clean ECG on ElecGuru.

You seem to know what you task entails pretty clearly, but what is your question? is there a portion of the demo code you don't understand?


text:
What is the rise time of an output pin of atmega328 changing its state?
I've already searched a lot and didn't found the answer. Also, I don't have an o'scope. Anyone can help me?

Should be in the ns range. Also depends on the load, obviously.

Do you have the load impedance and capacitance, and the input thresholds?

I just measured on my Uno with a pocket scope and a cheap 1× probe. I got something around 40 ns, but it was at the bandwidth limit of this basic scope, and I believe this probe has quite high capacitive load. A faster scope and a better probe would probably give a shorter rise time.
Update: I tried again with a better scope (an Hameg HM-305) and a decent 10× probe, the observed rise time was somewhere in the 10 ns range, which is about the rise time of the internal amplifier of the scope. Then the higher boundary would be about 10 ns.

Last time I measured on a circuit (it was an i2c network master and with a 2560), it was about 0.3us, so that gives you a high value for that. Also, I believe it cannot be faster than one/half of a CPU cycle which takes: 1/(16E6)=62.5ns/2 = 31.25ns, so here's the lower boundary.
And there you got a possible range.
Then the rise time will definitely depend on the configuration of the circuit. It might be less or more depending on pull ups, capacitance attached at the pin out exit. It might also depend on the configuration of the pin (PWM? Internal Pull-up?…)
Finally, I believe there should some nominal values given in the datasheet.
Edit: Useful knowledge from the datasheet, but there's no definitive answer for any pin:
P311: 29.4.3 External Clock Drive
| Symbol | Parameter | Min | Max   | Min | Max   | Min | Max   |
| ------ | --------- | --- | ----- | --- | ---   | --- | ----- |
| tCLCH  | Rise Time |     | 2.0µs |     | 1.6µs |     | 0.5µs |

P313: 29.6 SPI Timing Characteristics
| Description    | Mode      | Min | Typ   | Max    |
| -------------- | --------- | --- | ----- | ------ |
| Rise/Fall time | Master    |     | 3.6ns |        |
| Rise/Fall time | Slave     |     |       | 1600ns |

P315: 29.7 Two-wire Serial Interface Characteristics
| Symbol | Parameter                      | Condition | Min        | Max   |
| ------ | ------------------------------ | --------- | ---------- | ----- |
| tr     | Rise Time for both SDA and SCL |           | 20 + 0.1Cb | 300ns |

HTH

The cycle time is 62.5 ns, and of course the rise time can be shorter than that.

The rise time of a GPIO on all embedded systems is not connected to the CPU speed.

I got 8 ns on both the rising and falling edges. If using the PORT instruction to set and clear bits instead of the much slower digitalWrite() instruction, the highest frequency I got by toggling a pin high and low was 2.666 Mhz. This is slowed down by the excessive time the arduino takes to pass execution back to the top of the Loop() marker. The duty cycle of the pulse output at 2.666 Mhz was somewhere in the region of 15%.


text:
Is PulseIn fast enough for Quadcopter?
I've been trying to use interrupts to control a quadrotor with a tx/rx to no success. I'm using an arduino mega as my control board. I have successfully read a singe channel using attach interrupt and PulseIn. I have also successfully read multiple channels with pulse but failed to do so with attach interrupt and pinchange int. Should I just go ahead and use PulseIn

Your referring to reading ppm signals from an RC radio with pulseIn?

Yes. I have been told to avoid it but nobody who tells me this explains why

You should avoid pulseIn for a quadcopter, the main reason being that pulseIn takes too long to execute.
pulseIn waits for a pulse to start, then waits until that pulse finishes, and then returns how long it took to finish. Standard RC signals pulse at 50-60Hz, with the "high" part of the signals being between 1 and 2 milliseconds. 60Hz is one pulse per 16 milliseconds or so.
What that amounts to is pulseIn taking at most 18 milliseconds, but never less that 1 millisecond to execute per channel. lets say you want to measure 4 channels (throttle, pitch, yaw, roll); the average time would be around 40 milliseconds.
In general 40 milliseconds isn't so long, but your quad will need to read the accelerometer and gyroscope and stabilize itself more often then that in the air. A loop that takes 40 ms is running at 25Hz, but the stabilize loop in all the quadcopter implementations I'm familiar with is run at 100Hz or higher (thats areoquad, multiWii, and ardupilot).
You should use interrupts to read the values, because interrupts are non blocking, and give higher quality readings. Some specialized quadcopter boards have other processors read the actual RC signals and send the result back to the main processor to cut down on the number of interrupts they have to use.

FYI, The standard servo output library sends new signals at 50Hz. Those open source quadcopters use their own implementations that run at higher output frequencies, since brushless ESCs support that. There is a pull request with code to add support for different refresh intervals to the arduino servo library here that I have tested; You could try appling it as a patch to your installation if the output rate gives you trouble down the road.

Thanks for the servo library information. Great. I did try it on my quad and I got this error information stated below after refreshing my servo library.  Any idea what causes this and how to correct this?                                                                        C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:40:69: error: 'usTOTicks' was not declared in this scope
^
exit status 1
Error compiling for board Arduino Nano.


text:
Serial communication and Arduino program in C
When I flash this simple code (using Arduino-Makefile):
#include <avr/io.h>
#include <util/delay.h>
#include <Arduino.h>

void init_io(void) {

    // open serial port
    Serial.begin(9600);
    while (!Serial);
    Serial.println("Comm-link online");

}//END: init_io

int main(void) {

    init_io();

    while (1) {

        // send data only when you receive data:
        if (Serial.available() > 0) {

            // read the incoming byte:
            int incomingByte = Serial.read();

            // say what you got:
            Serial.print("I received: ");
            Serial.println(incomingByte, DEC);

        } else {

            //  Serial.println("No serial ");

        }

    }//END: loop

    return 0;
}//END: main

I only see first two chars printed in the serial output:

~$> Co

The input also does not work as intended - tested on two independent microcontrolers, Mega and Uno. I'm not sure what's the cause of this behaviour. Here's the Makefile:
BOARD_TAG    = uno # megaADK uno
MONITOR_PORT  = /dev/ttyACM0
ARDUINO_LIBS =

include $(ARDMK_DIR)/Arduino.mk

It's definitely not a hardware problem, I've used serial i/o before in other projects.

What program are you using to see the serial responses? How do you have the port configured on your end?

Usually screen, I tried also on Arduino IDEs built in Serial Monitor.

When using the Arduino core library, you normally do not write a
main() function. Instead, you write setup() and loop() and rely on
libcore's provided main() for calling them.
If you nevertheless want to provide your own main(), then you should
call init(); (with no arguments) before you try to use the library.
Adding this single call makes your program work on my Uno.
However, since it does not seem to be officially documented, this trick
may not be safe against upgrades in the core library. Writing setup()
and loop() should be more future-proof.

This solves the problem. An alternative is to use AVR libc implementations printf(), puts() and getchar().

Yes, but if you go along this path, you will have to initialize the UART yourself, and provide the put and get functions, and the ISRs. And since your program will not depend on libcore, you will probably use a Makefile simpler than Arduino.mk.

Yes,off course - I'm simply stating it here as another possibility, for future reference.


text:
How can I drive this LCD TFT with an Arduino?
As I understand it, the Arduino comes with a TFT library which uses SPI to drive LCD TFTs. I recently bought a TFT labelled "HY-32.TFT" on the front and "HY-TFT320_262k heyaodz111211" on the back.
It uses an XPT2046 touch screen controller, but I'm more interested in just getting something on the screen currently.
To use the Arduino library, I need to connect pins:

SCLK
MOSI
CS
DC
RESET

But I can't see these apart from some similarly named ones associated with TP (touchpad?) and SD (sd card), as the photo shows:

Is it possible to drive this with my Arduino? If so, how?
UPDATE: It looks like the datasheet for the controller and the board can be downloaded from 3.0" 3" TFT LCD Module Display + Touch Panel + PCB adapter.

http://www.geeetech.com/wiki/index.php/3.2TFT_LCD

From what I'm seeing, the touch screen and card reader use SPI but the LCD uses a bunch of Digital I/O lines. The link in Gerben's comment includes a library for the LCD that might be what you're looking for. I hope you're using a ATMega board as it doesn't look like an Uno or similar board will have enough I/O for the LCD.

If you search for "arduino lcd tft shield" on ebay you should if a few shields for your kind of lcd. But all of them require an Arduino MEGA (or DUE).
You could also use some kind of a shift register to drive this lcd with an Arduino UNO (or other small boards).


text:
How big of a difference is there between an Arduino Uno and the rest?
Lately I've been fooling around with a project for my Microsoft Sidewinder Force Feedback Pro Joystick. I've found out that there is a project currently for it built for the Teensy 2.0. On the page for the Teensy 2.0 there is a link for an Arduino Library for the very same project that was (I guess) converted. There isn't much documentation for it, and I don't think there is much progress being made on it anymore. However when I grab the files and try to upload it to my Arduino Uno it spits out an Unsupported device. Doing some digging around I found where it shows what devices are supported in the includes.h.. Which happen to be
#if defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__)
 #define __AVR_AT90USBX2__
#elif defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
 #define __AVR_ATmegaXU4__
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
 #define __AVR_AT90USBX6__
#else
 #error "Unsupported device"
#endif

Which ends up being the red arduino, arduino micro, arduino leonardo, and I think a few teensys.
What I want to know is if you can upload this code onto a UNO. I'm not really wanting to purchase a teensy just to check if this will work or not.

You can try removing the #error line and see what happens.

No that won't work

@BrettAM Actually that was the first thing I tried lol. Its trying to verify what Arduino I am uploading to. Which if I change the board in the arduino software it will compile and attempt to upload. However will ultimately fail.

The code won't work as a traditional project when uploaded on an Uno, because the Uno does not talk directly to the Host, it only speaks UART.
But good news is that the Uno uses another atmega chip, an Atmega8u2 on the older models or Atmega16u2 on the others. That IC handles directly the USB connection with the host on behalf of the Atmega328. And that code below is actually (close enough) support for that IC:
#elif defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
 #define __AVR_ATmegaXU4__

That means you should be able to upload the code (or a similar one) on that 'frontend' IC, so it acts as a HID device, and connects to the main 328 for any I/O you might need.
To do the upload on that other chip, you can use an ISP programmer on the 6pins header close to USB, or you can use the DFU programmation mode over USB.
I'm sorry for not giving external references or code, but I'm answering from my phone!
Edit: after a short browse over the code, it's definitely possible to implement that using an uno, but you'll need to split the code between the two chips: the USB interface to behave like ah HID device and the main I/O chip to talk midi, and implement comms between both.
Edit #2:
Here's a few resources that might help to work out USB and Midi using Arduino, but it looks like none is a cooked in USB on atmegaXu2 to Midi on atmega328:

http://unojoy.tumblr.com/
http://forum.arduino.cc/index.php/topic,111.0.html
http://hunt.net.nz/users/darran/weblog/15f92/Arduino_UNO_Big_Joystick_HID_firmware.html
https://stackoverflow.com/questions/16710701/joystick-usb-definition-for-use-with-arduino
http://hackaday.com/2011/03/28/hiduino-the-only-limit-is-yourself/
http://arduino.cc/en/Hacking/DFUProgramming8U2
http://arduino.cc/en/tutorial/midi
https://sites.google.com/site/bharatbhushankonka/home/diy-midi-over-usb-using-arduino-uno
http://www.instructables.com/id/Turn-your-Arduino-Uno-into-an-USB-HID-Mididevice/

And if you're not at ease with AVR development, it's gonna be HARD. You'd better get a teensy2 or a leonardo where that code should compile and work with little effort.
HTH

It's actually a '16U2, not a 4.

I have no problem with working with DFU as I have played around with UnoJoy before (like I said to someone elses post I tried converting the signal coming out of my RC Receiver to something I can use over UnoJoy, but was having issues with that) However I'm not nearly skilled enough to go through the entire code to split everything up and recode as needed. I might just have to go ahead and get the teensy2.

That's a sensible choice, you might otherwise take a leonardo (based on the atmega32u4) that should be compatible (maybe with very minor changes, like for the pins) with the code.

That program will make the arduino board act like a keyboard to the PC it's plugged in. This can't be done on the Uno, since it doesn't have USB support.

It actually can, given you change the atmega16u2 firmware for one that makes it behave like a keyboard.

@zmo you are correct. It's however quit involved, so I chose not to mention it.

@Gerben Its not that involved, as I've played around with UnoJoy which makes everything quite simple. I tried messing around with it to convert PWM from my RC Receiver so I can use it in games, but that's a whole other issue I'm having.

Generally, the differences between the different chips are mostly: amount of memory (sram, eeprom), number of pins (analog, digital, pwm), numbering of pins, and hardware support for protocols (serial, SPI, 2 wire etc)
In this case, you would have to go through the code wherever you find #IFDEF __AVR_AT90USBX2__ or #IFNDEF __AVR_AT90USBX2__ and the others - you would need to work out what it is doing differently for each, and work out how you would do the same thing on the Arduino Uno (which runs on an Atmega328).

I believe it defines what each pin is, what they do, and how they will be bound to the device. Which I would have to go through everything for the Uno's chips.


text:
Can I use IR Transmitter/Receiver for heart beat detecting?
Specifically, I want to know if the KY-022 module and KY-005 module can be used for heart beat detecting according to this tutorial?
KY-005:

KY-022:

If so, can you please explain to me how can I achieve such thing with respect to the following:
1- Is there any kind of synchronization between transmitter/receiver?
2- How to get a stable analog value from the receiver?
3- The Correlation between Heart beat rate and the obtained values?
providing circuit sketch will be very helpful but not necessary.
Thanks in advance.

If you watch the video and try to work out what you are seeing it should be clear. [No - the transmitter is simply an IR light source.] 2. No need for stability - look for local maxima and minima at frequencies that are "about   right".  An FFT of the signal may be useful but is overkill. 3. Did you watch the video? If so, watch it again. Look at the waveform on the oscilloscope. You are, of course, seeing the heart beat.

Tutorial link broken.

No, you cannot.  The sensor you link to has a circuit which attempts to detect IR light modulated at a specific frequency, and produces a digital output.   For a heartbeat sensor you need an analog output to feed into far more sophisticated signal processing - effectively the built-in processing gets in the way and means you cannot use it for this purpose.
Additionally, sensors of this type typically have an automatic gain control which means that they desensitize when subjected to continuous signal - they are designed for sources like remote controls where the modulation is itself pulsed on an off in small fractions of a second, so they interpret constant modulated light as noise and soon turn off their output.


text:
Arduino Due analog output has 500mV offset
I use a simple serial connection to tell the Due what to output into an analog output pin. However, the outputs are offset about 550mV (as seen on an oscilloscope) and the maximum value of 255 gives ~2.7V. What am I missing? Why can't the DAC output 0V - 3.3V mapped onto 0 - 255 values?
int output = DAC1; // analog output pin
String inData;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  while (Serial.available() > 0) {
    char value = Serial.read();
    inData += value;
    if(value == '\n'){
      val = inData.toInt(); // 0..255
      analogWrite(output, val);
      Serial.println(val);
      inData = "";
    }
  }
}

What is the voltage on VDDANA?

how do I check that?

With the black lead of the DMM on ground and the red lead on VDDANA, with the DMM in DC volts mode.

it reads about 4.2V, if by VDDANA you mean Vin pin. I don't know where to measure VDDANA otherwise

The datasheet for the MCU gives its pinout.

From the schematic, VDDANA is pin 73 on the actual chip.

is it a known problem? I am way from card for now, will update as soon as get back to work. If this is known problem, what are approximate solutions/something i can try?

I don't know how old this thread is, anyway I thought it doesn't hurt to give some insight because I experienced the same problem. Look at:
http://www.atmel.com/Images/Atmel-42187-ATSAM3X-and-ATSAM3A-Series-Checklist_AP-Note_AT03462.pdf
page 13: DAC0 and 1 voltage lays between 1/6 ADVREF and 5/6 ADVREF which corresponds to approximately ADVREF=3.2v; Span is (4/6)*3.2 = 2.1v
for periodic signals, Offset can be removed by using a small decoupling capacitor which will act as a high pass filter.
Hope this helps

Thank you for help! Numbers on atmega datasheet do make sense, they are close to what I see on oscilloscope.

int output = DAC1; // analog output pin
String inData;
int val;

void setup()
{
  Serial.begin(9600);

}

void loop() {
  while (Serial.available() > 0) {
    char value = Serial.read();
    inData += value;
    if(value == '\n'){
      val = inData.toInt(); // 0..255
      val=constrain(val, 543, 2720);
      analogWrite(output, map(val,543,2720, 0, 255));
      Serial.println(val);
      inData = "";
    }
  }
}

Hi and welcome. Please [edit] your answer and provide an explanation as to why your code works. Code only answers are frowned upon. Thanks.


text:
Why is my interrupt code not working?
Background
I'm trying to write code to read signals from a six-channel RC receiver on an Arduino Mega 2560. Currently I am keeping the code to just read one channel to make things easy to troubleshoot. The problem is my shared variable is not updating, leading me to believe that my interrupt service routine is not detecting any rising edges.
I thought my receiver was broken, so I tested it using the standard Arduino attach interrupt function. It worked perfectly, so my receiver is fine.
I used Serial.print() to see if my volatile channel variable was updating (that is, change its value to the channel 1 flag value). It was not updating, so my ISR must be wrong. You can find the original code in the blog post.
What's wrong? I'm out of ideas.
#include <PinChangeInt.h>

//Pin assignment
#define channel1PIN 10

//Bit flags
#define Channel1FLAG 1

//Flag holder
volatile uint8_t bFLAGUPDATESHARED;

//Shared variables: Accessed by the interrupt service routine and read in 'void loop'.
volatile uint16_t unCHANNEL1SHARED;

//Start time variables: These are used to set the start time of the rising edge of
//a pulse. They are only accessed by the ISR, and thus they are unsigned integers and
//not volatiles.

uint32_t ulCHANNEL1START;

void setup()
{
  Serial.begin(9600);
  Serial.print("RC Channel PWM Read Interrupt Test");

  //PinChangInt library function. Used to set attach interrupts.
  PCintPort::attachInterrupt(channel1PIN, calcCHANNEL1, CHANGE);
}

void loop()
{
  //In-loop variables to hold local copies of channel inputs.
  //This is static so it retains values between call loops.
  static uint16_t unCHANNEL1IN;

  //The in-loop copy of the bSHAREDFLAGUPDATE volatile flag holder
  static uint8_t bFLAGUPDATELOCAL;

  //Check to see if any channels have received signals. If so, copy
  //shared variables to local in loop variables.
  if (bFLAGUPDATESHARED)
  {
    //Switch off interrupts when I copy shared variables to local variables
    noInterrupts();

    bFLAGUPDATELOCAL = bFLAGUPDATESHARED;

    if (bFLAGUPDATELOCAL & Channel1FLAG)
    {
      unCHANNEL1IN = unCHANNEL1SHARED;
    }

    bFLAGUPDATESHARED = 0;
    interrupts();
  }

  Serial.println(unCHANNEL1IN);

  //Clear local update flags copy as all values have been copied to local variables
  bFLAGUPDATELOCAL = 0;
}

void calcCHANNEL1()
{
  if (digitalRead(channel1PIN) == HIGH)
  {
    //If pin goes high, start timer and set ulCHANNEL1START to timer start
    ulCHANNEL1START = micros();
  }
  else
  {
    //If it is not rising, it must be falling so set shared
    //variable to current time-start time
    unCHANNEL1SHARED = (uint16_t)(micros() - ulCHANNEL1START);

    //Tell that channel 1 has received a signal
    bFLAGUPDATESHARED |= Channel1FLAG;
  }
}

Try simplifying your code. Have the ISR light up an led, for example. I don't see anything inherently wrong.

I figured it out. For some reason, it only works on pins 10,11 and 12. I don't know why though. PinchangeInt should work on any digital pin

But you are using pin 10? Anyway; glad you got it working.

Only some ports on the Atmega2560 support pin-change interrupts, specifically ports B, E (bit 0), J (bits 0 to 6) and K.
Looking at the reference schematic that means that these pins on the board are supported:
     Chip
Name  Pin  Pin on board
-----------------------

Port B

PB0 - 19 - D53 (SS)
PB1 - 20 - D52 (SCK)
PB2 - 21 - D51 (MOSI)
PB3 - 22 - D50 (MISO)
PB4 - 23 - D10
PB5 - 24 - D11
PB6 - 25 - D12
PB7 - 26 - D13

Port E

PE0 - 2 - D0 (RXD0)

Port J

PJ0 - 63 - D15 (RXD3)
PJ1 - 64 - D14 (TXD3)
PJ2 to PJ6 - not connected on board

Port K

PK0 - PK7 - (89 - 82)  - A8 - A15

Thus you can see that D10 to D12, which you say works, are in that list. Other random ones would not be.

SoftwareSerial
You can see confirmation on the page for SoftwareSerial where it says:

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

This is because SoftwareSerial uses pin-change interrupts to detect incoming serial data, and thus the disclaimer on that page about which pins it will work with.

Atmega2560 pin-outs

PinchangeInt should work on any digital pin

Note that the Atmega328P (as used in the Uno) has less ports, and all are available for pin-change interrupts on that board.

This can't be right. The page first linked by OP claims pins 2, 3, 18, 19, 20, and 21 can be used for interrupts. These map to PE4, PE5, PD3, PD2, PD1, and PD0, according to https://goo.gl/DvHEUA  and https://goo.gl/xAwBGM For my part, I'm more concerne with whether PORTC can be used, as in ros_arduino_bridge: https://goo.gl/rq6yQO

The linked page refers to external interrupts however the OP is using pin change interrupts as you can see from #include <PinChangeInt.h>. The pin change interrupt pins are the ones I listed.

I see. I had an inkling that might be the distinction, but assumed that all pins capable of external interrupts would also be capable of pin change, though not the other way around.

On the ATmega1280/2560, only ports B, J, F, and K have pin change interrupt capability. These map approximately to pins 10 through 15, 50 through 53, and A6 through A15 (although part of port J is unmapped to Arduino pins, therefore PCINT11 through PCINT15 are unavailable on the Arduino Mega/Mega 2560).

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


text:
How to communicate the Arduino board with SIM900?
I have a problem. I bought a SIM900 board, but I can not connect there with the Arduino. To send AT commands on the serial the SIM900 doesn't respond, but the LED indicating that the network is on. I've tried to change the baud rate of 9600 to 19200 in the firmware of the Arduino, but it still fails. I think I'm having a problem with the connections of the SIM900, since this board strikes me as obscure (could not find the schematic on the Internet)
The board I have is identical to this:

I'm 90% sure that I am connecting to the wrong pins. But I tried to reverse the jumpers and even some soldered pins on UART.

Interesting... I have been looking a lot into the various GPRS/GSM/GPS boards available recently, using the SIM 900 or 908. I saw your board on eBay, and was quite interested, but in the end I decided to wait as I could not find any libraries for that particular board. Sorry, that is not much help to you.  I will have another search and see what I can come up with. :-)

If you are interested in a GPRS board, I recommend you buy EFCOM. I worked with her and never had problems. But I need to university research, and takes a long time to get to Brazil, not to mention the price, the dollar is costing R$ 3.22 :( ($1 Dollar =  R$ 3,22 Real) link ebay. There is a saying for this here in Brazil: "The cheap is expensive"

I managed to solve the problem. I connected the ground of SIM900 the Arduino ground. It worked for me :)

Excellent news! You should answer your question by posting the solution, with maybe a photo or diagram of the boards pins that needed connecting, and then marking the question as answered... It will probably help  someone else. :-)

I'll tell you what worked for me, because I didn't find the schematics of this board. But your board may work differently, so it is always good to check the datasheet and the schematic (if you have one).
Power
Be sure to use an external 5V source that can supply up to 2A without dipping significantly.
Code
#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);         //7 = TX, 8 = RX
unsigned char buffer[64]; port
int count=0;
int i = 1;                         //if i = 0, send SMS.
void setup(){
  //delay(10000);
  GPRS.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);             // the Serial port of Arduino baud rate.
  Serial.print("I'm ready");
  Serial.print("Hello?");
}

void loop(){
  if (GPRS.available()){         // if date is comming from softwareserial port ==> data is comming from gprs shield

    while(GPRS.available()){          // reading data into char array
      buffer[count++]=GPRS.read();     // writing data into array
      if(count == 64)break;
    }
  Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port
  clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
  count = 0;                       // set counter of while loop to zero
}

if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook
  GPRS.write(Serial.read());       // write it to the GPRS shield
  if(i == 0){
    GPRS.print("AT+CMGF=1\r"); //sending SMS in text mode
    Serial.println("AT+CMGF=1\r");
    delay(1000);
    GPRS.print("AT+CMGS=\"+554988063979\"\r"); // phone number
    Serial.println("AT+CMGS=\"+554988063979\"\r");
    delay(1000);
    GPRS.print("Test\r"); // message
    Serial.println("Test\r");
    delay(1000);
    GPRS.write(0x1A); //send a Ctrl+Z(end of the message)
    delay(1000);
    Serial.println("SMS sent successfully");
    i++;
  }
}

void clearBufferArray(){              // function to clear buffer array
  for (int i=0; i<count;i++){
    buffer[i]=NULL;                  // clear all index of array with command NULL
  }
}

Connection

Testing...
Open the serial monitor Arduino, set the baud rate in 19200 in "Both NL & CR". If not work, set to "Carriage Return". Type "AT" and wait for an OK.

Help
If you need help, these links were useful to me:

http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0
http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0
http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield

A 1A external supply is questionably insufficient, unless there's a lot of capacitance on the module itself to handle GSM pulseloads.

Is the USB connection from the laptop sufficient?


text:
I2C TinyWireS SEND: How to convert unsigned long to uint8_t array?
How do you convert an unsigned long to a uint8_t array? I am interested in sending an unsigned long integer from an ATTiny85 to an Arduino Uno via I2C. The issue is with TinyWireS.Send() which can only send a var of type uint8_t. I believe the solution would be to use TinyWireS.Send() in an array?

This might not be politically correct code, but it is pretty simple to just cast a pointer to uint8_t like this:
long data = 5;
uint8_t *rx = (uint8_t*) &data;

You can still use array subscripts even though its a pointer, and you can pass it to a function like an array. Just don't go past rx[3].
Alternately, you could also make a union like this:
union{ long data; uint8_t bytes[4]; } convert;
convert.data = 5;

And then use convert.bytes as your array to send.

I do exactly this with an ATtiny You have 32 bit long that needs to be broken up into 4 8-bit chunks. You need to some simple bit shifting to accomplish this.
volatile unsigned long Data1;//this is the data you are sending
volatile byte SendCount;
volatile uint8_t sendByte;

void requestEvent()
{

  SendCount++; //increment this
  switch (SendCount)
  {
    case 1:
      Data1 = GetMyData();
      //Data1 = 55555;
      sendByte = Data1 & 0xFF;
      break;
    case 2:
      sendByte = Data1 >> 8;
      break;
    case 3:
      sendByte = Data1 >> 16;
      break;
    case 4:
      sendByte = Data1 >> 24;
      SendCount=0;
      break;
  }

  TinyWireS.send(sendByte);
}

You need to initialize SendCount = 0; in your Setup method.
You will need to recompose the 4 bits back into a 32 bit long on the Master device too.


text:
Arduino Uno - combined LCD and keypad interfacing problem
I have a problem with the Arduino Uno.
I need to use a 4x3 keypad and 16x2 LCD together with an Arduino Uno. As 4x3 keypad requires 7 pins, I have defined pins 2, 3, 4, 5, 6, 7 and 8 to it. A 16x2 LCD requires 6 pins but only 5 pins remain (9, 10, 11, 12 and 13). Pins 0 and 1 are used for serial.
Please suggest a probable solution.

Welcome to Arduino SE! What exactly is your issue? Pin assignment? Please edit your question to reflect exactly what you need. Thanks!

You could use a shift register to read the switches as outlined by the excellent tutorial Parallel to Serial Shifting-In with a CD4021BE. Quoting the summary:

Sometimes you'll end up needing more digital input than the 13 pins on
  your Arduino board can readily handle. Using a parallel to serial
  shift register allows you collect information from 8 or more switches
  while only using 3 of the pins on your Arduino.

So you would only use 3 pins to read the seven switches, which would leave you with 9 pins to play with, for the LCD.
In addition, you could use a similar method for the LCD, using a shift-out register, and use just 3 pins for the 6 inputs of the LCD. A tutorial for that is Alphanumeric LCD with Shift Register on Arduino – part 1, using the AlphaLCD library or 3-Wire Serial LCD using a Shift Register, which has no library, but provides code.
This would leave you with 6 pins free (out of the total 12 pins, if you exclude pins 0 and 1 for serial), after both the switches and LCD are wired up.
Of course, this solution requires you to purchase one or two shift (in and/or out) registers.
The Arduino IDE may come with a built-in library that use shift registers, but I am not sure about that. Maybe someone can confirm, or refute, this?
I hope that this helps.

Is there any tutorial for LCD and CD4021 using Arduino LCD Library?

@xcoder - I've updated my answer.

Am new at this but I am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).
As for the LCD I would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)
Try the code below for the keypad (The code is if you have an i2c backpack)
#include <Wire.h>
#include <Keypad.h> //keypad library
#include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads
  char hexaKeys[COLS][ROWS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
  lcd.begin(16,2);
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();  delay(250);
    lcd.noBacklight();  delay(250);
  }
  lcd.backlight();
}

void loop(){

  char customKey = customKeypad.getKey();

  if (customKey){
    lcd.print(customKey);
  }
}


text:
Storing in a global variable using inline assembly
What I'm trying to do is pretty basic: I have a global variable and I'm trying to store some value in it (specifically, the SP_H and SP_L values).
The variable is an array of structs and I'm trying to access one of those structs.
This is what I am doing:
typedef struct_t { uint8_t sp_h, sp_l; } struct_t;

struct_t arr[MAX_STRUCTS];

void some_inline_assembly_function()
{
  volatile asm(

  // Determine where to store the new SP_H and SP_L register

  "lds r26, ???                \n\t" // <-- How do I store the address
                                            of arr[0].sp_h or arr[0].sp_l
                                            in the X registers (r26,27)
  "lds r27, ???                \n\t"

  // This part stores the stack pointer low and high byte indirectly
     using the X registers (r26,27), which is what I want.

  "in    r0, __SP_L__          \n\t"
  "st    x+, r0                \n\t"
  "in    r0, __SP_H__          \n\t"
  "st    x+, r0                \n\t"
  ::);
}

If this looks familiar, it is because it probably is. I'm trying to implement simple context switching (pushing the entire task context into the stack and retrieving another one). What I'm trying to accomplish is storing the current PC_H and PC_L to a global variable so that the "shceduler" knows where to start popping the registers and restore the context.
Yes, I know FreeRTOS does this. I need to know how to do this myself.
Thanks a bunch.

Did you try to just use arr in the assembly?

I've just seen people pop the registers onto the stack in a particular order, and then change the stack pointer(s) to another stack.

Probably a stupid idea, but why not write it in C, compile it, and run avr-objdump -S  against the elf file, and see how the C compiler does it.

The address you are looking for is a symbol known by the linker. Then
you can have the linker put the value of the symbol straight into your
code: no need to load from memory. In other words, you use the ldi
instruction to load the required address as an immediate value. You
should also reverse the order of the struct definition, since you are
storing SPL at the lowest address.
typedef struct { uint8_t sp_l, sp_h; } struct_t;

struct_t arr[MAX_STRUCTS];

void some_inline_assembly_function()
{
  asm volatile(
    // Determine where to store the new SP_H and SP_L register
    "ldi r26, lo8(arr)     \n\t"  // X is loaded with the symbol arr
    "ldi r27, hi8(arr)     \n\t"  // which is the address of arr[0].sp_l
    // Here you may want to add 2 * an array index.

    // This part stores the stack pointer low and high byte indirectly
    // using the X registers (r26,27), which is what I want.
    "in    r0, __SP_L__    \n\t"
    "st    x+, r0          \n\t"
    "in    r0, __SP_H__    \n\t"
    "st    x+, r0          \n\t"
  ::);
}

Notice the lo8() and hi8() assembler macros: they split the address
into low and high bytes. Actually the assembler translates them into
R_AVR_LO8_LDI and R_AVR_HI8_LDI relocations records, and the
linker does the real job.
Edit: I think I just realized why you were thinking of using lds
in the first place...
Instead of using array indices, you may want to access the array through
a pointer (declared struct_t *pointer). When programming in C or C++,
a pointer identifier behaves, for most purposes, just like an array
identifier. However, at the assembly level, using a pointer involves an
extra indirection, as you have to read the contents of the pointer from
RAM. In this case you would indeed be using lds instructions:
; Copy the global 'pointer' into the X pointer register.
lds r26, pointer    ; low byte
lds r27, pointer+1  ; high byte

As a side note, if you are programming in C++, then you have to declare
extern "C" any identifier that you want to use both in C++ and in
assembly. Otherwise the C++ compiler will
mangle its name and you
would need to use the mangled name in the assembly source.


text:
Yun - replaced uhttpd with lighttpd - luci works but not /data access..?
Ok, utthpd is running on port 80 and lighttpd on port 81...both give access to the luci control panel...all well and good.
However the /data access to the yun data store only works from uhttpd.
Lighttpd returns error 404 (page not found).
Any idea what the solution might be..?