text:
Does Proteus simulate external interrupts properly using Arduino? I can't get them to work
I am trying to simulate an interrupt with an Arduino Uno in Proteus. This is the simple test code that I'm using:

void introutine()
{
  digitalWrite(13,HIGH);
}

void setup()
{
  pinMode(13,OUTPUT);
  attachInterrupt(2,introutine,LOW);
}

void loop()
{
}

Here's the circuit in Proteus:

When I hit the button, the LED is supposed to turn on. Well, nothing happens. I have read something about Proteus being bad at simulating interrupts, but I'm not sure about it because Timer1 interrupts did work well. Basically, the problem lies within EXTERNAL interrupts only. I hope you people can help me.
Thank you.

NOTE: the node between R5 and the button says IO13 because I forgot to undo that. Suppose it says IO2, and still it will not work.

Why do you have mode LOW in attachInterrupt instead of RISING?  Also, instead of putting some kind of correction about IO13 vs IO2 in a comment, please edit that info into the question.  Also, the phrasing  “Suppose it says IO2, and still it will not work” asks us to imagine it doesn't work when you correct the pin number.  Rather than asking us to imagine that's the case, why not go ahead and test it and then edit the question to say what the effect of the change was?


text:
Power problems stacked Arduino shields
I have a weird problem. I am currently building a BB-8. Therefore, I am using an Arduino Uno. On top, I have stacked an Adafruit Motor Shield v2.3 and, again, on top of this, I have stacked the Sparkfun USB Host Shield. The Arduino is powered by a 9V-Block battery, the motors are powered separately by two 18650 Li-Ion batteries. To control the two Pololu motors, which have a stall current of 1.6 amps each, I use a Xbox 360 wireless controller, where the receiver is connected to the USB Host Shield.
Now to my problem. Every seems to work fine, until i cover everything with a styrofoam hemisphere. Yes, you've read right. If that happens, the controller signals is lost and does not connect again, unless I restart the Arduino. I have uploaded a small video on youtube, where you can see the problem.
I guess, this is a power problem, since this issue does not occur, when I connect the Xbox receiver to my Mac. Has anyone an idea, how to solve this problem?
I already tried another power source. And the USB host shield should give enough power, since the specs are saying, that 500 mA is no problem, and hit is exactly the USB 2.0 spec. The combination of the shield shouldn't be a problem, too. I carefully chose this shields, because the motor shield is just using the pins A4 and A5, the USB host shield is using some of the digital pins, so I think there is no interference.
Thank you for your help.
EDIT
I have tested it a bit more now and i think i can reduce the probable reasons. First, i tried some other power supplies, from AA batteries on the VIN pin to external power adaptors. Next, i tried other xbox receivers and controllers. I also tried a playstation 3 controller with a Bluetooth dongle. Nothing solved the problem. I also covered the Arduino with other things than styrofoam, like a garbage can, cardboard and some metal box. This worked, so the problem was only with styrofoam. Now i haven't covered the Arduino, but i slowly got closer. About 20 cm from the Arduino, it stopped working. My clue: static electricity. Do you think this can be a problem? And if yes, how can i solve this?

So, I solved the problem. As is mentioned in my question, the problem was static electricity. I primed the styrofoam sphere with some special primer to make the styrofoam a little more stable and so on. That's it. Luckily I didn't touch the Arduino with the sphere. I think it would have damaged the Arduino.

Those 9v batteries are not known for their ability to supply current. Their best uses are long-term powering of low-current standby devices like smoke detectors. I'd first try replacing it with 4 double- or triple-A cells, whatever you can scrounge up for a quick test. My guess is when you cover the robot the Xbox receiver's current demand increases just enough to crash or reset something. A-cells may supply enough more current without the voltage sagging.

Thanks for the reply, i heard this before. I will check as soon as possible and give an answer.

source: Stack Exchange

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

sort: votes


text:
Arduino micro lost connection after first programming
I have just programmed a new micro, loaded the basic blink code in it. After that neither my laptop, nor my desktop sees it anyway with the following usb error:
Fri Apr  1 14:32:01 2016] usb 1-2: device descriptor read/64, error -62
[Fri Apr  1 14:32:01 2016] usb 1-2: device descriptor read/64, error -62
[Fri Apr  1 14:32:02 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd
[Fri Apr  1 14:32:02 2016] usb 1-2: device descriptor read/64, error -62
[Fri Apr  1 14:32:02 2016] usb 1-2: device descriptor read/64, error -62
[Fri Apr  1 14:32:02 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd
[Fri Apr  1 14:32:03 2016] usb 1-2: device not accepting address 8, error -62
[Fri Apr  1 14:32:03 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd
[Fri Apr  1 14:32:03 2016] usb 1-2: device not accepting address 8, error -62
[Fri Apr  1 14:32:03 2016] usb 1-2: USB disconnect, device number 8
[Fri Apr  1 14:32:03 2016] usb 1-2: new full-speed USB device number 9 using ohci_hcd
[Fri Apr  1 14:32:04 2016] usb 1-2: device descriptor read/64, error -62
[Fri Apr  1 14:32:04 2016] usb 1-2: device descriptor read/64, error -62

If I push the reset button on it it comes back a bit then disappears again:
22620.495256] usb 1-2: New USB device found, idVendor=2341, idProduct=0037
[22620.495263] usb 1-2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[22620.495268] usb 1-2: Product: Arduino Micro
[22620.495272] usb 1-2: Manufacturer: Arduino LLC
[22620.497393] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[22627.966141] usb 1-2: USB disconnect, device number 32
[22628.432089] usb 1-2: new full-speed USB device number 33 using ohci_hcd
[22628.572111] usb 1-2: device descriptor read/64, error -62

Anybody experienced this? I have tried to reconnect it multiple times to both computers, even tried a new cable doesn't help.

the AVR chips can be programmed via spi and sometimes serial, which means not via usb, if you get in a state where the usb is not usable.  you may be at or close to that state.

This means, you have not enough power on the USB bus. What does your sketch do? Are there any devices attached to the Arduino? Did you check with another cable?

Single processor for sketches and USB communication. The Leonardo and Micro differ from other Arduino boards in that they use a single microcontroller to both run your sketches and for USB communication with the computer. I don't see what else would you need to put into the basic blink example, if there is something board specific the compiler should put that in not you.

the AVR chips can be programmed via spi and sometimes serial, which means not via usb - that's not correct. The Micro has a USB interface and is intended to be programmed by it.

The USB part of the Atmega32U4 needs quite a bit of software to operate correctly, which is either not included in the basic blinky example or you got a binary for a different Arduino model.
The syslog looks like there is a bootloader present after Reset for a couple of seconds..
[22620.497393] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
     ^
[22627.966141] usb 1-2: USB disconnect, device number 32
     ^

.. which shuts down and starts blinky. This is documented on the ArduinoBoardMicro page.
Re-flashing the chip is a bit tricky in this state, as you must press the reset button at the "right" time just before the software wants to access the chip.

If I push the reset button on it it comes back a bit then disappears again:

That's exactly how it works. The Micro enumerates as a Serial interface for a couple of seconds after reset, enough time for you to upload a new sketch. If you don't upload in time, and unless your code specifies a serial port, the serial interface goes away. Blink doesn't use a serial port.
You need to quickly press and release Reset at the exact moment that the IDE says it is uploading, and the board should then detect the new sketch.

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


text:
digitalPinToInterrupt() doesn't work

I am working on a protection circuit with 2 raindrop sensors which would be hooked onto the arduinos 2 interrupt pins and as soon as they detect water they shut some relays off, turn a red led on and exit() the main program.
These sensors I have order are working fine as regular input pins with the following code:
// lowest and highest sensor readings:
const int sensorMin = 0;     // sensor minimum
const int sensorMax = 1024;  // sensor maximum

void setup() {
  // initialize serial communication @ 9600 baud:
  Serial.begin(9600);
}
void loop() {
  // read the sensor on analog A0:
    int sensorReading = analogRead(A0);
  // map the sensor range (four options):
  // ex: 'long int map(long int, long int, long int, long int, long int)'
    int range = map(sensorReading, sensorMin, sensorMax, 0, 3);

  // range value:
  switch (range) {
 case 0:    // Sensor getting wet
    Serial.println("Flood");
    break;
 case 1:    // Sensor getting wet
    Serial.println("Rain Warning");
    break;
 case 2:    // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below.
    Serial.println("Not Raining");
    break;
  }
  delay(1);  // delay between reads
}

I will use the digital output not the analog but this doesn't change much. For the digital the pin is up at 5V at start and will be put to LOW once water is detected by the sensor.
I using the mega right now for breadbording but micro will be the final board.
Both the mega+micro should have 2,3 as interrupt pins:
Mega, Mega2560, MegaADK 2, 3, 18, 19, 20, 21
Micro, Leonardo, other 32u4-based   0, 1, 2, 3, 7

I have modified the following code and tried all conditions:
LOW to trigger the interrupt whenever the pin is low,
CHANGE to trigger the interrupt whenever the pin changes value
RISING to trigger when the pin goes from low to high,
FALLING for when the pin goes from high to low.

It doesn't respond to any (the same time as I said the pin works fine as regular input).
Here in the setup I know that I am not using
attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);

but
attachInterrupt(interruptPin, myISR, FALLING);

that is because the IDE doesn't recognize this function. Is there any problem with the code? If I understand interrupts correctly I don't even need to check for that if ( ISRRan ) to break off the while loop, once the interrupt comes in the ardu SHOULD be running my interrupt function and immediately run the protection code then abort.
byte interruptPin = 0;  // your interrupt pin
volatile boolean ISRRan = 0;  // this variable is set in your ISR to trigger a break in the while loop
byte C = 0;  // this is just the counter var for the while loop

void setup() {
 attachInterrupt(interruptPin, myISR, FALLING);
}

void myISR() {
 ISRRan = 1;
 // do other things in the ISR
}

void loop() {
 while ( C < 10 ) {
   if ( ISRRan ) {
     break;
   }
   //doing something inside the while loop
 C++;
 }
 // do other things outside of the while loop
 ISRRan = 0;  // Reset for whatever reason
}

Where your period definition ? Which hardware allow rapid communication ? C++ set a period, mean clock_time x count. You haven't any data when scanning counter on count. Use a lot delay for prepare device + communication. 9600 rate need minimal 0.3 second delay(mean 300 milisecond)(of course can use less delay value but lost a lot data !)

You could rework without interrupts. Rain doesn't exactly start and stop within a millisecond. Just test the sensor in your main loop.

https://www.arduino.cc/en/Reference/AttachInterrupt has some hints on mapping pins to interrupt numbers, if digitalPinToInterrupt(pin) doesn't work.

I have solved this.
The problem was with the pinout indeed.
attachInterrupt(0, myISR, FALLING);

will use the DIGITAL PIN 2
I was using attachInterrupt 2, that's all.


text:
Can't figure out how to distribute the power
so I'm making a project, kind of BB-8 droid replica, and I stumbled upon a problem. Since I am using two RC brushless motors, ESC's and batteries, I want to make my Uno board fed up from those batteries. Also, I want to use inductive charging set that would charge both batteries. Can anyone tell me or give some kind of scheme how should I distribute the power from batteries and what additional boards should I buy?

Comments are not for extended discussion; this conversation has been moved to chat.

The best option is to connect the 5V/2A output of the UBEC to the 5V pin on the Arduino. In my experience, 7.4V is not enough to feed into the input jack on an Arduino especially if it is from a battery, as the voltage will drop when current is being drawn by other loads. I have built an Arduino controlled robot using a 6V NiMH battery and brushed DC gearmotors (so no ESCs or UBEC) and used a $5 5V 1A step-up/step-down converter so that even if the battery voltage dropped below 5V, it could still power the board. However, since you have a UBEC that is not in use, use it. Note that if you put voltage into the 5V pin, disconnect it when you are connecting the arduino over USB or you might damage your board.
As for inductive charging, I don't know of any off-the-shelf solution designed for charging a 2S lithium ion battery. The best option for charging would probably be an easy way to open the ball to access the batteries.

About that problem You wrote in bold I had already known since I tried programming my ESC.

EDIT
I agree that opening and then charging would be the best choice but I'm making this as a gift and not much people have Li-ion chargers laying in their houses :D so the idea is to make it like Sphero BB-8 which is with inductive charging system. I found something in adafruits page https://www.adafruit.com/products/1407 which might work just fine because it would really fit into my project. The problem is that I would need a board that would take power from inductive set to charge the batteries... but any sketch I  have made is messed up and I don't want to try anything that I don't get it.

That inductive charging system is only capable of 5V at 500mA. You could easily step this up to charge a 6V or 7.2V NiMH battery as they are relatively forgiving about charging conditions, but it would probably be difficult (as well as dangerous) to try to charge a 2S LiPo this way.


text:
DVD drive stepper motors with polulu a4988 on Arduino
I am new to arduino, I started learning about it today and i'm stuck. I ripped out a small stepper motor from an old DVD drive. I got a polulu a4988 driver and I have wired it up as follows:

/*     Simple Stepper Motor Control Exaple Code
 *
 *  by Dejan Nedelkovski, www.HowToMechatronics.com
 *
 */
// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;

void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000); // One second delay

  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}

But nothing happens, the motor doesn't even vibrate. Any idea what could be wrong?

Check the data sheet and see if you can truly leave all of those pins on the left side unconnected.  Additionaly, you need the /sleep pin high - you seem to be hoping there is a /pullup resistor on the reset line which will accomplish that for both of them?

According to Pololu's website, the VMOT pin needs at least 8V to function. Try a 12V switching (important!) wall wart supply that can supply at least 1A instead of your USB supply. Avoid supplies that can deliver currents >3A, as they are overkill for a small stepper motor and can be dangerous if shorted. Be sure to put a large (100uF is good) capacitor across that supply to prevent voltage spikes. To prevent damaging the motor from the higher voltage, follow the information Pololu provides on setting the current limit and set it to about 350mA. If you notice the motor is too hot to touch, try 200mA.

thank you! I found a psu for an external hard drive which outputs 12v and 2A. Would this be suitable?

That is almost definitely a switching supply and it should be suitable. Make sure that you pay attention to the polarity when hooking it up.

Great, thank you. I still haven't got it to work, my arduino switches off for some reason. Not sure why though.

I recently bought one of these and it had an internal short from the STEP pin to ground. This caused my Arduino to shut off too. Check all the pins connected to the Arduino with a multimeter to see if there are any shorts to ground, VCC, or VMOT. Post a picture of your soldering and wiring too. The Arduino should not be shutting off if this is wired correctly

Oh I see, i'll do it as soon as i get home tomorrow! thanks for your help, I really appreciate it :)

It turns out my arduino is fried. Not sure when/how that happened. I ordered a clone now and i'll try it again and see if it works! Thanks for your help

Is it the entire arduino or just one of the pins connected to the A4988?

Before you connect it to the arduino, connect the motor, hook up VMOT and its ground pin to your 12V supply, connect Vcc and its ground pin to your USB 5V supply, connect RESET to SLEEP, connect DIR to Vcc, put a 10K resistor from STEP to GND, and wire a pushbutton from STEP to Vcc. Turn on the power supplies and press the pushbutton. If the motor does not move, it could be that the motor is wired incorrectly (likely), the motor is defective (unlikely) or the A4988 module is damaged (somewhat likely). If you can't get it working in this configuration, contact Pololu customer service.

authors: مصمم الدواسر


text:
Arduino Serial Monitor works but not on PySerial and PuTTY
I made simple custom arduino board using an atmega328p and the PL2303 serial to USB chip.
In my arduino program, I am in a loop that sends out a string continuously. I can read this in the Arduino serial monitor with a baudrate of 9600. However, in my python program using the pySerial library, the readline function doesn't return anything. I checked using PuTTY but it still doesn't do anything.
Now I tried messing with the serial settings and found out that these lines of code work (the readline returns the string) if I call it in the exact same order.

ser = serial.Serial(comm_port)
ser.xonxoff = True
ser.rtscts = True
ser.dsrdtr = True
ser.readline()

However, the code below doesn't work
ser = serial.Serial(comm_port, xonxoff=True, rtscts=True, dsrdtr=True)
ser.readline()

What could be causing this? My guess is somehow I've switched the datalines in my USB cable and that the arduino serial monitor handles this somehow.
Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer.

I wrote a python application which communicated with an arduino and for some reason I had to insert a delay after opening the serial for it to work correctly, if I didn't the first data I sent would always get dropped. Perhaps that's what's occuring here? Setting the attributes of the serial connection like that is probably slower than doing it in initialisation.
For myself I found that a delay of 3 seconds was what I needed for it to work 100% correctly on all computers (on some a second was enough). You only had to wait after opening it once open it worked fine.
To do a delay import the time module and use the sleep function which takes an argument of seconds.
import time

time.sleep(3)

Also worth noting depending on your application it's worth setting a timeout value for the serial that's appropriate or just keeping it open with the timeout paramter.
 ser = serial.Serial(com, 115200, timeout=0)

If you do this make sure to close it when you finished with it though (I personally used a try finally block which makes sure its always closed).
try:
  ser = serial.Serial(com, 115200, timeout=0)
  #go nuts with whatever communicating your doing
finally:
  ser.close()

I'm afraid I can't really tell you what caused the issue though. I also realise that this question is quite old so I hope my answer is still helpful, if not to you then to someone else who stumbles across it. To note for future the people on the official Arduino forum may be of more help for arduino related questions in general.

The delay before it is ready is almost certainly caused by the auto reset on serial open behavior and the subsequent bootloader timeout.

Yes, try connecting to the RX/TX pins instead.

"Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer." sounds like your atmega328p does not have a bootloader. Or the PL2303 does not have the correct driver.
I never used PL2303, but I have used FTDI USB TTL (ft232r) adapters. When I first used the adapter, my Windows computer installed the wrong driver for the adapter and I had to manually download the correct firmware from the FTDI website and install it manually. You can check if the driver is correct in the device manager, the author of the driver should be the manufacturer's name (not Microsoft).

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


text:
error: invalid conversion from 'char' to 'char*' [-fpermissive]
I have written a simple code to read data from capacitive keypad and display it on LCD.
I am getting the data from keypad in following data structure.
char phoneNumber[PHONE_DIGITS];

and then displaying the data on LCD as
   LcdString(phoneNumber[i]);

where my LCD string function is
void LcdString(char *characters)
{
  while (*characters)
  {
    LcdCharacter(*characters++);
  }
}

There is a type cast error

error: invalid conversion from 'char' to 'char*' [-fpermissive]

How can I debug it?

You're calling your function with a single char, specified by phoneNumber[i], but your function is expecting an array.
If you change your call to:
LcdString(phonenumber)

then that will pass the entire array.
Are you trying to say that you're storing multiple phone numbers?  i.e. a two dimensional array?  Check out the String reference for more details: https://www.arduino.cc/en/Reference/String


text:
arduino teensy no true HI-Z available?
I am using this https://github.com/watterott/SilentStepStick stepper driver to drive a stepper motor.
I am having trouble setting pins to HI-Z/floating to configure the stepper driver.
To set the driver to 16 micro steps and full interpolation, one has to set 2 configuration pins to HI-Z/floating (datasheet, p.9).
The example code on github (TMC2100.ino) just doesn't touch the pins at all, this works fine for me.
However, if I only add the lines:

pinMode(11, INPUT);  //connected to CFG1
pinMode(10, INPUT);  //connected to CFG2

which should set the pins to HI-Z/floating, the result is different.
The motor turns at the same speed, but makes more noise, I believe the driver is using the 16 step method with no interpolation. This corresponds to both pins being interpreted as high.
This makes me believe, that the Arduino uses a different code at startup than being used in pinMode(x, INPUT) to configure all pins. I am using a Teensy 3.1/3.2.
How can I solve the problem? Pins 11 and 10 are hard wired to the driver, as it replaced the well known A984.
Apart from the obvious "don't configure the pins then", I would like to know what's going on here.

Examine your circuit for possible pulling resistors.  Check the Teensy code details or look up and directly query the relevant raw kinetis gpio configuration registers.

If there were any pulling resistors, then it should not work when the pins are not configured in code.

Then check the implementing code for the function you are calling and raw register values, or move this to the PJRC support forum.

The Teensy has internal pull-up/pull-down resistors which can be enabled or disabled through software, see e.g. p. 231 here. You may want to check the "pull enable" (PE) bit in PORTx_PCRn.

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


text:
How can I maintain PWM output while still performing other tasks?
I want to generate a PWM signal that I can turn on and off with a button press without using interrupts.  Is there a way to keep the PWM output going while running other processes?

PWM just runs once started. It's all managed by a completely separate bit of silicon inside the chip.
Once you have done analogWrite(...) the PWM will just keep going until you tell it otherwise.

I was running this with Serial plotter yesterday and for some reason it kept interrupting the PWM when I was reading one of the analog channels.  I finally tested on an oscilloscope and it does work. Thanks!


text:
Using Blynk to control stepper motor is jerky
I am using Blynk to try and control a 28byj-48 stepper motor using the ULN2003 driver and an Arduino UNO from my iphone via USB withe the iOS Blynk App.
Without using Blynk, my stepper is smooth and works fine:
  #include <Servo.h>
  #include <Stepper.h>

  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,
  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
  const int motorpin1 = 8;                    //Assign motor  pins to Arduino pins
  const int motorpin2 = 9;                    //
  const int motorpin3 = 10;                   //
  const int motorpin4 = 11;                   //

  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4
  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);

  int pos = 0;    // variable to store the servo position

  void setup() {
    myStepper.setSpeed(600);
  }

  void loop(){
     myStepper.step(-500);
  }

But when I use Blynk, the stepper is so jerky and stutters terribly:
  #include <SoftwareSerial.h>
  SoftwareSerial SwSerial(10, 11);
  #define BLYNK_PRINT SwSerial
  #include <BlynkSimpleSerial.h>
  #include <Stepper.h>

  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,4-step mode
  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
  const int motorpin1 = 8;                    //Assign motor pins to board pins
  const int motorpin2 = 9;                    //
  const int motorpin3 = 10;                   //
  const int motorpin4 = 11;                   //

  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4 blah blah
  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);
  char auth[] = "my auth key here";

  void setup(){
    SwSerial.begin(9600);
    Blynk.begin(auth);
    myStepper.setSpeed(600);
  }

  BLYNK_WRITE(1){
    myStepper.step(param.asInt());
  }

  void loop(){
    Blynk.run();
  }

I am using a slider on the app to control the stepper by the way. I am not sure what I am doing wrong, any suggestions?

Blynk runs over a network and therefore cannot respond in real-time nor consistently. You could have the Blynk slider control set a local variable which the motor controller would use for motor speed, but the basic motor-drive timing needs to be locally controlled and independent of network operations. The SimpleTimer library is one way; a timer interrupt would be another.

Ah I see, I'll look into the library and try come up with a solution! Thank you so much.

My guess would be you are suffering from a comms latency issue.

Are you using a local server or the cloud?
Is you iOS device connected over WIFI or 2G, 3G or 4G?
Is you device on the same subnet as you iOS device and local server?

I've never used blynk (I might do this weekend though), my best thought as to how to fix it would be to revise your approach.  When you are controlling devices over an unpredictable connection (Ethernet) you can't rely of messages to arrive in a certain order or at certain times.  You need to tell the device to do something and keep doing it until its done or its told to stop.
So in this case tell the device to rotate clockwise at a certain rate until it travels n degrees or it is told to stop.  Now you can't just tell the motor to make 20 turns, because that will make your app unresponsive.  What you need to do it tell it to turn 50 steps and then return to the control loop, if no new order has come in it should then go and do another 50 steps, if there is a new order then off it goes with the new task.
Hope that makes sense and helps.

Great! I have a better understanding of the cons when it comes to my current setup now. I am using the cloud and my iOS connection is independant of my PC's internet connection (connected to Arduino). My servo motors however work almost instantaneously and without any issues! I might have to consider swapping out my stepper for a servo which in my case would also work fine. I hadn't thought about using control loops, i'll definitely give it a go! I just started using Blynk yesterday and it seems absolutely awesome so far. Thanks for the help!


text:
My Arduino is heating up
I am working on a simple Arduino project where I am controlling 5 TowerPro servos. I read that each takes up 2.2 V each so that means the Arduino can only handle about 2 , if using 5V. So far Ive connected 4 with no issues but when I added the 5th the whole thing stopped and the 5V regulator was really hot. That means I don't have enough power and the Arduino is just having a hard time giving not enought volts for all five servos. I just don't know what to do now. Ive tried adding 3  3V battery packs instead of the Arduino but it was smoking. Is there another way to provide the right amount of power for 5 servos without breaking or burning anything!

You need to determine how much current is required too, it's not just the voltage that matters. Can you show a schematic of how things are currently connected?

I suggest going back to read the basics about voltage and current, especially the part about parallel circuits. You seem to be confused about quite a few things. That said, without any sort of data about the servos or the circuit connections I doubt anybody will give an answer that you're happy with

Don't power the servos from the Arduino.  Power them separately, and only connect the ground and control signal lines to the Arduino.

I read that each takes up 2.2 V each so that means the Arduino can only handle about 2 , if using 5V - that doesn't mean you can power two 2.2V servos from 5V. It doesn't work that way. Can you edit your question and include a link to the servos and preferably the datasheet?

The voltage regulator on the Arduino is designed to power the logic circuits, and perhaps a few LEDs and other digital devices. It is not designed to power 5 motors.
You haven't specified what current they draw - that is the important question, not the voltage.
As the comments under your question have said, you need to power the motors separately from the Arduino, not through it. However, connect the ground wires, and use the Arduino to control the signal wire to the servos.
The graphic below shows the general idea. For 5 servos even those batteries are probably not enough.
Notice that the power for the motor does not go through the Arduino.


text:
Arduino with wifi shield and 5AA batteries current draw
Arduino uno with official Wifi Shield take 5 Volts.
Arduino lights up as it should when powered but the WiFi shield is dead the l9 doesn't light up but works fine when arduino is connected to usb cable.
I use 5 battery holder 5x1.5V = 7.5 V ; 2000 mAH
50 mA - Arduino
300 mA - WiFi shield

350 mA * 5h = 1750 mAh

5xAA = 7.5V ; 2000 mAh

Am I missing here something? It should last in the worst case scenario 5 hours with new batteries at 2000 mAH (which I think they have more but I do not have them on me right now).

We are not the arduino help desk.

@OlinLathrop I'm asking if I did the calculations correctly? if that makes sense

Ignore Olin. He's stuck in the fifties.

What does the 5V rail show when on batteries and the wifi shield connected?

@Passerby I wish I had access right now to all the equipment I'm a student I'm using it all at lab so I just wanted to know if my calculations made sense. I will retry tomorrow with fresh batteries and do all sorts of measurements.

Your calculations are missing the essential issue: When you plug in the USB cable, the computer can supply a large amount of current (up to 500 mA) on the 5V bus. When you use your 7.5V battery pack, you're relying on the Arduino's tiny on-board regulator to supply power to the 5V bus, and it can't handle more than a few 10s of mA of external load before it overheats and shuts down.

@davetweed not true. The 5V reg could handle a few hundred mA, closer to 700 before issues, with a low VIN. The 3.3V reg is the weak one.

@cde: What you say may have been true for early Arduinos, but today's Arduino UNO only has a tiny SMT regulator with no heatsink.

@DaveTweed - the PCB itself is a non-trivial heatsink.  Especially given that the input is barely above the dropout voltage, thermal issues are probably not the problem.  Rather, most likely the battery pack is outputting a lower voltage than imagined and the regulator is in dropout.

As a general answer, yes. AA alkaline should be more around 2500~3000 mAh depending on quality. 5x AA in series would result in 7.5 Volts and 2500 mAh.
But that's only for almost fully charged batteries. AA batteries can range from 1.6V to 0.8V "dead for most purposes". As they drain, the voltage drops.
What may be happening is that you are powering the Arduino through its power jack, which goes through a diode, causing a 0.7V drop. Then it goes to the linear regulator which has a very high drop out voltage. Or even via the VIN pin, bypassing the diode. But as the battery drains, the voltage drops below the regulator ' s limit.
The Arduino microcontroller can easily work below 5V. The shield might not.

thank you for reply! I definitely use jack I will try going straight for VIN pin tomorrow is there a simple way I could put a connector on a jack to get positive and negative? So I won't have to cut off the connector?

@higeath there are plenty of pigtails on ebay. If I recall correctly, you need a 2.5mm female dc jack.

4xAA = 6.0V connected to a standard diode like 1n4001 = ~5.4V (within the specs for an AVR), connect directly to Vdd (+5V on arduino's). Unless there's a reason you need to use a 7.5V pack. Bypass the protection diode & Vreg = less wasted energy on heat/diode drops. IIRC, the WIFI/Ethernet shields can spike to 500mA or so, so that may also be causing extra drain. If your code constantly uses the WIFI radio, it will cause more current spikes as opposed to using the WIFI less in your code. Your avg current will decrease and battery life will go up. You'll save batteries by using 4 instead of 5 and not cause the 5V regulator to drop out and cause power issues by bypassing its input at Vin and connecting the 6V pack with a series diode to drop it to ~5.4V and connecting to +5V on an Arduino. It will also help with Vdrop when the WIFI has a current spike.
Also note that as any battery discharges, it's more of a slope than straight line and then dead, even for lithium packs. look at this link, good info for you to understand.
http://www.powerstream.com/AA-tests.htm


text:
How to 'label' module using electric techniques
I am in a project where it makes set of 'modules(set of separate circuits that will work as a sensor when connected to the board' that would be connected to Arduino Mega.
Currently, I'm planning to connect 'modules' with the Mega board using RJ-45(also known as LAN cable) cables.
At first, using voltage divider circuit, I tried to identify these 'modules' by attaching a resistor to it, so that if the board sends 5V to the 'module', it gets the resistance of the resistor inside the module.
But, as soon as I tested, this way seemed a bit unstable, because the measured resistance of the resistor kept changing.
Now, is there any other way to 'label' the module? I'm a beginner in this thing, so I'll appreciate any help that is provided.
Thanks in advance.
Ps. the voltage divider circuit that I used can be found in here:
Ps2. the resistor in the module does not mean the total resistance of the circuit in the module. It's separate.

What kind of sensors / communication protocol / electrical signalling are you using?

each modules have sensors like photo-interrupter in it, and through the RJ-45, are provided VCC,GND, 2 digital inputs, 2 analog inputs, a PWM, and 1 pin is left for the identification.

That starts getting kind of tricky then...  Let me put my thinking cap on for a while...

the voltage divider circuit that I used can be found in here:; no link present. Raspberry hats use I2C EEPROM to identify the 'HAT'/shield. I've seen people using a DS18S20 temperature sensor, as those also include a 64-bit unique identifier. Though both of these will a relatively expensive options. It could be the long lengths of cable that mess with the resistance. So maybe you could add a constant current source on the modules; then add a 'terminating' resistor at the Arduino, and measure the voltage across it.

Personally I would have made the modules purely digital. Add a small microcontroller to each one to interact directly with the sensor in the module, and then use a digital protocol (RS-485, RS-422, LVDS, etc) to communicate between the module and the main board. That way the protocol can include a "tell me what you are" request. Cable length then also doesn't affect analog readings.

It also means the sensor modules themselves then contain the code needed to interact with the sensor. The main board doesn't need to know how to do that - only how to request data from it, or send settings to it.

You still haven't provided the divider circuit!!!

@Gerben Gosh... my eyes are dim lately... here's the link: http://www.circuitbasics.com/arduino-ohm-meter/

What kind of values are you using? You might want to try adding a small capacitor near the analog pin on the arduino to stabilize the voltage. PS maybe your eyes need an op-amp (optical amplifier) q-;

@Gerben Pardon me, I didn't get the 'What kind of values are you using?'...

Resistor values in ohms

If you are unable / unwilling to change your interface into a purely digital system whereby a small microcontroller in the sensor module interfaces the sensor with a communication bus, the best method is probably to include a small 1-wire EEPROM with each module.
An ideal one would be the DS2431 which provides 1024 bits (128 bytes) of EEPROM storage using just 1 wire to both communicate and provide power.
Programming in a unique identifier for the module would be a simple enough task, and that unique ID can then be used to work out what the module is.
The DS2431 is pretty cheap too, available at prices around  $1.50 and below (much less for bulk and surface mount).
You can also get bigger versions for storing more data should you want to.

humm... if the digital storage is the only answer... then I shall follow. Thanks so much!


text:
Arduino I/O Shield relay won't switch
I have an Arduino Uno and the I/O Shield wired up and I'm trying to switch (i.e. engage) a relay on the I/O Shield, but nothing seems to be working.
I've identified the input pins correctly and am able to send digital signals to it and it responds correctly. I also see the LED next to the relay light up when I do a digital write on the Arduino to a specific relay pin.
I'm starting to think that I might need to use an alternative power source or that I am not using the Arduino API correctly to switch the relay. At the moment I do a digitalWrite(13, HIGH), delay, and then do a digitalWrite(13, LOW) - pretty simple.
The shield is just powered by the Arduino at the moment, and I haven't been able to find where I might be able to plug in power, so I'm assuming the Arduino supplies it with all of the power it needs.
#include <Arduino.h>

int relayPin = 13;

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

void loop() {
            digitalWrite(relayPin, HIGH);
        delay(5000);
        digitalWrite(relayPin, LOW);
        delay(5000);
}

So you did everything correctly? Then it works correctly, case closed. Maybe show someone what you did?

pinMode(13, OUTPUT); ?

yeah I setup the pin as an output as well

@wesleyLee - He is able to light up the LED which is next to the relay so I think he has declared the pin as output correctly.

or that I am not using the arduino API correctly to trip the relay Arduinos know nothing about relays, they only know about pins that can be outputs and then can go high or low (or float). If the connected LED turns on and off then that part is OK. Check the supply voltage for the relay, it needs more power than an LED.

Based on your newly-added photo, you are using the Velleman VMA05 I/O Shield (or the KA-05 kit version).
This shield requires a 12V 500mA (minimum current capability) power supply input to the Arduino Uno, as that board uses relays with a 12V coil.  Your symptoms (LED lights but relay does not switch) suggest that you are using a lower voltage, or lower current, power supply to your Arduino. If so, then the fix is: Use the required power supply to the Arduino.

I'm assuming the arduino supplies it with all of the power it needs.

Yes - but only if you meet the minimum requirements of the power supply which you connect to the Arduino. As documented in the Vellemen VMA05 datasheet and manual, this must be a 12V supply (not lower, not higher) capable of a minimum of 500mA.
(You would likely be able to use a 12V supply capable of a slightly lower current output, if you only wanted to have one or two relays active at the same time. However if more relays were active simultaneously, the risk would increase of incorrect or erroneous behaviour, due to the additional current necessary for each relay coil, in addition to powering the Arduino, eventually exceeding the capabilities of the power supply.)

I'm assuming I plug the power in to the power in pin of the arduino, from what I understand we can only supply 5v through the micro usb slot.

@ThePaxBisonica - "I'm assuming I plug the power in to the power in pin of the arduino" - Yes, using the round "barrel connector" (also called "coaxial power connector" or "DC power jack").

@ThePaxBisonica - In case you are unsure about Arduino power supplies (perhaps you have always used the USB connection for power?) here is a link to the Arduino website explaining more about choosing & connecting an Arduino external DC power supply. Although for powering just an Arduino Uno then a 9v supply would suffice, when using your relay shield (and several other models of relay shield), a 12V supply with sufficient current capability (in your case ideally 500mA minimum) is required.

Unless you share a schematic, it will be very difficult to provide a good answer.
Here are the things that you might be doing wrong:
1) Using a power supply which is not able to provide enough current to the relay.
2) Using a power supply of wrong voltage as required by relay coil. The relay might be needing 12 V and you might be trying to power it up with a 5 V power supply.
3) You might be trying to drive the relay directly with your GPIO pin (without using any external transistor switch).
4) Trying to raise a dead relay. There is a possibility that the relay is damaged. Check it by powering it up directly using a battery or another adequate power supply that you got.

when you say the relay might need 12v I'm a little confused because I've looked for a power input and there doesn't seem to be any, do you mean I need to power the arduino with a 12v power supply?

Yes, 12V / 500mA supply is the minimum required for this board to work correctly. 9V will make the LED turn on but not pull the relay contacts properly.  Also, I have had two of these boards where the back EMF diodes across the relay coils have gone short circuit causing excessive heating in the associated switching transistors.  The solution is to replace these diodes with a more suitable 1N4001 type since the 1N4148 that is supplied with the kit is really a small signal diode and really not suitable for this purpose.


text:
How to bootload a atmega328-pu using arduino uno?
I have some Atmega328-Pu micro-controllers without boot-loader program. Now I need to burn boot-loader to them all. I have two arduino uno boards having Atmega328 P-Pu micro-controllers on board. I used this circuit  from this page Installing an arduino boot-loader
It does not work. The boot-loader is not uploaded. Can you please help me out? If you need any more informations please ask. I have been struggling with this kind of boot-loading techniques for more than a week. I am using arduino IDE 1.0.1 and the board is Arduino uno R3

Have you uploaded the ArduinoISP sketch to the left-hand Arduino in your diagram and selected ArduinoISP under Tools->Programmer before using Tools->Burn Bootloader to burn the bootloader? BTW, I would strongly recommend upgrading to Arduino 1.6.8 - that is where my instructions are written from.

This thing has never let me down: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

@Whiskeyjack  ... and the Arduino ISP tutorial have never let me down (even with different Arduino types than described in the original tutorial; brief report to that effect).

is the target ATmega clock pin oscillating? Is there anything else connected to the SPI pins?

After uploading ArduinoISP and before trying to actually burn the bootloader, you have to put a capacitor (10 µF recommended, 1 µF always worked for me) between RESET and 5V of the Arduino on the left (the one running ArduinoISP).

Hi friends thanks for your support. It worked well as it is. No external capacitor I used.
I made the connection as shown in the above picture taken from LINK1.
I modified the file "boards.txt" and "avrdude.conf" as given in step 4 of LINK2
I first uploaded the ArduinoISP sketch to the board on the left.
And then I opened an "EMPTY ARDUINO SKETCH".
From that empty sketch I made the following changes
     Tools->Board = "Arduino328"
            Port  = COM4 in my pc
            Programmer = Arduino as ISP
Last step "Burn Bootloader"
Ta Da....
It worked. When I posted this question I burnt the boot-loader having the arduino ISP sketch opened. Only thing I changed now is I opened an empty sketch and hit burn from that sketch. Anyway.. thank you all. I dont think I wasted your time. If so, I apologise.


text:
Is this a proper implementation of FreeRTOS for Arduino?
I'm using the RGBLCDShield library and a few analog input signals and since it seems the interrupts are being used by the SPI interface of the LCD Shield, I decided to try it with FreeRTOS instead.  I don't currently have my arduino with me (left if at parents') but I wanted to get some feedback on this code to see if it would run properly; I might not be getting my UNO back for a few days but I wanted to at least have a usable code ready to be tested when I do get it.
The Analog inputs are just 2 low level signals and the digital outputs just control some IC switches.  One PWM is fed through a lowpass filter and into an amplifier input.
Here is my code in it's entirety:
#include <Arduino_FreeRTOS.h>
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
#include <math.h>

// define tasks
void TaskAnalogRead( void *pvParameters );  // Check voltage input
void TaskLCDShield( void *pvParameters );   // Control Display
void TaskUserInput( void *pvParameters );   // User Interface - System Process

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
unsigned int vSet = 0;  // Desired Voltage (potentiometer set)
unsigned int vOut = 0;  // Voltage on capacitor

// the setup function runs once when you press reset or power the board
void setup() {

  // Set up Tasks to run independently
  xTaskCreate(
    TaskAnalogRead
    ,  (const portCHAR *) "AnalogRead"   // A name just for humans
    ,  128  // This stack size can be checked & adjusted by reading the Stack Highwater
    ,  NULL
    ,  2  // Priority, with 1 being the highest, and 4 being the lowest.
    ,  NULL );

  xTaskCreate(
    TaskLCDShield
    ,  (const portCHAR *) "LCDShield"
    ,  128  // Stack size
    ,  NULL
    ,  3  // Priority
    ,  NULL );

  xTaskCreate(
    TaskUserInput
    , (const portCHAR *) "UserInput"
    , 128
    , NULL
    , 1
    , NULL );

  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
  lcd.begin(16, 2);
}

void loop()
{
  // Empty. Things are done in Tasks.
}

/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/

void TaskLCDShield(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

  // Start Display
  lcd.setBacklight(0x7);
  lcd.setCursor(0,0);
  lcd.println(" PORTABLE SPARK ");
  delay(5000);
  lcd.clear();

  for (;;) // Continuously Update display
  {

    int volts = vSet * 100.0;
    int chg   = (vOut * 0.488)/volts;
    int vpos, cpos;
    lcd.setCursor(0,0);
    lcd.print("Voltage:       ");
    lcd.setCursor(15, 0);
    lcd.print("V");
    lcd.setCursor(0,1);
    lcd.print("Charge :       ");
    lcd.setCursor(15,1);
    lcd.print("%");

    lcd.setCursor(9,0);
    if(volts < 100)
      {
        lcd.print("    ");
        vpos = 13;
      }
    else if(volts < 1000)
      {
        lcd.print("    ");
        vpos = 11;
      }
     else if(volts < 10000)
     {
      lcd.print("     ");
      vpos = 10;
     }
     else vpos = 9;
    lcd.setCursor(vpos,0);
    lcd.print(volts, DEC);

    lcd.setCursor(9,1);
    if(chg < 10)
      {
        lcd.print("    ");
        cpos = 13;
      }
    else if(chg < 100)
      {
        lcd.print("   ");
        cpos = 12;
      }
    else cpos = 11;
    lcd.setCursor(cpos,1);
    lcd.print(chg, DEC);
    //digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
    //digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    //vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
  }
}

void TaskAnalogRead(void *pvParameters)  // Read Analog Voltages (VSet, Emonitor)
{
  (void) pvParameters;

  for (;;)
  {
    int eMon = analogRead(A0); // read input pins
    vTaskDelay(1);
    int vA = analogRead(A1);

    vSet = (vA/1024) * 15000;  // calculate actual values
    vOut = (5.0/1024.0) * 10000 * eMon;

    vTaskDelay(10);  // one tick delay (300ms) in between reads
  }
}  // End Analog Read

void TaskUserInput(void *pvParameters) // User Interface
{
  (void) pvParameters;

  // initialize digital pin 13 as an output.
  pinMode(8, OUTPUT);  // Fire signal
  pinMode(7, OUTPUT);  // Charge/Discharge signal
  pinMode(5, OUTPUT);  // Eprgm PWM output
  pinMode(4, OUTPUT);  // Cam/DAQ trigger

  bool charge = false;   // charge flag

  for (;;)
  {
    uint8_t button = lcd.readButtons();
    switch(charge)
    {
      case true:
        analogWrite(5, (vSet * 0.0204)/5);
        vTaskDelay(1);
        digitalWrite(7, HIGH);
        vTaskDelay(1);
        break;

       default:
        analogWrite(5, 0);
        vTaskDelay(1);
        digitalWrite(7, LOW);
        vTaskDelay(1);
        break;
    } // End Switch(charge)

    if(button & BUTTON_UP)  // Charge/Discharge button
    {
      charge = !charge;
    } // end if

    else if(button & BUTTON_DOWN) // Fire!
    {
      digitalWrite(8, HIGH);
      vTaskDelay(1);
      digitalWrite(4, HIGH);
      vTaskDelay(1);
      digitalWrite(7, LOW);
      charge = false;
      vTaskDelay(1);
      digitalWrite(4, LOW);
      vTaskDelay(1);
      digitalWrite(8, LOW);
    } // End else if

  }  // End for

} // End User Interface

My specific concern is with the 2wire interface of the LCD shield and whether it would be able to communicate with the Arduino - especially when it needs to read the button inputs.
Also, how do I determine the stack size for each task?  Is 128 for each enough to handle what I have?

“the interrupts are being used by the SPI interface of the LCD Shield”. I don't quite understand this sentence. Each interrupt source has its own interrupt (or interrupts). The SPI interface has one interrupt. It does not prevent you from using other interrupts if you want.

This is not a direct answer to the question. Instead, I suggest that you
do not need an RTOS to do what you want. A lightweight alternative is to
use millis() to decide when it is time to perform such or such task:
void loop()
{
    uint32_t now = millis();

    // Update the LCD every second.
    static uint32_t last_lcd_update;
    if (now - last_lcd_update >= 1000) {
        last_lcd_update = now;
        update_lcd();
    }

    // Read the analog inputs every 300 ms.
    static uint32_t last_analog_read;
    if (now - last_analog_read >= 300) {
        last_analog_read = now;
        do_analog_read();
    }

    // User input is handled continuously.
    handle_user_input();
}

This will use significantly less resources (flash, RAM and CPU time)
than an RTOS. Another advantage is that you do not need to determine a
stack size for each task, which is definitely not a simple thing to
do.


text:
Trouble using lcd.readButtons() in RGBLCDShield library
I am trying to create a state machine that loops in whatever state it's in until a button is pressed.  I am using the Adafruit_RGBLCDShield library along with the LCD shield and 16x2 display.  For some reason the buttons aren't being detected at all.  Here is the code for one of the states:
    case STANDBY_MODE:
  lcd.clear();
  lcd.setBacklight(0x0);
  delay(100);
  noInterrupts();
  digitalWrite(fire, LOW);
  digitalWrite(chg, LOW);
  digitalWrite(trig, LOW);
  analogWrite(eprgm, 0);
  // Wait for button press
  while(1)
  {
    button = lcd.readButtons();
    if(button)
    {
      showLCD();
      t0 = millis();
      state = NO_CHARGE;
      analogWrite(eprgm, (vSet*0.0204)/5);
      interrupts();
      return;
    }
  }
break;

In this state, the system turns off all outputs and display and waits for a button to be pressed.  For some reason, though, it doesn't respond when I press the button.  Is there something missing here?

IMO, your post doesn't provide enough information to allow definitive problem diagnosis.
Why do you say noInterrupts(); at line 5?  Some versions of the Wire library might be interrupt driven[1].  If interrupts were off, such a library wouldn't detect any button presses on a TWI-interfaced shield like Adafruit's RGBLCDShield.
[1]: Per arduino.cc's WireLibraryDetailedReference page,  “"The AVR TWI is byte-oriented and interrupt based...." (section 21.6 on p. 224) ... The TWI module sends an interrupt when it finishes, to notify the processor of the change in conditions ... However, notice that the Wire library has blocking I/O. ” [Ie, the usual Wire library doesn't take advantage of TWI interrupts.]

Thanks, this actually WAS the issue.  I can't use interrupts with the LCD shield interface.


text:
How to connect a phone's camera to an Arduino?
I would like to ask how to connect my phone's camera to an Arduino, just like it is done in this this video. Is anyone familiar with this application they are using?

That video shows a Bluetooth connection between the smartphone and the Arduino.
(A USB connection between the smartphone and the Arduino might be better in some ways).
details
If you want more information after watching a video like this, click the "show more" button underneath the video to see the details.
Those details clearly say "The Nexus S device connects to the IOIO board via Bluetooth, and uses the smartphone's camera in conjunction with OpenCV and the external IR sensors to control the vehicle."
Those details also include a link to
"Android Based Robotics".
The OpenCV image processing software runs on the smartphone. In this autonomous application, the image data never leaves the smartphone. The software on the smartphone reduces the image data to two integers -- the X,Y pixel location of the center of the green ball.
The Arduino and the Bluetooth link can easily handle a few integers at over 200 Hz. Neither one is suitable for handling live video data.
The Arduino could probably act as the controller.
The camera could send the X,Y pixel location of the green ball to the Arduino; while the Arduino collects all the other sensor data; then the Arduino could use that to decide what to do; then send the appropriate control signals to the motor drivers.
However, in this autonomous toy car it appears that the the smart phone acts as a controller.
The Arduino collects all the other sensor data, forwards that data to the smartphone; then software on the smart phone takes that data and the X,Y pixel location of the green ball; then the smartphone decides what motors need to turn; then the smartphone sends the appropriate commands to the Arduino, and the Arduino demultiplexes those commands to the motor drivers.
For even more details on building robots using smartphones and Arduino, see

"Android Based Robotics" ( http://www.socsci.uci.edu/~jkrichma/ABR/ ).
The Tinkernut video
"DIY Smartphone Controlled RC Car" ( https://www.youtube.com/watch?v=xsJ7176fLNw )
goes into more details of how to connect a smartphone to an Arduino via Bluetooth.
Android Based Robotics: ground robot manual
( https://groups.google.com/forum/#!topic/android-based-robotics/_H8Zmvbxx-M )
"Simple RC car for beginners (Android control via Bluetooth)"
( http://solderer.tv/cxemcar/ ) ( via http://english.cxem.net/ ).
Communicate with Your Arduino Through Android (using USB cable)
ArduinoCommander:
"Control your Arduino board from your Android device over Bluetooth, Ethernet or USB"

Normally I would say that the phone is some kind of converting image to serial data and sending it to arduino via serial port. But there is no cables on the phone in the video. It is communicating wirelessly. But I don't think that vehicle is atonoumus?  The phone should be transfering image data via ethernet (wifi) and the user controls it. The reason I don't think that's an atonoumus is because you can't simply process that image stream with an arduino it would be a enormous process for arduino's little chip. They must be processing it on a computer. Either two ways the phone is talking to another processor. Not the arduino. Maybe if you tell what you want to do spesificly I might help you instead of trying to figure out this video :))  EDIT: it could also be a Bluetooth connection :))


text:
COM+ and COM- to RX and TX
I want to connect a Hokuyo scanning range finder to an Arduino Mega, the outputs are labeled like this:

COM+
COM-
Input
Output
DC12/24
GND

I want to read its serial output with Arduino, please help me in details.
Thanks

Have you looked at the hardware documentation of the device you are trying to connect to, normally this will provide details on how to connect and interface with the COM Ports

Failing @Harvey's suggestion, you will at the very least need to specify the exact model of the device you are trying to interface with. But I suspect this will be off-topic here anyway; Super User is concerned with using computers from a user perspective, not programming or hardware design.

There are many protocols involved in COM programming also, so also a very broad question

You should specify what model of Hokuyo scanning range finder you have.  Some models are USB-interfaced, in which case  COM+ and COM- could possibly correspond to USB D+ and D- leads.
The Hokuyo URG-04LX has both USB and RS-232 interfacing.  The linked page shows the following pinout on CN1:
Pin No.   Signals                                Colors
1         N.C.                                   Red
2         N.C.                                   White
3         OUTPUT(Synchronous output)             Black
4         GND(5th pin of 9-pin, D-sub connector) Purple
5         RxD(3rd pin of 9-pin, D-sub connector) Yellow
6         TxD(2nd pin of 9-pin, D-sub connector) Green
7         0V                                     Blue
8         DC5V                                   Brown

Given that pinout, you would connect pin 5, RxD, to a TXD output on the Mega, and pin 6, TxD, to an RXD input on the Mega.  Note, before making any such connection, measure the output voltage on pin 6.  An ordinary Mega supports 0 V and 5 V levels for serial data, but standard RS-232 levels are lower and higher than that; for example, ±12 V.  If you connect  ±12 V RS-232 levels to your Mega, you will damage it.  The several Hokuyo documents I've looked at don't say whether they use traditional RS-232 levels (±12 V) or TTL levels (0-5 V).


text:
Printing Time to Serial Port
I am reading sensory data that comes from the digital inputs(two DHT11 Humidity sensors using adafruit library.) and I would like to add a hh:mm:ss real time counts next to them. I try to use the time.h library but could not understand how to worked it in that way.
My code is;
#include "DHT.h"

#define DHT1PIN 4
#define DHT2PIN 7

#define DHT1TYPE DHT11
#define DHT2TYPE DHT11

DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("Humidity sensors DHT11 tests!");

  dht1.begin();
  dht2.begin();
}

void loop() {

  delay(2000);

  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();

  if (isnan(t1) || isnan(h1)) {
    Serial.println("Failed to read from DHT #1");
  } else {
    Serial.print(h1); Serial.print(" \t");
  }

  if (isnan(t2) || isnan(h2)) {
    Serial.println("Failed to read from DHT #2");
  } else {
    Serial.print(h2);
    Serial.print(" \t");
  }
  Serial.println();
}

and my serial port out is;

and I want it to be like that;

Any help will appreciated.

Did you add a RTC to the circuit?

No I want it to read the clock from compter.

Then there's no way the Arduino can know the time. Write a custom host-side program.

Isn't there a way to know the time of data that printed on a serial?

Sure. The host will know. But that means a host-side program.

So no way to print it to serial window, thanks.

Like he said, there is a way to print it but it would require a program running on your PC; the Arduino is not omniscient, your PC keeps track of the current time whereas the Arduino only knows about time as it relates to executing instructions, therefore your PC has to either inform the Arduino of the time when the sketch first begins to run, and let the Arduino regularly update the time on its own or, even better, your PC program should listen to the serial port and print the current time in addition to whatever DHT sensor data it receives from the Arduino.

http://unix.stackexchange.com/questions/104834/how-to-log-serial-data-with-time-stamp

I solved the problem by using millis() function. And now I ca get results like these;

My code is;
#include <Sensirion.h>
#include "DHT.h"
unsigned long time;

#define DHT1PIN 4
#define DHT2PIN 7

#define DHT1TYPE DHT11
#define DHT2TYPE DHT11

DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);

const uint8_t dataPin =  9;              // SHT serial data
const uint8_t sclkPin =  8;              // SHT serial clock
const uint8_t ledPin  = 13;              // Arduino built-in LED
const uint32_t TRHSTEP   = 1000UL;       // Sensor query period
const uint32_t BLINKSTEP =  250UL;       // LED blink period

Sensirion sht = Sensirion(dataPin, sclkPin);

uint16_t rawData;
float temperature;
float humidity;
float dewpoint;

byte ledState = 0;
byte measActive = false;
byte measType = TEMP;

unsigned long trhMillis = 0;             // Time interval tracking
unsigned long blinkMillis = 0;

void setup() {
  dht1.begin();
  dht2.begin();
  Serial.begin(9600);
  Serial.println("In.(%) In.Tem(*C) Out.(%) Time");
  pinMode(ledPin, OUTPUT);
  delay(15);                           // Wait >= 11 ms before first cmd
  // Demonstrate blocking calls
  sht.measTemp(&rawData);              // sht.meas(TEMP, &rawData, BLOCK)
  temperature = sht.calcTemp(rawData);
  sht.measHumi(&rawData);              // sht.meas(HUMI, &rawData, BLOCK)
  humidity = sht.calcHumi(rawData, temperature);
  dewpoint = sht.calcDewpoint(humidity, temperature);
  logData();
}

void loop() {

  unsigned long curMillis = millis();          // Get current time

  // Rapidly blink LED.  Blocking calls take too long to allow this.
  if (curMillis - blinkMillis >= BLINKSTEP) {  // Time to toggle the LED state?
    ledState ^= 1;
    digitalWrite(ledPin, ledState);
    blinkMillis = curMillis;
  }

  // Demonstrate non-blocking calls
  if (curMillis - trhMillis >= TRHSTEP) {      // Time for new measurements?
    measActive = true;
    measType = TEMP;
    sht.meas(TEMP, &rawData, NONBLOCK);      // Start temp measurement
    trhMillis = curMillis;
  }
  if (measActive && sht.measRdy()) {           // Note: no error checking
    if (measType == TEMP) {                  // Process temp or humi?
      measType = HUMI;
      temperature = sht.calcTemp(rawData); // Convert raw sensor data
      sht.meas(HUMI, &rawData, NONBLOCK);  // Start humidity measurement

      float h2 = dht2.readHumidity();
      float t2 = dht2.readTemperature();

      Serial.print(humidity);
      Serial.print(" \t");
      Serial.print(temperature);
      Serial.print(" \t");

      if (isnan(t2) || isnan(h2)) {
        Serial.println("Failed to read from DHT #1");
      } else {
        Serial.print(h2);
        Serial.print(" \t");

        //time = millis();
        //prints time since program started
        Serial.println(curMillis);
      }
      Serial.println();
    }
    else {
      measActive = false;
      humidity = sht.calcHumi(rawData, temperature); // Convert raw sensor data
      dewpoint = sht.calcDewpoint(humidity, temperature);
      logData();
    }
  }
}

void logData() {
}

But the difference is that I am using SHT75 instead of another DHT11 so I am simultaneously acquiring data from the both of them. Thanks for everyone!


text:
Fan control circuit with Arduino
I have a fan control circuit with Arduino (PWM). I did all things and it worked. My question is why we did not directly connect the fan to Arduino. Why should we have a driver circuit?

Because physics will destroy your device.

I found an answer for that since we are applying a linear control on the fan,if we we connect directly to the arduino,we would not be able to any voltage rather than 0 and 5 volts(it will act like a switch).With driver circuit,we made our fan operate between 0-12 volts using feedback. However,this answer is not enough for me ,i did not understand the exact reason.

This question is on-topic and should remain open. Programming is included but not exclusively. Boards, clones, IDEs, libraries, and more, related to Arduino, are included.

This is an electronics question, and it should be forwarded to the electronics stackexchange.
The fan needs to have a proper amount of current to spin, and because the microcontroller that controls the fan draw very little current on its output pins (check the datasheet for the exact value, but it should be a few milliamps), unless you have a miniature fan, wiring it directly on the microcontroller will not be able to move the fan.
And this is by design that microcontrollers cannot provide much current. Because to provide larger amount of current than what they do, they'd need to have bigger copper tracks between the transistor to avoid having they internal circuits building too much heat, and they would be much much bigger.
So as a work around, we use an transistor, which receives on the "Base" pin a voltage, drawing almost no current, which will "connect" the collector and emitter pins where you can have a much bigger current flowing (though be careful to respect the datasheet's nominal values for current! Or use either a MOSFET, a Triac or a Relay for bigger currents).

Arduino is a low voltage and low current device. Arduino max current output delivery capecity is 200ma, you can read about diffrent arduino's limitations here,
http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations
Fan or anything that has a coil inside it, needs a huge amount of current during their start up. The current draw decreases as it gains its motion to some limit. The initial huge current is called surge current. There is a high chance that it will blow you pins dead.
Let's say we are using really small fan. And it managed to start and rotating, that dosen't meant there is no problem at all. When a coil is rotated inside a magnetic field an opposite voltage is induced called Back Emf . This is another huge potential concern. This is why we are always suggested to use a diode which will block the opposite flow of current.
Transistor, being a low voltage device and as it can deliver tremendous large amount of output current, It is very widely used to drive high current devices

The
Vin pin = 5V or 3.3V

You cannot use the 5V from the USB to power up the FAN and the LOAD because the USB port usually delivers only 100mA, and this is not enough to switch the relay and the LOAD.
That is why you must use an external power supply (Vcc) that is between 7 to 12 volts to power up the Arduino board and the transistor + relay. The load uses its own power supply, for instance if you use a light bulb then you might connect it to the 110/220V mains or any other power source.
or
you can also use a fan that has one of the pins of the fan is a PWM input. The fan has an internal transistor to switch the 12V power when given a 0-5V input. That is the pin you want to connect to the actuator pin.
please get back to me if it was helpful

Actually the Arduino Uno dc current per I/O pin is 40mA. When fan is connected directly to Arduino Uno, it cannot withstand, because the fan draws more-than 20mA current.
The driver circuit provides sufficient current to rotate the fan. The TIP 121 can withstand up to 3A current.

I know this is an old link but MAXIM has a tutorial on using PWM to drive "normal" DC fans.  The link is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/1784
It was helpful.
Personally, I am designing a simple 5-step temperature-driven device that uses an ATtiny13A to drive a 5 volt fan and a thermistor mounted to a heatsink.  I was originally trying to use a PWM frequency of 4687Hz (CPUclk / 256) but it was way to high.  The MAXIM article states that frequencies in the range of 20Hz to 160Hz are useful.  Obviously, the 4687Hz was TOO HIGH.  I dropped it down to 18Hz and everything works now.  The problem was that the pulse width at 4687Hz was too short to give the DC fan enough electrical "momentum" to spin the fan.  Using a lower PWM frequency gives more electrical energy to the fan to get it to spin.  An analogy would be trying to push a toy car with short and rapid "pushes" as opposed to using longer and slower "pushes".
Hope this helps.
Peace and blessings.


text:
How would you send clock impulses to a camera with an Arduino Mega?
Hardware newbie here and I need to know how to connect my TSL 1401 line scan camera to an Arduino Mega so that I can send it the needed impulses. The Mega has a hundred different sockets and the Schema just scared me when I looked at it.
I just want to know which socket I can connect to the CLK and SI ports of my camera so that I can get and an analog output of pixels.

Please [edit] your question to include a link to the datasheet of the TSL 1401 and the schema of the arduino mega that you are using.

Is this related to this question?

It depends on the camera that you're using but you send in impulse just sending digital write signal, waiting a little bit and then turning it off. You do this over and over again until you have all the pixels. Here is an example where I send 128 impulses:
  for(int i = 0; i < 128; i++)
  {
    digitalWrite(CLK, HIGH);
    delay(1);
    digitalWrite(CLK, LOW);
    delay(1);
  }

Depending on the hardware you are using you might have to send a SI (signal impulse) prior to the CLK impulses and the delay in between them will vary. The best thing to do is to read the documentation to find these figures.


text:
Arduino mega 2560 Stacked with Ethernet/SD card Shield Heat up
Stacked mega and ethernet/sd shield:

When I do this stacking, it heats up. I tried connecting the SPI via ports 13-10 (no stacking), it doesn't work. Also tried connecting the ICSP (red circled mark) via male-female wires without stacking, it works, but still heats up. So I think the ICSP has a defect? or does it? Is it supposed to be like this and I'm just being paranoid?
*PS: the heat in the "pain" level when I touch it, no burning IC odor. Maybe it's because I unplug it immediately after short use? IDK.
**update, I think I got it working, the problem was not about the heating, but the program. Consulted a more experienced person, he said what's happening is normal.

Since this is not a programming question and relates to hardware you might have a better audience on [arduino.se]. I suggest posting it there.

Or you should try on the electronics site, as it's less an issue with the Arduino framework and hardware, but more with the electronics.

the heat in the "pain" level when I touch it, no burning IC odor. Maybe it's because I unplug it immediately after short use? IDK.
  So I think the ICSP has a defect? or does it? Is it supposed to be like this and I'm just being paranoid?

Well you're right in being a bit paranoid. And temperature building up is very likely to mean you've got a short somewhere, it might be a bad solder or a component that fails (like a cap that conducts).
So you've got to isolate the issue:

Isolate the faulty board: whichever board is getting hot, it might be that one that has a failure or the other one ruining it

you need to try the shield with another arduino (whatever version it is) and see if the issue is replicating
then you need to try the arduino you were using with another shield running on ICSP (like another ethernet shield, or an SDCard shield), which will confirm the hypothesis that only one component of the two is failing.

Once you've isolated the board, you need to isolate the component.

you first have to isolate which component is building up heat.
If you've got access to a thermal camera, it's a good idea to use it.
If not: start locating the area where heat is building with your finger, and then test each component of the area with a thermometer (like the ones you plug on a multimeter, or simply a "meat" thermometer for cooking).

Once you've isolated the component, then look it up on the schematics and layout, and lookup all connected components. Either that component or one on the track is failing, or there's a short on that track.

If the solution is not obvious, you can come back on Stack Exchange (get on the electronics QA site with your results), and some EE expert will help you find out what's wrong!
HTH

Wow sir! Thanks! I'll look up to it, although I don't have some equipments you said, this would help a lot, not only on my arduino but other projects. I also tried the arduino forum for this suspected problem.


text:
Arduino Uno - External Power not working properly
I am a newbie to Arduino and created my first project. The project is using a Sharp short range sensor and a 7 seg LED board (http://embedded-lab.com/blog/new-version-of-max7219-based-4-digit-serial-seven-segment-led-display/) to count objects.
Everything works fine when on USB power to my computer or if I use a 5v 1A wall adapter with a USB cable. The problem is when I use an external power adapter or use a DC power supply to the Vin. The board powers up and I measured the output voltage on the 5v pin and is measuring around 4.8v.
The Sharp sensor is connected to the A0 Analog in and I see the voltage fluctuate when an object passes, but the LED is not displaying a value when on the external power. The display is connected to GRD, 5v where DIN, CLK, and LOAD pins of the display are connected to pins 7, 6, and 5 as the instructions stated.
I tried two different Arduino boards and several different AC to DC power adapters ranging from 9v to 12v plus used a DC power supply to the Vin and same results.
The code is below and pretty simple (although I am sure there is a lot better way of doing it but this is my first project in C so go easy on me and the function for digits is from a website and not written by me).
If a picture of the project would help I can upload one.
Any ideas or thoughts?
Thanks,
Steve
#include "LedControl.h"
#include <stdio.h>
#include <math.h>

// Arduino Pin 7 to DIN, 6 to Clk, 5 to LOAD, no.of devices is 1
LedControl lc = LedControl(7, 6, 5, 1);
int sensorpin = 0;      // analog pin used to connect the sharp sensor
int val = 0;            // variable to store the values from sensor(initially zero)
int cnt = 1;

void setup()
{
    // Initialize the MAX7219 device
    lc.shutdown(0, false);   // Enable display
    lc.setIntensity(0, 10);  // Set brightness level (0 is min, 15 is max)
    lc.clearDisplay(0);     // Clear display register

}
void loop()
{

    val = analogRead(sensorpin);       // reads the value of the sharp sensor
    if (val >= 650)
    {

    //write values to LED
    if (cnt<=9)
    {
        lc.setDigit(0, 0, cnt, false); // Display 4 to Digit 1-9, " "
    }
    if (cnt >= 10 && cnt <= 99)
    {
        lc.setDigit(0, 0, getDigitFromNum(cnt,0), false); // Display 4 to Digit 1-9, " "
        lc.setDigit(0, 1, getDigitFromNum(cnt, 1), false); // Display 3 to Digit 1-9, " "
    }

    if (cnt >=100)
    {
        lc.setDigit(0, 0, getDigitFromNum(cnt, 0), false); // Display 4 to Digit 1-9, " "
        lc.setDigit(0, 1, getDigitFromNum(cnt, 1), false); // Display 3 to Digit 1-9, " "
        lc.setDigit(0, 2, getDigitFromNum(cnt, 2), false); // Display 2 to Digit 1-9, " "
    }

    delay(400);
    cnt++;

}
}

// Function: getDigitFromNum returns a digit at a given index of a integer.
// Goes from right to left with the starting index of 0.
int getDigitFromNum(int num, int digit) {
    num /= pow(10, digit);
    return num % 10;
}
// Function: getDigitFromDec returns a digit at a given index of a double.
// Goes from left to right with the starting index of 0.
int getDigitFromDec(double dec, int digit) {
    dec *= pow(10, digit);
    return (int)dec % 10;
}
// Function: getDigitFromNum returns the decimal values of a double.
double getDecimals(double dec) {
    return dec - (int)dec;
}

Maybe to much noise or load on the 5V regulator? How much power are you drawing? And what's wrong with just using a USB power supply? They are cheap and easy to find.

And a good clean picture, and schematic always helps.

Thanks for the help.
Added a photo... not sure it shows it real well. Downloading  Fritzing now so schematic to follow. How do I measure how much power I am drawing (remember newb here).
I want to ultimately use battery power. Any recommendations on a battery pack that will connect to the USB Type B port? Also I would like to understand what I am doing wrong or the issue.

Along with Passerby's comments, your stepping on your own brain. Do not over complicate the wheel. Stick with what works and make it more permanent. There is likely nothing wrong with your code or it would not work at all.

Do you have enough of current supply? What if your power supplies are just too low on current - cannot work properly because arduino cannot get enough current to power everything? Just try (if you have) something with 12V and 1A. It should be more than enough, but..at least, give it a try.

Passerby - Still working on the schematic - not sure how to represent the LED display board as it is not a standard part, but thanks for the tip on schematic vs drawing (once complete will upload). I looked into the USB banks and that looks reasonable and will research that, but still want to understand what is up with this. You mentioned noise. I have a few solder joints to connect the sensor and LED display back to the 5v. Could that cause an issue for the regulator? I read where the external jack is connected to a voltage regulator but the USB is not.

Sparky256 - thanks and yeah I have stepped all over my brain on this one. Although new to Arduino and C programming, background is in software and years ago played with electronics (long before Arduino). I didn't see the code as an issue, but a lot of people I notice ask for it. Also with trying multiple boards and power supplies ruled them out. Has me puzzled on this even though I am new to this.

Jakey - One the external wall jack power supplies I tried is a 12v 1A supply. The other one is a 9v 1a supply that came with a kit. I also used a Dr. Meter DC power supply connected to the Vin pin. It only allows the board to draw the max current it can handle. I pushed the voltage up to 12v and the board would only draw around .800 mAh. The power supply of course can push a lot more than that. Both of these produced the same result.

Okay. What if (I know this is not recommended, but) you connect +5V to a 5V pin on arduino? Just give it a try.
On the other hand: Why don't you (in this case) just power your Arduino with phone USB charger? Just plug in usb A -> usb B cable and you're ready to go.

I might not be able to respond as much for the next week because of travel for work. I am thinking it is something with the LED board. I am going to contact the supplier on that and see what they think. Thanks everyone and will update as soon as I can.

Jakey - right now I am powering the device using a USB phone charger and working good. Two things, I want the device to be portable so running off batteries is preferred and secondly would like to understand why it is not working. Is there something special or different you have to do when uploading the code to the device to have it run off of external power?
Not sure what you mean by connecting a +5v to the 5v pin. I thought the one 5v pin was a voltage out?

5V pin is voltage out. But if you connect the 5V power supply to this pin, arduino should turn on. It's not good for 7805, but if you try it for 3 seconds, won't do any harm.
About external voltage: Give it a try of a battery (or socket charger) to a DC connector left of the USB connector (watch the polarity!).
Report results afterwards. It shouldn't be much different, but in this case, we'll just give a kick in the dark.
PS: Just measure the battery/power supply(NOT USB!) voltage for sure. Just to make sure, it gives out as much as supposed to (or at least 7V, but preferable more than 9V).

@Jakey It's not good for 7805, but if you try it for 3 seconds, won't do any harm. You're talking nonsense. First there is no "7805", and second the LDO that is there doesn't give the slightest damn. Power has no concept of "in" or "out" - it only exists. The only possible danger is if you power through 5V and try to draw current from VIN to power things - then it can flow backwards through the regulator. Other than that, powering into 5V is perfectly valid.

The only difference between powering from USB and powering through the barrel jack is the voltage is reduced to 5V through a Low Dropout (LDO) voltage regulator. These are typically a clone of the popular LM1113-50 and vary in current handling capacity from around 500mA up to 1A.
I notice your board is not a genuine Arduino - therefore the components used may be at the cheaper end. So we'll assume a low-grade LDO that only handles 500mA before going into thermal shutdown with good heatsinking. Since there isn't on these boards we shall therefore assume a maximum of 400mA before it gets too hot. Probably somewhat conservative.
So if your entire circuit is drawing more than about 400mA you can expect the regulator to shut down, or at least to reduce the current and/or voltage available.
The fact you're seeing 4.8V rather than 5V could be an indication that there is voltage droop occurring - i.e., the regulator is not able to supply enough current so the voltage drops. This would be accompanied by the regulator getting very hot.
The regulator is the device with 3 pins on the right side and a single tab on the left directly above the barrel jack socket. See how hot that is getting.
As a rule of thumb if you can hold your finger on it without crying for 10 seconds it's not too hot.

Another thing you can do is to reduce your circuit to the bare minimum. Unplug absolutely everything and upload the Blink example sketch. Power that from the external DC and see if the LED blinks for you. If it does then the power supply is working OK. You can then add your peripherals one at a time to see when it fails.
If it doesn't blink then there must be something inherently wrong with the supply.
One possibility is that the LDO is oscillating due to insufficient or incorrect input and output capacitors. This basically means the "5V" voltage it gives out is actually wildly swinging between say 4.5V and 5V or 4.75V and 5.25V, which really confuses the microcontroller. Cheap LDOs are often more sensitive to the capacitors they are paired with and can suffer from this kind of problem.
To diagnose that kind of thing you would really need access to an oscilloscope to analyse the voltage.
If it is oscillating a 10µF ceramic capacitor connected between the lower two pins of the LDO (as orientated in your picture - that is Vout and GND) may cure it. A 1206 surface mount capacitor fits nicely across those pins and is reasonably easy to hand solder. You could also try a through-hole capacitor (ceramic again) between 5V and GND on the power header, but you really want it as close to the LDO as you can get it, so soldered direct to the LDO's pins is best.


text:
How to connect an Arduino with SIM300 and a seperate GPS module?
I am trying to connect an Arduino with SIM300 and GPS module to upload data directly into a database on my localhost using GPRS of the SIM inserted. I am not able to interface the separate GPS and GSM modules. Kindly help in this regard.

If you give more details , that would be helpful. The amount of information you give, it looks like you need a tutorial not an answer.

I am using seperate gps and a gsm module. I am using an A6390 gsm and neo 6m gps module. i want to fetch gps data and uplaod to a local database using gprs through the gsm module

I know I should write this in comment section , but as comment have word limitation and I'm going to give you a idea why this should not be a question and how should you go for your problem, I'm writing it in answer section.Please don't down voted me :p
You miss the point of my comment. This is a forum where you ask about your problem and people try to help you to solve it. It's not a tutorial providing forum. But from you'r question as far as I understand , you want more or less  a full tutorial about your circuit. That's why you are getting down vote.
First you should run your module individually . Here is two YouTube tutorial link for your GPS and GSM modules.
GSM module tutorial
GPS module tutorial
You can look for more tutorials in YouTube and build a besic idea. Then make GSM and GPS module working individually. When individually they work, then add there code and components and run the whole system. This way , it will be easy for you to detect where the problem is. If you'r device fail and you can't find or solve the problem, then ask here.
There is some rules how to ask questions here, follow them. Give total idea about your problem and how far you can debug.If possible, add your code and circuit diagram. Hope we can help you then.


text:
Moving ATMEGA to 3.3V
I currently have a barebone arduino built from just an Atmega 328P and a 16Mhz external crystal.

I planning to move this system down to 3-3.6V but I have read that on low voltage I have to use 8Mhz crytstal so my only question is that because of this change do I have to take the chip out to reflash with the programmer again or it will work as it did before?
What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?

I think in particular case you may get working result, but in large sample: some set of devices won't work. This relate to internal construction of oscillator circuit.

Software side could be easier than I thought: http://playground.arduino.cc/Learning/Atmega83-3V

If you use Serial to program the ATMege, you'd have to change the bootloader. Since it assumes it's running at 16MHz.

...I have read that on low voltage I have to use 8Mhz crytstal...

Technically you can run anywhere below 13Mhz or so, so you have lots of choice.
You may also be able to use the prescaler to divide the clock by 2, either by hoping the ATmega can run the short time at 16MHz, or by programming the CKDIV8 fuse to start it at 2MHz.

...do I have to take the chip out to reflash with the programmer again...

If you move to a frequency within spec with either a clock change or prescaler use, yes. The bootloader and Arduino libraries expect a 16MHz clock, so you will have to rebuild the bootloader with the new clock rate, and sketches that use delay() et alia as well as the intrinsic delay functions will also need to be rebuilt.

What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?

It may work, it may not.

So can I use a programmer circuit with 16Mhz code for the reprogramming of the firmware (an arduino uno)? Even if after programming it becomes unavailable in the uno and works in the final circuit.

You would use a ISP programmer to program the bootloader for the new clock. After that you can program it as normal.

I planning to move this system down to 3-3.6V but I have read that on low voltage I have to use 8Mhz crytstal so my only question is that because of this change do I have to take the chip out to reflash with the programmer again or it will work as it did before?

Any time-sensitive code -- such as delays and UART I/O -- will run at half speed with the 8 MHz crystal. If any of this matters, you'll need to reprogram the chip. (This will include the bootloader, which will now run at half the baud rate it used to!) If this is OK, though, you can leave it alone.

What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?

The ATmega328P isn't specified to run reliably at 16 MHz at 3.3V. Many chips will actually work at this speed, but some will fail, possibly in subtle ways or at inconvenient times. Don't rely on it working.


text:
Increase the resistance of a photoresistor with increase in light intensity
I'm building a laser tripwire of sorts and instead of shutting up when the laser points on it (which is essential for my project) it beeps louder.
Here's the code
int buzzPin = 11; // buzzer connected to digital pin 11

void setup() {
    pinMode(buzzPin, OUTPUT); // sets the digital pin as output
}

void loop(){
    if(analogRead(0) < 750){ // this number depends on calibration of the photocell
        digitalWrite(buzzPin, HIGH); // turns buzzer on
        delay(5000); // waits for 1 second
        digitalWrite(buzzPin, LOW); // turns buzzer off
    } else{
        digitalWrite(buzzPin, LOW);
    }
}

You can't. That's not how physics works. Ask how to do what you're really trying to do instead.

Just reverse the logic in the code.  'if (analogRead(0) < 750)' turns into 'if(analogRead(0) > 750)'

Arduino can not measure resistance. It can measure voltage.
To measure resistance you can convert resistance to voltage using a voltage divider.
In Arduino world a voltage divider consists out of 2 resistors in series between 5V and gnd. The connection to the 2 resistors is connected to a analogue pin.
Depending whether your LDR is connected to gnd or 5V the measured value on the analogue pin will go up or down with the resistance of the LDR.
In other words swap the resistor and your LDR from position.

Just invert it in software. Instead of analogRead(0) use (1023-analogRead(0)).

You could change your circuit or just change analogRead(0) < 750 to analogRead(0) > 750.


text:
Arduino Due SRAM
I'm trying to create an array in Arduino Due and when the
array exceeds the size of 32768 integer elements
the compiler (Atmel Studio) complains.
I read that Arduino Due SRAM size is 96K in 2 banks. 64Kb and 32Kb.
Anyone knows any details?

Size of int in arduino due is 4Bytes. If you're trying to create array of 32768 integers, it means you need 128kB of free space.

I've read in several places that e.g. PROGMEM const int foo[] = { 1, 2, 3, ... } would work, but was unable to do it in my environment ( debian, arduino-mk package ). I had a number of arrays I needed to commit to flash to conserve sram. This worked fine for all variables, but not for arrays. Try that... What say the wizards?
Note to moderators and others: I know I am not answering the question definitively, but it is relevant to OP's question.

On ARM chips, like all Princeton architecture chips, you don't need to do fancy things with PROGMEM - just make them const.

So it's completely unnecessary? How awesome is that ;)

PROGMEM is used to lock const data into flash and prevent CRT0 from copying it into RAM. On ARM it doesn't need to copy it into RAM because it can directly access it without special register instructions, so the PROGMEM isn't needed.


text:
Xbee not activate on arduino micro
I have 2 nodes: one is a PC+arduino mega+xbee the other one is arduino micro+xbee.
The 2 xbees are communicating fine, I have tested this with 2 separate arduinos.
My problem is that when the second xbee hooked up to the micro it seems it does not try to send or receive data from the serial lines.
It is connected to the first RX/TX pins in proper order (RX->Tx, Tx->Rx) on the micro.
This is obvious for me because if I start my program's setup section on the ardu with:
void setup()

{
  Serial.begin(9600);
  while (!Serial);

The whole main program won't be running because the serial just never gets ready only if I plug my PC in.
When I try to send data from the PC->micro through xbee I see the Xbee receives it (led goes on the board) but nothing happens on the micro.
The micro right now is set to periodically send some debug data through the serial, I don't get that back either otherwise I would see the serial TX led on the micro blinking that it is sending the data. It only works when the PC is connected through USB.
Do I need some additional code for the xbee or is it require a hardware modification? I use a 5V-3V ttl converter as an extra hardware.

From the Arduino site: Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.

It is probably because you are using the only Serial to communicate to both the devices - your PC and XBee. At any instant, you can communicate to only one device. So you might need an extra serial to get you go.
And, may be due to this conflict you can see TX led blinking. May be it's communicating with anyone of them, and the other one is receiving garbage.

From your description, it kind of hard to figure out which arduino doesn't react. Maybe a picture would help.
If it is the arduino that is connected to the PC then the problem is that the serial connection is already used to talk to te PC and therefore can't be used to talk to the XBee. you'll need to use one of the other serial connections on the atmega (serial1, 2 or 3)
Mind you that you don't need a microcontroller to connect an XBee to the PC. A simple UART to USB converter is enough.


text:
What are the Ramps pins on my Arduino mega?
I've been working on a 3D printer and I've come to the last step, which is wiring it all up.
The 3D printer I'm making works ONLY with the Arduino Mega. No Ramps. If I need to get Ramps later, I will, but for now, can someone please help me understand which of the Ramps pin goes with which Arduino pin. For example, in the Repetier firmware, the code is like this:
#define X_STEP_PIN         54
#define X_DIR_PIN          55
#define X_ENABLE_PIN       38
#define X_MIN_PIN           3
#define X_MAX_PIN           2

But Arduino doesn't have a 54 and a 55 pin. I've been googling this and I found that Ramps pins 54 - 69  are the same as pins A0 - A15 on the Arduino Mega.
I know this but not for the other pins...
Can someone please tell me the connection of all the Ramps pins to the Arduino pins?
Like: pin 54 on Ramps = A0 on Arduino. I need this for all of the pins.

As explained in schematic, we have Rx and Tx pin and d2* and d3*. If we check in arduino mega pin outs, Rx is D2 pin. this creates the confusion, please explain me the difference between D2 and D2*

You are right, your have all the information in your question.
Pin 54 Refers to the Arduino PIN Number, nothing to do with RAMPS.
0-53 are the digital pins and the 54 is A0, etc.
So the pin numbers should go higher than 69, which is A15.

You're very close to your answer.  Here are the specifics:
Name      software pin  Mega2560 board label
X_STEP_PIN    54         Analog A0
X_DIR_PIN     55         Analog A1
X_ENABLE_PIN  38         Digital 38
X_MIN_PIN     3          PWM 3
X_MAX_PIN     2          PWM 2

http://reprap.org/mediawiki/images/3/3f/Arduinomegapololushieldschematic.png shows the mapping.

thanks,
but when I insert the pins for the X axis directly on the mega, I doesnt work. I'm using a driver.