text:
I have a question,an error occured in my code saying TIMSK was not declared in the scope(There are no errors)
#include <SmartInventor.h>

void setup() {
  SmartInventor.DCMotorUse();

}
void loop() {
  // M1, M2, M3
  // CW, CCW, STOP
  // 0-100
  // 0-360

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(5000);

  SmartInventor.DCMotor(M1, CCW, 10);  //Music starts  //0:00:06
  delay(2000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(11000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0); //Music stops   //0:00:32
  delay(10000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(5000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(1000);

  SmartInventor.DCMotor(M1, CW, 10); //Music starts back up    //0:00:44
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(18000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(3000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 10);
  delay(8000);

  SmartInventor.DCMotor(M1, CW, 10); //Music stops   //0:01:15
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(5000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(3000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0); //Music starts up agian   //0:01:31
  delay(11000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0); //Music stops     //0:02:03
  delay(23000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0); //Music starts up agian   //0:02:14
  delay(12000);

  SmartInventor.DCMotor(M1, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(6000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(6000);

  SmartInventor.DCMotor(M1, CCW, 10); //Music Ends    //0:02:40
  delay(2000);

  SmartInventor.DCMotor(M1, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M1, STOP, 0);
  delay(3000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(5000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000)

  ;SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(13000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(13000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(13000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000)

  ;SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CCW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(2000);

  SmartInventor.DCMotor(M2, CW, 10);
  delay(2000);

  SmartInventor.DCMotor(M2, STOP, 0);
  delay(7000);

}

A different user asked the same question a few days ago. Are you this user? As written in the comments for these questions, you should always include the full error message into the question. "There are no errors" is just wrong, simce you mention the error right before that

For which board are you compiling the code? And provide a link to the smartinventory library

The SmartInventor library is only for the Rokit Smart board. Why are you trying to use it with an Arduino Mega?

The SmartInventor library is to be used with the Rokit Smart board. That board is based around the ATMega32.
The Arduino Mega is not a Rokit Smart board, so the library will not work, since the Arduino Mega us based around the ATMega2560. The two chips are different, and have different sets of internal peripherals. So the registers have different names accordingly.

Ok so what board can I use for Rokit smart

The Rokit Smart.

Im just gonna write a new code for the mega2560 Arduino board. Can you guys tell me how to write the same code that I did with Rokit smart but in  the Arduino language

That all depends what it is you are trying to do, and what you are trying to do it to.

can I code of this typehttps://www.bing.com/videos/search?q=coding+two+dc+motors&&view=detail&mid=A6D70717250191472167A6D70717250191472167&&FORM=VRDGAR&ru=%2Fvideos%2Fsearch%3Fq%3Dcoding%2520two%2520dc%2520motors%26qs%3Dn%26form%3DQBVR%26sp%3D-1%26pq%3Dcoding%2520two%2520dc%2520motors%26sc%3D0-20%26sk%3D%26cvid%3D6A02585DECEB4033ADC28846E118035B for the mega board

Probably. Again: what are you trying to control? The Mega is just the brain. You must have something connected to it.

3 DC motors. But is 1 and 3 the same thing like Rokit smart? If it is than ill code 2 motors on one board and the other motor on another board.

No clue. How are you connecting the motors? You must have since kind of motor shield. I suggest you start by looking at the examples given by the manufacturer of that shield.

Yah I do have a motor shield

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


text:
Arduino and Solenoid Water Valve
I use Arduino UNO and two SPST Relay (Wemos Mini D1 Relay) to make the reverse polarity circuit. I use this circuit to open and close the Solenoid Water Valve (SWV), which work with 9 to 12 volt. The connections are as follows:
NO (Relay1) --> NC (Relay2) --> +12 Volt
NC (Relay1) --> NO (Relay2) --> 0
D1 (Relay1) --> D1 (Relay2) --> Digital pin 3 of Arduino
COM (Relay1) --> SWV1
COM (Relay2) --> SWV2
GND Relay1) --> GND (Relay2) --> GND of Arduino
5V (Relay1) --> 5V (Relay2) --> 5 Volt of Arduino

the circuit work perfectly with Arduino boar. But the problem is that when I use ATMEGA328p-PU on breadboard as explained in LINK, Relays are not working properly. Actually, relays connecting and disconnecting continuously when ATMEGA328p sends 1 to D1 pins of Relays.
The point is when I de-attach the SWV, relays work properly. but if the SWV is connected it still is not working.
I've checked the connection many times and they are correct.
I used the following code in arduino:
int Relay = 3;
void setup() {
  // put your setup code here, to run once:
  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  digitalWrite(Relay, HIGH);
  delay(2000);
  digitalWrite(Relay, LOW);

}

Any help is highly appreciated.
Thanks in advance.

Could you show a schematic (or drawing) and a photo please. When someone puts a atmega328p on a breadboard for the first time and adds a relais or motor, then it almost never works. There are currents going the wrong way, there is a lot of noise, peak pulses bounching through the breadboard, unstable crystal, and so on.

I did exactly the same as the link mentioned in the post.

sigh... In typical Arduino fashion, the "official" documentation is woefully inaccurate and misleading. Oh dear. I wish they would stop trying to produce these tutorials - they make our lives so hard...

what is a reverse polarity circuit?

Are you using latching solenoid valves? Try using an H-bridge to reverse the polarity.

The problem is most likely EMI (electromagnetic interference) from the switching of the inductive load by the relays.
The fact that you have your setup on a breadboard means that each and every pin of the ATMega328 is connected to a little antenna. That massively increases its susceptibility to falling prey to EMI.  Add to that the fact that there is absolutely no decoupling of the power supply (thanks to Arduino producing shoddy worthless tutorials) makes the whole chip very fragile.
When running with a real Arduino board you have decoupling on the power which helps to reduce induced power rail bounce which can cause the chip to fail.
There are two things that can help mitigate this:

Add decent decoupling to the ATMega328

This means adding capacitors between each VCC pin and ground. At the bare minimum a 100nF capacitor on each VCC pin is needed. Additionally a 1nF capacitor can be beneficial. A 10µF capacitor should also be added on the breadboard's power rails to act as a board-level reservoir.

Snubber networks on the switching

A snubber network, in its most simple form, is a resistor and capacitor in series.  It is placed across the switching terminals of a device that is switching an inductive load to absorb the sudden spike of back-EMF from the collapsing magnetic field whenever the load is switched off.

simulate this circuit – Schematic created using CircuitLab
Note that the capacitors here should be rated for at least 400V since the voltages involved are quite high.

An inductor can create large pulses of power when turned off and on such as in a relay or a solenoid.  A flyback diode is usually added across inductors to suppress these pulses.  Indeed if you look at the schematic of the Wemos Relay Board used in this project you see where D1 is used in just such a way.  Unfortunately the voltage is being applied in both directions across the solenoid so a flyback diode can not be used directly across the solenoid.  However, it may be possible to add a flyback diode before the relays where the voltage is not reversing.
It is almost always better to mitigate electrical noise such as Electromagnetic Field (EMF) interference at its source.  Hence the flyback diode.  However, many combination logic and processor designers add decoupling capacitors as close as possible to the power terminal of each logic chip. This may be the reason a real Arduino board works while the bread board does not.

If the case that you mentioned is a problem the circuit with Arduino board should have not worked while, as I've mentioned, it works properly and the problem is with ATMEGA328 on breadboard.

The way I understand it, the solenoid is galvanically isolated from the Arduino by the relays. Thus no back-EMF can get to the Arduino. More likely it is EMI from the switching arcs crashing the ATMega on the breadboard due to a lack of proper decoupling and power management which the Arduino "tutiorial" (hah!) completely lacks. As always, Arduino completely misleads their poor users with the garbage they produce in the name of "tutorials".

@user42037 I will modify my answer to reason out why a real Arduino board works while your bread board does not.  But, please note, it is almost always better to mitigate electrical noise at its source.  To do otherwise almost always takes more effort.

source: Stack Exchange

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

sort: votes


text:
Need help on Arduino as ISP
If I use an Arduino board to bootload a new chip, is it still possible to use the microcontroller on the board for another project, or it will only be for bootloading new chips.

There are more ways to flash a bootloader to new AVR chip. To which you refer? If you replace the chip on Uno to burn a bootloader to it with a programmer, then it is very unclear what you are asking, because the original chip is not involved in this process.
If you ask about ArduinoISP sketch, then simply it is a sketch. You upload it as any other sketch and replace it with any other sketch.


text:
expected unqualified-id before '.' token
//my coding
#include<DHT.h>              // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(14,15,16,17,18,19);
#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3);

#define dht_dpin 12
#define heart 13

DHT dht;

char *api_key="0UXHCZ777V0PAWPW";     // Enter your Write API key from ThingSpeak
static char postUrl[150];
int humi,tem;
void httpGet(String ip, String path, int port=80);

void setup()
{
 lcd.begin(16, 2);
 lcd.clear();
 lcd.print("   Humidity   ");
 lcd.setCursor(0,1);
 lcd.print("  Measurement ");
 delay(2000);
 lcd.clear();
 lcd.print("Circuit Digest ");
 lcd.setCursor(0,1);
 lcd.print("Welcomes You");
 delay(2000);
 Serial1.begin(9600);
 Serial.begin(9600);
 lcd.clear();
 lcd.print("WIFI Connecting");
 lcd.setCursor(0,1);
 lcd.print("Please wait....");
 Serial.println("Connecting Wifi....");
 connect_wifi("AT",1000);
 connect_wifi("AT+CWMODE=1",1000);
 connect_wifi("AT+CWQAP",1000);
 connect_wifi("AT+RST",5000);
 connect_wifi("AT+CWJAP=\"1st floor\",\"muda1884\"",10000);
 Serial.println("Wifi Connected");
 lcd.clear();
 lcd.print("WIFI Connected.");
 pinMode(heart, OUTPUT);
 delay(2000);
 t.oscillate(heart, 1000, LOW);
 t.every(20000, send2server);
}

void loop()
{
***DHT.read11(dht_dpin);     error in this line***
  lcd.setCursor(0,0);
  lcd.print("Humidity");
 **humi=DHT.Humidity;**   error in this line

  lcd.print(humi);   // printing Humidity on LCD
  lcd.print(" %    ");
  lcd.setCursor(0,1);
  lcd.print("Temperature");
**tem=DHT.Temperature;**  error in this line
  lcd.print(tem);   // Printing temperature on LCD
  lcd.write(1);
  lcd.print("C   ");
  delay(1000);
  t.update();
}

void send2server()
{
  char tempStr[8];
  char humidStr[8];
  dtostrf(tem, 5, 3, tempStr);
  dtostrf(humi, 5, 3, humidStr);
  sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
  httpGet("api.thingspeak.com", postUrl, 80);
}

//GET https://api.thingspeak.com/update?api_key=0UXHCZ777V0PAWPW&field1=0
void httpGet(String ip, String path, int port)
{
  int resp;
  String atHttpGetCmd = "GET /"+path+" HTTP/1.0\r\n\r\n";
  //AT+CIPSTART="TCP","192.168.20.200",80
  String atTcpPortConnectCmd = "AT+CIPSTART=\"TCP\",\""+ip+"\","+port+"";
  connect_wifi(atTcpPortConnectCmd,1000);
  int len = atHttpGetCmd.length();
  String atSendCmd = "AT+CIPSEND=";
  atSendCmd+=len;
  connect_wifi(atSendCmd,1000);
  connect_wifi(atHttpGetCmd,1000);
}

void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    lcd.clear();
    lcd.print(cmd);
    Serial.println(cmd);
    Serial1.println(cmd);
    while(Serial1.available())
    {
      if(Serial1.find("OK"))

      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  {
   Serial.println("OK");
        lcd.setCursor(0,1);
      lcd.print("OK");
  }
  else
  {
   Serial.println("Error");
         lcd.setCursor(0,1);
      lcd.print("Error");
  }
}

The arduino example seems to suggest you have the capitalization the wrong way around. Try  #include <dht.h> and dht DHT; instead.

You declare an object of type DHT and name dht. Then you try to call a method of DHT.read11().
Instead, you should be using the object name, dht.read11(), or as @Gerben points out, change the way you declare the object:  DHT dht;.


text:
Why can't the new Arduino IDE 1.6.7 compile extern "C"?
Consider:

I having a problem in compiling in extern "C" code in the Arduino IDE 1.6.7 which I don't have on version 1.6.5.
The error is:

error: conflicts with new declaration with 'C' linkage

It is complaining about the lines containing loop() and start_timer(void);.
This is my code:
#ifdef __cplusplus
extern "C" {
#endif

void start_timer(void);

#ifdef __cplusplus
}
#endif

void start_timer(void)
{
    Serial.println("2");
    Serial.begin(9600);
    delay(2000);
}

void setup()
{
    start_timer();
    Serial.println("4");
}

void loop()
{
    Serial.println("1");
    delay(2000);
}

Please edit the code and provide the error/warning from the compiler.

I can't reproduce that. Please post your full code as Mikael Patel suggested, and the error message. That is: a Minimal, Complete, and Verifiable example

I already updated my previous post

Why do you need to declare C linkage for a symbol directly in your script?

I can't reproduce your problem still. See this:

However if you are having problems (and frankly I expected you to) then you should read this:
How to avoid the quirks of the IDE sketch file pre-preprocessing
How the IDE organizes things

I can reproduce your problem in IDE 1.6.5 (not 1.6.7). The code generated by the IDE preprocessor is this:
#line 1 "sketch_jan11a.ino"
#ifdef __cplusplus
#include "Arduino.h"
void start_timer(void);
void setup();
void loop();
#line 2
extern "C" {
#endif

void start_timer(void);

#ifdef __cplusplus
}
#endif

void start_timer(void)
{
    Serial.println("2");
    Serial.begin(9600);
    delay(2000);
}

void setup()
{
    start_timer();
    Serial.println("4");
}

void loop()
{
    Serial.println("1");
    delay(2000);
}

You can see that in the automatic function prototype generation that the IDE "helpfully" generates for you, it puts the prototype for start_timer outside the extern "C" declaration. Thus one function prototype has a declaration in C++ format, and the other in C format.
Why are you even doing this? I presume this is a small example of a larger problem.
If you follow the suggestions in my link How to avoid the quirks of the IDE sketch file pre-preprocessing - did you read that? - the problem goes away, because .cpp files in IDE tabs are not subjected to this extra processing.

Please refer to the about image that i just attached for the issue that i'm facing. If i put the whole "start_timer()" function into the extern "C" then i will be working fine.

Which operating system are you using?

See amended reply for more info.

The compiler is telling you that there is a conflict between the two definitions of start_timer().
The normal usage of extern "C" is in a header file for functions that are accessed from both C and C++. This actually has to do with how C++ handles names and overloading. Using extern "C" will use normal C name handling and C++ name mangling is turned off (together with overloading, etc).
Please see https://stackoverflow.com/questions/31349865/compiler-error-for-conflicting-variable-declarations-conflicts-with-new-declar.

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


text:
DHT11 and Pulse sensor incompatibility?
I am working on an IoT project to send data acquired from DHT11 and PulseSensor to a website. I can send the data properly when I use each of sensors alone but when I write a wrapper to use both sensors simultaneously, DHT11 returns check-sum error. PulseSensor uses interrupt based on TIMER2 , whenever I remove interruptSetup(); from setup block the problem is solved but obviously the PulseSensor does not work in this case.
I searched inside the DHT11 library, as far as I could understand it does not use any Timer or interrupt to make a conflict with PulseSensor requirements.
This project use to serial port to communicate with PC for debugging and another one to communicate with ESP8266.
Please help me in finding a solution for this problem. Or guide me to websites that Arduino gurus track more :)
#include <SoftwareSerial.h>
#include <stdlib.h>
#include <dht.h>

dht DHT;
//DHT11 PIN
#define DHT11_PIN 5
// LED
int ledPin = 13;

// Heart_Sensor_Variables
int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 10;                // pin to blink led at each beat

// Volatile Variables, used in the interrupt service routine!
volatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS
volatile int Signal;                // holds the incoming raw data
volatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false;     // "True" when User's live heartbeat is detected. "False" when not a "live beat".
volatile boolean QS = false;        // becomes true when Arduoino finds a beat.

//ISR variables
volatile int rate[10];                    // array to hold last ten IBI values
volatile unsigned long sampleCounter = 0;          // used to determine pulse timing
volatile unsigned long lastBeatTime = 0;           // used to find IBI
volatile int P =512;                      // used to find peak in pulse wave, seeded
volatile int T = 512;                     // used to find trough in pulse wave, seeded
volatile int thresh = 525;                // used to find instant moment of heart beat, seeded
volatile int amp = 100;                   // used to hold amplitude of pulse waveform, seeded
volatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM
volatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM

//function Prototypes
void interruptSetup(void);

//Thingspeak API key
String apiKey = "REMOVED FOR SECURITY REASONS";

// connect 11 to TX of Serial USB
// connect 12 to RX of serial USB
SoftwareSerial ser(11, 12); // RX, TX

// this runs once
void setup() {
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);

  // enable debug serial
  Serial.begin(57600);
  // enable software serial
  ser.begin(57600);
  // reset ESP8266
  Serial.println("AT+RST");

  // sets up to read Pulse Sensor signal every 2mS
   interruptSetup();
}

// the loop
void loop() {
  // blink LED on board
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);

//Read DH11 Data
  int chk = DHT.read11(DHT11_PIN);

// DISPLAY DATA
switch(chk) {
  case 0: ser.println("OK"); break;
  case -1: ser.println("Checksum error!"); break;
}

  ser.print(DHT.humidity, 1);
  ser.print(",\t");
  ser.println(DHT.temperature, 1);

if (QS == true){     // A Heartbeat Was Found
  ser.println("BPM and IBI have been Determined");
  ser.println(BPM, 1);
  ser.println(IBI, 1);

                       // BPM and IBI have been Determined
                       // Quantified Self "QS" true when arduino finds a heartbeat
        digitalWrite(blinkPin,HIGH);     // Blink LED, we got a beat.

        QS = false;                      // reset the Quantified Self flag for next time
  }

  // TCP connection
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149"; // api.thingspeak.com
  cmd += "\",80";
  Serial.println(cmd);
  delay(1000);

  if(Serial.find("Error")){
    ser.println("AT+CIPSTART error");
    return;
  }

  // prepare GET string
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr +="&field1=";
  getStr += String(DHT.humidity);
  getStr +="&field2=";
  getStr += String(DHT.temperature);
  getStr +="&field3=";
  getStr += String(BPM);
  getStr +="&field4=";
  getStr += String(IBI);
  getStr += "\r\n\r\n";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  Serial.println(cmd);
 delay(500);
  if(Serial.find(">")){
    Serial.print(getStr);
  }
  else{
    Serial.println("AT+CIPCLOSE");
    // alert user
    ser.println("AT+CIPCLOSE");
  }

  // thingspeak needs 15 sec delay between updates
  delay(16000);
}

void interruptSetup(){
  // Initializes Timer2 to throw an interrupt every 2mS.
  TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
  TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER
  OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
  TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
  sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED
}

// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.
// Timer 2 makes sure that we take a reading every 2 miliseconds
ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
  cli();                                      // disable interrupts while we do this
  Signal = analogRead(pulsePin);              // read the Pulse Sensor
  sampleCounter += 2;                         // keep track of the time in mS with this variable
  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise

    //  find the peak and trough of the pulse wave
  if(Signal < thresh && N > (IBI/5)*3){       // avoid dichrotic noise by waiting 3/5 of last IBI
    if (Signal < T){                        // T is the trough
      T = Signal;                         // keep track of lowest point in pulse wave
    }
  }

  if(Signal > thresh && Signal > P){          // thresh condition helps avoid noise
    P = Signal;                             // P is the peak
  }                                        // keep track of highest point in pulse wave

  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT
  // signal surges up in value every time there is a pulse
  if (N > 250){                                   // avoid high frequency noise
    if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){
      Pulse = true;                               // set the Pulse flag when we think there is a pulse
      digitalWrite(blinkPin,HIGH);                // turn on pin 13 LED
      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS
      lastBeatTime = sampleCounter;               // keep track of time for next pulse

      if(secondBeat){                        // if this is the second beat, if secondBeat == TRUE
        secondBeat = false;                  // clear secondBeat flag
        for(int i=0; i<=9; i++){             // seed the running total to get a realisitic BPM at startup
          rate[i] = IBI;
        }
      }

      if(firstBeat){                         // if it's the first time we found a beat, if firstBeat == TRUE
        firstBeat = false;                   // clear firstBeat flag
        secondBeat = true;                   // set the second beat flag
        sei();                               // enable interrupts again
        return;                              // IBI value is unreliable so discard it
      }

      // keep a running total of the last 10 IBI values
      word runningTotal = 0;                  // clear the runningTotal variable

      for(int i=0; i<=8; i++){                // shift data in the rate array
        rate[i] = rate[i+1];                  // and drop the oldest IBI value
        runningTotal += rate[i];              // add up the 9 oldest IBI values
      }

      rate[9] = IBI;                          // add the latest IBI to the rate array
      runningTotal += rate[9];                // add the latest IBI to runningTotal
      runningTotal /= 10;                     // average the last 10 IBI values
      BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM!
      QS = true;                              // set Quantified Self flag
      // QS FLAG IS NOT CLEARED INSIDE THIS ISR
    }
  }

  if (Signal < thresh && Pulse == true){   // when the values are going down, the beat is over
   digitalWrite(blinkPin,LOW);            // turn off pin 13 LED
    Pulse = false;                         // reset the Pulse flag so we can do it again
    amp = P - T;                           // get amplitude of the pulse wave
    thresh = amp/2 + T;                    // set thresh at 50% of the amplitude
    P = thresh;                            // reset these for next time
    T = thresh;
  }

  if (N > 2500){                           // if 2.5 seconds go by without a beat
    thresh = 512;                          // set thresh default
    P = 512;                               // set P default
    T = 512;                               // set T default
    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date
    firstBeat = true;                      // set these to avoid noise
    secondBeat = false;                    // when we get the heartbeat back
  }

  sei();                                   // enable interrupts when youre done!
}// end isr

The DHT requires some precise timing on its one-wire interface e.g. a >40us HIGH pulse == 1, while a <40us HIGH pulse == 0. Your DHT library doesnt use interrupts directly but it does use micros() which is based on regular interrupts, which are disabled automatically when you are within the TIMER2 ISR (no need for your explicit cli() and sei(), by the way). If you waste too much time in your ISR, you'll miss bits/pulses on the DHT line and obtain incorrect data, hence your checksum error.
The simplest solution I can think of is to disable the TIMER2 interrupt before the read11() call and enable it again after. I dont have much experience with AVR interrupts but I think this small change should do it:
#define TIM2_EN() (TIMSK2 = 0x02)
#define TIM2_DIS() (TIMSK2 = 0x00)

// your code as usual

void loop(){
  // ...as before...

  TIM2_DIS(); //Enable TIMER2 Interrupt

  //Read DH11 Data
  int chk = DHT.read11(DHT11_PIN);

  TIM2_EN(); //Disable TIMER2 Interrupt

 //...as before...
}

// your code as before

You are totally right. I applied your suggestion and it solved the problem. There is no more check-sum error after disabling TIMER2 interrupt.Thank you. By the way, Do you have any general methodology in your mind to avoid this kind of conflicts when installing several sensors? I mean is there any pattern to follow in writing flaw-less codes?

@PuyaAmiri The only way is to take care to understand the workings of the libraries you depend on, else some unknown detail will blindside u. Libraries for sensors that employ SPI may clash if they use different SPI modes for example. Or libraries for sensors that use SoftwareSerial will require u to listen() to each port in turns. Interrupts, as you've seen, can also be problematic in subtle ways. If you will be using a bunch of libraries written by others and not your own code, then its essential that u get at least some general understanding of how they work.

// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.
// Timer 2 makes sure that we take a reading every 2 miliseconds
ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
  cli();                                      // disable interrupts while we do this
  Signal = analogRead(pulsePin);              // read the Pulse Sensor

Interrupts are automatically disabled in an ISR.
Don't do lengthy things in an ISR (like analogRead). That takes 104 µs when an ISR should take only a few µs.

But when a kind of exact signal sampling is needed the first thing that comes to my mind is using a TIMER and writing corresponding ISR . So, you mean it is possible to use timer over flow flag out of ISR ?!

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


text:
Arduino ,How I can see the value (0 or 5) on my screen, where I connected my sensors output to analog input A0,A1.. pins
I am working in my project and I want to see the output of my sensors as (0 or 5).
The maximum read was 770 and the minimum read was 0. So, how can I see the  value (0 or 5) on my screen, where I connected my sensors output to analog input A0, A1 pins.
I did the following code, but it didn't work:
void setup(){
Serial.begin(9600);
}
void loop()
{
if (analogRead(0)<385)
      Serial.print("0");
 else
      Serial.print("5");
      Serial.print('  ');

if (analogRead(1)<385)
      Serial.print("0");
   else
      Serial.print("5");
      Serial.print('  ');

if (analogRead(2)<385)
      Serial.print("0");
  else
      Serial.print("5");
      Serial.print('  ');

if (analogRead(3)<385)
      Serial.print("0");
  else
      Serial.print("5");
      Serial.print('  ');

if (analogRead(4)<385)
      Serial.print("0");
  else
      Serial.print("5");
      Serial.print('  ');

if (analogRead(5)<385)
      Serial.print("0");
  else
      Serial.print("5");
      Serial.print('  ');

delay(1500);
}

Note: I have 5 light sensors in my circuit.

Try this code - it should help you see what is going on more clearly:
const int threshold = 385;

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

void loop()
{
  int reading = analogRead(0);
  Serial.print("Analog 0 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  reading = analogRead(1);
  Serial.print("Analog 1 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  reading = analogRead(2);
  Serial.print("Analog 2 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  reading = analogRead(3);
  Serial.print("Analog 3 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  reading = analogRead(4);
  Serial.print("Analog 4 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  reading = analogRead(5);
  Serial.print("Analog 5 reads ");
  Serial.print(reading);
  Serial.print(" - this maps to ");
  if (reading < threshold){
    Serial.println("0");
  } else {
    Serial.println("5");
  }

  Serial.println();

  delay(1500);
}

Excellent - please mark the question as answered in that case.

I have no idea what you are trying to achieve there, but I can tell you that without an analogRead or digitalRead statement in there, you're not going to be reading anything other than the values of the variables you set at the top. If you have a new question, please ask it separately.

Your code has multiple issues.
if (analogRead(1)<385)
      Serial.print("0");
   else
      Serial.print("5");
      Serial.print('  ');

Note that Serial.print('  '); is not at all the same as Serial.print("  ");

Also, by the indentation it looks like you should be using braces. Amended code:
if (analogRead(1)<385)
      Serial.print("0");
   else
      {
      Serial.print("5");
      Serial.print("  ");
      }

Without the braces only the first statement after the else is conditionally executed.
If I am wrong about that, you should indent differently, eg.
if (analogRead(1)<385)
      Serial.print("0");
   else
      Serial.print("5");
Serial.print("  ");


text:
Unable to read any SMS's other than the first SMS using SIM908 shield
I'm using two SIM908 shields to communicate with each other. One of the shields will be connected to a sensor and it should send values contentiously to the second SIM908 (receiver). I'm facing a problem on the receiver side, I'm only able to receive the first SMS and when sending a new SMS it displays the older one.
The code that I'm using is from (cooking-hacks.com) where I bought the shield. In the original code the instructions were in void setup function so I  moved them to void loop function to keep checking for new SMS and print any received values. I also made other minor changes. Here is the code
int8_t answer;
int x;
int onModulePin= 2;
char aux_string[30];
char SMS[200];
float fSMS;
char data[20];

void setup() {
  pinMode(onModulePin, OUTPUT);
  Serial.begin(115200);
  Serial.println("Starting...");
  power_on();
}

void loop() {
  Serial.println("Setting SMS mode...");
  sendATcommand("AT+CMGF=1", "OK", 1000);
  // sets the SMS mode to text
  sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"", "OK", 1000);
  // selects the memory
  answer = sendATcommand("AT+CMGR=1", "+CMGR:", 2000);
  // reads the first SMS (since all other messages are deleted from previous delete statement)
  if (answer == 1) {
    answer = 0;
    while(Serial.available() == 0);
    // this loop reads the data of the SMS
    do {
      // if there are data in the UART input buffer, reads it and checks for the answer
      if(Serial.available() > 0) {
        SMS[x] = Serial.read();
        x++;
        // check if the desired answer (OK) is in the response of the module
        if (strstr(SMS, "OK") != NULL) {
          answer = 1;
        }
      }
    }while(answer == 0);
    // Waits for the answer with timeout
    SMS[x] = '\0';
    /*  strtok(SMS, ",");
    strtok(NULL, ",");
    strtok(NULL, ",");
    strtok(NULL, "\n");
    strcpy(data,strtok(NULL, ""));*/
    Serial.println(SMS);
    //Serial.println(data);
    /*    fSMS= atof (data);
    Serial.println(fSMS, 5);*/
  } else {
    Serial.print("error ");
    Serial.println(answer, DEC);
  }
  Serial.println("AT+CMGDA= \"DEL ALL\"");
  //delete all messages from SIM card
  delay(5000);
}

void power_on() {
  uint8_t answer=0;
  // checks if the module is started
  answer = sendATcommand("AT", "OK", 2000);
  if (answer == 0) {
    // power on pulse
    digitalWrite(onModulePin,HIGH);
    delay(3000);
    digitalWrite(onModulePin,LOW);
    // waits for an answer from the module
    while(answer == 0){
      // Send AT every two seconds and wait for the answer
      answer = sendATcommand("AT", "OK", 2000);
    }
  }
}

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {
  uint8_t x=0,  answer=0;
  char response[100];
  unsigned long previous;
  memset(response, '\0', 100);
  // Initialice the string
  delay(100);
  while( Serial.available() > 0) Serial.read();
  // Clean the input buffer
  Serial.println(ATcommand);
  // Send the AT command
  x = 0;
  previous = millis();
  // this loop waits for the answer
  do {
    // if there are data in the UART input buffer, reads it and checks for the answer
    if(Serial.available() != 0) {
      response[x] = Serial.read();
      x++;
      // check if the desired answer is in the response of the module
      if (strstr(response, expected_answer) != NULL) {
        answer = 1;
      }
    }
    // Waits for the asnwer with time out
  } while((answer == 0) && ((millis() - previous) < timeout));
  return answer;
}

Did you get an answer to this? Looking to find solution to similar problem.
It gets stuck at the first AT command it encounters. Is there any special library that needs to be included? Thanks


text:
Using the Waspmote Sensor Board
Spanish company Libelium makes this pretty impressive sensor board:
http://www.libelium.com/products/waspmote/sensors/
for their Waspmote series of boards.  These are not meant for Arduino compatibility, but they are not only interesting for combining so many sensors, the availability of calibrated sensor sets makes it even more unique.
So here is the challenge: can we reasonably leverage these from an Uno or a Mega?

Look at some of their docs: http://www.libelium.com/development/waspmote/examples/ga-11-co-sensor-on-socket4-reading/ seems like they have a very similar platform to Arduino.

Their forums suggest making the connection is not trivial, but may be possible:  http://www.libelium.com/forum/viewtopic.php?f=15&t=8811

They talk about XBee and WiFi connections in one of the datasheets and there is an API later in the PDF docs... Yet I read that it might be hard... (Direct quote from 0xF2's comment) Compatibility between Arduino and Waspmote's sensor boards is not direct, since the connectors' pinout do not correspond, you'd have to wire the connections using the documentation. Anyway, I'm afraid the Libelium's sales policy implies a minimum first order including five Waspmotes, five batteries and one Gateway. | @sachleen Maybe it is powered by Arduino with a few libraries...

Too long for a comment...
Look at some of their docs for examples. seems like they have a very similar platform to Arduino.

Their forums suggest making the connection is not trivial, but may be
  possible: http://www.libelium.com/forum/viewtopic.php?f=15&t=8811

All that's saying is you can't simply plug in a sensor into your Arduino like a shield, because it's not a shield. You'd have to hook up the connections to the right pins and then use their libraries and code to communicate with it.
That involves reading their documentation and code to figure out what pins it uses to communicate with what. You may have to modify the code slightly to work with Arduino (mainly changing pin numbers).
All in all, I wouldn't invest my time or effort into it. Don't lock yourself into a product that isn't intended to be used the way you're using it. You'll get no support from the company and there's no guarantee future versions of their product will work. Or things like this (from the forum link):

Anyway, I'm afraid the Libelium's sales policy implies a minimum first
  order including five Waspmotes, five batteries and one Gateway.

Simply not worth the effort. You'd be much better off making your own sensor board to fit your requirements.

Now you can purchase single boards through MicroConrollerShop.com
http://microcontrollershop.com/product_info.php?cPath=297_566&products_id=6773


text:
Is it possible to program an Arduino Pro Mini using an Arduino Uno R3?
I've recently received an Arduino Pro Mini as a gift, and I don't have an external USB programmer to program the Pro Mini. However, I do own an Arduino Uno R3, and I think it would be possible because they both have the same clock speed and micro-controller (16Mhz with an atmega328).
Is it possible to program an Arduino Pro Mini using an Arduino Uno?
If yes, how does one do so?

Which Pro Mini is it, 3.3V or 5V? I guess this must be the 5V one as I think the other one (3.3V) works only at 8MHz.

Just hook up the pins (RX, TX, reset, Power, and Ground) to the corresponding pins on your Uno.
You may have to take the ATMega328 out of your Uno for this to work.
Keep in mind that you need to hook it up to the correct power pin! If your pro mini is running at 3.3v then you must hook it up to the 3.3 pin on your Uno.
Check out the ArduinoToBreadboard page for a bit more info. Scroll down to "Uploading Using an Arduino Board". Although it shows you how to program an Arduino on a breadboard, the wiring is the same.

You should remove the ATmega328 from the board. There is a vague chance that it would work without doing so, but chances are even if it superficially worked, you would get errors.

I've gotten it to work consistently as I have the SMD uno. Had to manually reset, though.

This one did not work for me.

you can program with an SMD board, you dont link the reset line, hold down the reset on the uno throughout the whole process, and tap the reset on the mini soon as the ide says upload to upload the sketch, by holding the uno in reset it doesn't interfere with the serial comms

Worked like a charm. I kept pressing on RESET for the whole duration of uploading, from before plugging Arduino until having finished uploading. Works great. Thanks a lot.

There is another method by which you can upload your sketch programs.  Program the UNO with the "Arduino as ISP" sketch and connect the pro mini via the SPI pins (plus reset line).  See "Upload with Programmer" on the Arduino website and elsewhere on the internet including stack exchange.  This method will allow you to use the full memory of the chip and avoid using the bootloader, but you will need to upload with SPI each time.


text:
Error in Compiling
The error shown is
C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function `__vector_7':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of `__vector_7'
C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here
collect2.exe: error: ld returned 1 exit status

Why is this happening?
The code is:
#include <IRremote.h>

const int echo = 7;// connected to ultrasonic sensor's echo
const int trig = 8;// connected to ultrasonic sensor's trig
const int Right1 = 10;
const int Right2 = 11;
const int Left1 = 12;
const int Left2 = 9;// change this to any other pin; except pin 13
const int buzzer = 5;
const int rightIR = 3;// change here
const int leftIR = 2;// change here
int RECV_PIN = 4;
const int forward = 51;
const int backward = 36;
const int left = 19;
const int right = 0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  pinMode(buzzer, OUTPUT);
  pinMode(echo, INPUT_PULLUP);
  pinMode(rightIR, INPUT_PULLUP);
  pinMode(leftIR, INPUT_PULLUP);
  pinMode(trig, OUTPUT);
  pinMode(Right1, OUTPUT);
  pinMode(Right2, OUTPUT);
  pinMode(Left1, OUTPUT);
  pinMode(Left2, OUTPUT);
  sing(1);
  Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver

}

void loop() {
  digitalWrite(13, HIGH);
  if (calcDistance() > 30 && !isRight() && !isLeft())
  {
    if (irrecv.decode(&results))
    {
      Serial.println(results.value, HEX);
      irrecv.resume(); // Receive the next value
      delay(50);
    }
    else {
      moveForward();
    }

  }
  else
  {
    delay(10);
    int dist = calcDistance();
    if (dist < 30 && isLeft() && isRight())
    {
      Serial.println("Moving backward");
      tone(buzzer, 4699, 10);
      moveBackward();
      delay(1000);
    }
    else if (isLeft())
    {
      turnRight();
      digitalWrite(13, LOW);
      tone(buzzer, 104, 10);
      Serial.println("Turning Right");
    }
    else if (isRight())
    {
      turnLeft();
      digitalWrite(13, LOW);
      delay(300);
      tone(buzzer, 880, 10);
      Serial.println("Turning LEft");
    }
    else if (dist < 30)
    {
      turnRight();
      digitalWrite(13, LOW);
      tone(buzzer,  104 , 10);
      Serial.println("Turning Right");
    }

  }

  delay(20);
}

Can you get a more readable shot of the messages? Or cut-and-paste them? This image is pretty difficult to read.

C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function __vector_7': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of __vector_7'
C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here
collect2.exe: error: ld returned 1 exit status

As the error message says you have multiple definitions of __vector_7 which is defined in: IRemote.cpp:361 and Tone.cpp:536
Tone.cpp is arduino standart lib. If IRemote is a lib of yours then you should edit the cpp file and change the symbol to sth else.

The IRemote.cpp and Tone.cpp would be using the same interrupt vector. I believe it's ISR(TIMER5_COMPA_vect) {

You could. I don't think it's the best solution, but go to Tone.cpp and comment the ISR(TIMER5_COMPA_vect) { like /*ISR(TIMER5_COMPA_vect)*/void XunusedX(void) {. And be sure to never use any function from ...
You could also try to find a way on how not to invoke Tone.h with core.a. include <Tone.h> could be replaced with //include <Tone.h>
You could use another timer in IRRemote.h

This answer is better than mine :)


text:
How to use an Arduino Uno + Keyboard Firmware to make a "N Key Rollover" Game Pad
Hello I have flashed my Arduino Uno with USB keyboard firmware from this tutorial http://mitchtech.net/arduino-usb-hid-keyboard/#comment-6786, and I have been successful sending individual key presses but, not when trying to press an hold a key. I am attempting to use this firmware to create a custom Game Pad to USB adapter, the only issue is sending simultaneous keystrokes (not sending them one at a time). If you know how to accomplish this task I would be very happy. The technical term for this is "Key Rollover"

Howmany buttons are you checking and to which pins do you have them connected?

My game pad has 12 buttons, and they are connected with shift registers so only 3 pins. Checking the button states isn't the issue. I am trying to use the game pad as a keyboard with the Keyboard firmware from the tutorial above but, to play games I need to be able to press many keys simultaneously.

The easiest option would be to switch to an Arduino that has a USB-capable main MCU, such as the Leonardo.

I understand why this would be a good way to do this since the people from arduino provide a keyboard library for the Leonardo but, with my arduino uno I have already got to be plug n' play as a keyboard. The problem is getting more than one button press at a time. I need to add simultaneous key presses "Key Rollover"

After closer research on this topic I have found the answer to my problem but,thank you to all that have tried to help. In order to do "Key Rollover" I needed to write the additional key states to the remaining values of the buffer array then write the values with Serial.write(buf,8). I can now use my Arduino Uno + My Game Pads as controllers for all my computer games.

Could you post an example of your updated code?  I'm working on a similar project but a complete n00b as far as using the Arduino goes.

You don't want to send random keys do you?
Well consider using the code below as your base.
It's using Port Manipulation to read the buttons (Digital 0 to 7).
void setup()
{
  Serial.begin(9600);//Start serial connection.
  DDRD = 0b00000000; //Set Data Direction Register of port D to inputs (attach keys to digital pins 0to7;
  delay(200); //Misc delay.
}

void loop()
{
  Serial.write(PIND, 8);    // Send states of PORTD (digital 0 to 7)
}

I strongly suggest you use pull-down/up resistors on the buttons also.
Adjust your code to the amount of keys you're using, or pull the pins low if not used. To avoid receiving random/floating pin values.

The problem is not with the '328P itself but with the communications channel with the USB chip.

@IgnacioVazquez-Abrams Thanks, I skipped a bit too fast through the article. The new answer should fit the needs of the 'asker'.

Sorry, this is not what I am having issues with. I have all ready have the game pad and have been able to read the input values from the controller. When I press one button sending the keystroke is easy. It is when I need to have many key presses as held keys. Other wise the game will think I am repeatedly pressing different buttons.

Than you should only send the state of your key when it's changed?


text:
Multiple node network communication over I²C
I am working on a project where I want to send data from and to different Arduinos on a network. At the moment I²C seems the best option for my needs since I can specify where to send the data. But using this method I have a bit of an issue I can't seem to find a solution for :(.
I will try to explain my problem using the following image:

In the backend all the nodes are connected like in the first image (above the example network). But the nodes may be connected in a different sequence by a user. See the example network.
In this example network, the node with ID 1 needs to send data to ID 10 and not to any other node on the network. Node ID 12 also needs to send data to node ID 10, but no other nodes. Etc. Etc. Etc. But the node that needs to send data to the next node doesn't know the id of the node it needs to send to.
So at first the nodes need to find out what nodes they are connected to and where they need to send their data.
I thought of doing this by connecting a wire between each node (blue wire in possible solution) and when a node gets added to the network the nodes send a high signal over the blue wire and sends its ID to all nodes on the network and then all nodes on the network check if they receive a high signal and an ID.
If this is true they will send its id to the node that has been added. This works fine if you add a node one by one to the network. But it fails when you replace a node in the middle of the network or disconnect power from the network.
What would be the best way to do this (I am also open to use different data transfer protocols)?

Do nodes really need to know which node is next door?

i think yeah because I2c requires an adres where it needs to transmit its data to. (and the node must only send its data to the node that is physically next) But if you think it is not necessary let me know

What purpose does the concept of "next door" achieve?

it makes sure the data goes through the network in chronological order

What do you mean "through the network in chronological order"?

With I2C your master communicates with a slave. It doesn't care where on the bus that slave is.

If you look at the example network the node with ID 1 must only send its data to the node with ID 10 and not to the nodes with other ID's. It is just something i want

So you send it to node 10.

Or are you looking to avoid bus contention in a multi-master scenario?

Yes indeed but node ID 1 doesnt know that to node it needs to send to has ID 10 how do i figure that out?

But you just stated that 1 has to send to 10.

yes what you just said is the problem

Let us continue this discussion in chat.

It sounds (after discussion) like what you are after is actually a mesh of multiple peer to peer devices.  That is, lots of devices, each one has multiple dedicated communication links each directly going to another device.
If you had enough UART ports you could create individual UART links between nodes. The bets Arduinos only have a handful of those, and the UNO only one.  So that's not really practical.
You could possibly do it with SPI if you wanted to put a lot of work in to developing a decent control protocol to go along with it.  Something along the lines of BUSRQ/BUSACK signalling:
BUSRQ: Signalling line pulled HIGH by resistor. All nodes INPUT.
BUSACK: Signalling line pulled HIGH by resistor. All nodes OPEN-DRAIN & LOW.
SS: Direct 1:1 GPIO links between nodes - all pulled HIGH. All nodes INPUT.

Node 1                   Node 2                  Node X
RELEASE BUSACK
DRIVE BUSRQ (OD Low)     Sees BUSRQ fall         Sees BUSRQ fall
                         RELEASE BUSACK          (could be busy...)
                                                 RELEASE BUSACK
Sees BUSACK rise
DRIVE BUSACK
SS Node 2 LOW            Sees SS go LOW
Send SPI data            Receives SPI data
SS Node 2 INPUT          Sees SS go HIGH
RELEASE BUSRQ                                    Sees BUSRQ rise
                         Sees BUSRQ rise         Drive BUSACK
                         Drive BUSACK

Only once all nodes have released BUSACK will the requesting node be able to send any data, and once a node has released BUSACK it knows that it must never send any data.  The requesting node has basically locked the bus from other nodes accessing it.
It's not perfect, and doesn't handle multiple devices requesting the bus at the same moment, but it does prevent one device trying to send while another is actively sending.


text:
What is the most efficient voltage divider for Arduino?
I need to make voltage divider, so I could read a battery voltage up to 14.4 V. Could I use very high resistance resistors for that, so the current would be very low (to not to discharge battery)?
On the Internet there are examples with 500 - 2000 ohm resistors, but could I use hundreds of thousands to reduce the current to minimum? Would Arduino's analog input still read the value?

I think I've seen power management IO, that could measure current, voltage and provide its readings through I2C line. So it might be the correct way how to do it. INA3221?

This sounds like a project that isn't going to do what you think it is.  Are you trying to build a battery tester?  To tell you if your tool batteries are still good?

The most efficient is not to have a voltage divider at all. Or at least to only have a voltage divider when you actually need one.
My preferred schematic is this:

simulate this circuit – Schematic created using CircuitLab
With this M1 is normally kept turned off by R3. When you want to take a measurement you turn on M2 by setting D3 HIGH (or whatever pin you attached it to) which pulls down the gate of M1 turning it on. This then connects the batter to the voltage divider R1/R2 and allows you to read the voltage at A0.
The voltage divider of 20k / 10k allows you to read up to 15V on the battery, and gives you an output impedance of 6.67kΩ which is within the recommended maximum of 10kΩ for the ATMega's ADC.
During "idle" times when M1 and M2 are both off the only current flowing is the minuscule leakage current through M2 tempered by the large 100kΩ resistor R3 (which itself pales into insignificance compared to the "off" resistance of M2 anyway).
Selecting M1 so that the ON resistance is very small (<0.1Ω) allows you to essentially ignore it in your calculations since that will be swamped by the tolerance of R1 and R2 anyway.  M2 needs to be selected so that it is "logic level" (i.e, with a gate threshold V_GS well below 5V).
This double-FET arrangement should be used rather than just using an N-channel FET in the ground connection of the divider because when that simpler arrangement is turned off the Arduino will be seeing 12V directly connected to A0 which really is not good - you will kill the Arduino - so it is important that you switch the "high" side of the network not the "low" side, and to do that requires two FETs.

What are some jellybean FETs for this purpose?

@PeterMortensen I'd probably use the BSS138P (n channel) and the IRLML5203 (p channel) in a sot-23 footprint.

Yes, you can use very high value resistors for your voltage divider.  But the recommended maximum is 10 kohms for the ADC pins.  So the combined resistance of your two resistors should be maximum 10 kohms.

it is recommended that whatever you connect to the A/D have an output impedance of 10k or less for best accuracy. This is to allow the A/D input capacitor on the sample and hold to charge up in the time allotted to it between switching the input multiplexer over and starting the conversion.

From: Input Impedance of A0-A5

Note that calculating output impedance is not as simple as adding the resistors together. The resistors are actually calculated in parallel not series, so two 20k resistors would give 10k output impedance.

There are more details in another source.

I was able to implement it with 3 MΩ resistors.
The problem is that the readanalog() function executes 10 reads. So the first one is the right value and then you will not measure the right value anymore.
Solution: A voltage divider with 2.5 MΩ and 500 kΩ with a 470 nF capacitor on the 500 kΩ resistor. The solution with the MOSFET is better. This is easier, and it works (but only for 20 years ).

This is a variation on Majenko's design above. It was such a good idea, I couldn't resist submitting this - a reduced-component-count version:

simulate this circuit – Schematic created using CircuitLab
The TPS22810 is a load switch that enables or disables Vout (2.7V ≤ Vin ≤ 18V; Iout ≤ 3A). The output is determined by the EN/UVLO input that may be driven by a 1.8 V, 3.3 V or 5 V GPIO output. This component and the C1 bypass cap replaces 2 FETs and 2 Resistors. The TPS22810 cost is ≈ $0.50 ea. in small quantities.
The TPS22810 will likely find its most useful application as a high-side switch, but it seems to serve the purpose of the OP's need for driving a voltage divider also.

Everybody is missing the point here.  The lower limit on the series resistance of the voltage divider is the self-discharge rate of the battery.  For instance, a Li-ion battery loses about 10% of its charge per month.  For a 3000 mAH 18650 cell, that's about 300 mAH per month, meaning about 300/(30X24) = 0.42mA constant drain.  So, for a 8V stack made of 2 18650 cells in series, we get a total series resistance of 8V/0.42 of about 19K-ohms.  IOW, if I put a 19K resistor across an 8V stack, I would get about the same battery drain as the battery would see if I left it completely alone.  As long as the series resistance is much greater than that, it won't affect the battery life at all.  So, if I use 2ea 50K resistors for a total series resistance of 100K, it will have very little effect on battery life.  2ea 50K resistors will present an effective output impedance of about 25K to the ADC input port on a MCU, and that is low enough so there will be little or no distortion of the measured voltage, and any offset can be easily compensated out in software.  Moreover, if you want to go to a higher division ratio (say 4:1 instead of 2:1) the effective output resistance goes DOWN because it's a parallel circuit from the ADC's POV, but still a series circuit from the battery's POV.  If I use a 75/25K divider for a 4:1 ratio, the parallel output impedance is 18.75K.
So, no need for fancy switching circuits - just choose a series divider with a convenient ratio and with a total series resistance in the 100K range, and you are done.

I don't see any problem with reasonably high resistors (however see below). You are right that they would discharge the battery less.

Would Arduino's analog input still read the value?

Of course, if there was a voltage there to read. Why wouldn't it? A really high resistance might let the reading be affected by stray voltages.
A possible work-around would be to only take the reading occasionally, say, every 10 seconds. You could do this by making the reading be between a couple of Arduino pins, and leave one "floating" until you are ready to read it.
However that is not a good idea for reading a 12V battery. You need the voltage divider to be "active" so you don't have 12V on the Arduino input pin. Majenko's suggestion sounds better in that respect.
I have a lengthy discussion about the ADC on the Atmega328P. Reply #5 on that page discusses how it takes its measurements. This is done by charging a "sample and hold" capacitor. With too high an input impedance the capacitor would charge too slowly, and thus the subsequent sampling would give incorrect readings. A source signal impedance of 10k is recommended in the datasheet, so a voltage divider along those lines would be appropriate.
Majenko's suggestion of 20k + 10k would only involve a 0.4 mA constant current flow through the voltage divider, which for a 12V battery is probably not a huge deal (even without all that switching circuitry).

What is the actual (DC) input impedance?

The input impedance is 100 MΩ, but there are other considerations.

One reason it might not be able to read the voltage is that the Auduino's analog input will put a load on the voltage divider. Assuming the Auduino's input acts like a resister connected to ground (which is only an assumption for purposes of argument), then it will be connected in parallel with the 'bottom' resister of the voltage divider. This will alter the resistance and cause the Auduino to read a lower voltage than expected.

@David42 That's right. In fact I have a lengthy discussion about that (too lengthy to post here) on my page about the ADC in the Atmega328P. I'll edit that link into  my answer.

@NickGammon Reading at your answer and post about ADC, it seems to me that the simple solution proposed by Adriano should work great. That was to add a capacitor in parallel with the resistor connected to ground. What would be the problem of that?

I'm not sure why Adriano says that readanalog() executes 10 reads. The function on the Uno is analogRead() and it only executes one read. I think the best solution is to disable the voltage divider until it's required, as proposed by both Majenko and Seamus.


text:
Connecting Seeeduino XIAO 3.3 V out to dual H-bridge driver module (L298N) with TTL compatible inputs
The H-bridge module uses TTL compatible logic, but the chip allows these values (based on the L298N data sheet):

Symbol
Parameter
Min.
Max.

ViL
Input Low Voltage (pin 5, 7, 10, and 12)
-0.3 V
1.5 V

ViH
Input High Voltage (pin 5, 7, 10, and 12)
2.3 V
VSS

Am I correct to assume that I do not need to step-up the logic signal (from 3.3 V to 5 V) for this to work, but can I connect straight to the input?
Schematic in mind:

You are you using the Seedstudio L298N board, right? not the bare L298N? That board have pull-up resistors on the it, that pull to 5V. Not sure what 5V through a 10kOhm resistor does the the IO pin on a 3.3V MCU. It's probably fine, and it's only an issue while the pin is an INPUT, which it only is till you run your code (only during bootloader and startup).

Am I correct to assume that I do not need to step-up the logic signal (from 3.3V to 5V) for this to work, but can connect straight to the input?

You are correct. The input has to be above 2.3V to register as HIGH and below 1.5V to register as LOW. You have 3.3V for HIGH and near 0V for LOW, which fits those criteria perfectly.

Thank you! I was trying to add "Seeeduino XIAO" as tag but do not have enough points, can you do that? I think it would help.

@MeSo2 No, I won't do that. If we added every board that existed as a tag we'd overload the database. Only the main Arduino boards and very common third party boards ones have tags. The Xiao isn't a common one - I have never heard of it.

Comparatively recent small form factor board using the same chip as the various "zero" boards.  XIAO, specifically, doesn't really enter into the actual question though where its role is just as a 3.3v logic level MCU.

@timemage So, it's YAABB...  Yet Another ARM Based Board...

Yes, though it seems to be gaining a following; it may eventually warrant a tag for dealing with its actual eccentricities.  Perhaps not yet.

@timemage Maybe I should add the tag "yaabb" ;)

Could not resist up-voting that. =)

@timemage "For general I/O pins: Working voltage of MCU is 3.3V. Voltage input connected to general I/O pins may cause chip damage if it' higher than 3.3V." found here: Seeeduino XIAO

@Majenko is there any issue with the Seedstudio L298N board having pull-up resistors to 5V.

@Gerben typically there's no problem. The resistor drops the current to 170uA which is far below the rating of most ESD protection diodes... (looking at the SAMD21 datasheet 1mA is the worst case minimum, and 720uA is below that.)

@MeSo2, I get that, but I'm unclear on why you're saying this to me.

@timemage I think he's confusing input and output....

@Majenko, if I had to guess, I'd say he may be under the impression that a XIAO is somehow different from an Arduino Zero (which uses the same microcontroller) with respect to the 3.3v signals; it isn't.

@timemage XIAO pin 1, 2, 8 - 11 will be used as outputs. I never used an Arduino, but got my feet wet using a propeller microcontroller back in 2014.


text:
Trying to read a 93lc46b chip using Arduino
I am trying to read a 93lc46b EEPROM chip using Arduino. I am reusing the code from http://owlsan.blogspot.de/2012/10/accessing-93c4693c46n-serial-eeprom.html, except I have modified it for 93lc46b chip, plus I am using Arduino Uno and not Arduino Mega. The problem I am facing is, I get different set of bytes every time I try to read 93lc46b EEPROM chip. I doubt this might be some garbage data. Can you please explain me what and where exactly I am doing something wrong. The modified code snippet is as follows:
#include <avr/io.h>
#include <util/delay.h>

#define CLEAN 0b00000000

#define DDR93LC46B  _SFR_IO8(0x04)
#define PORT93LC46B _SFR_IO8(0x05)
#define PIN93LC46B  _SFR_IO8(0x03)

#define SK 13
#define DO 12
#define DI 11
#define CS 10

#define READ 0x02

#define SET_CS PORT93LC46B |= (1 << CS)
#define CLR_CS PORT93LC46B &= ~(1 << CS)

#define SET_SK {PORT93LC46B |= (1 << SK); _delay_us(0.01);}
#define CLR_SK PORT93LC46B &= ~(1 << SK)

#define SET_DI PORT93LC46B |= (1 << DI)
#define CLR_DI PORT93LC46B &= ~(1 << DI)

class SPI_93LC46B {
  private:
    uint8_t Transfer(uint8_t data) {
      SPDR = data;
      while(!(SPSR & (1 << SPIF))); // Wait for SPI interrupt flag
      return SPDR;                  // Return byte gathered from SPI data register
    }
    void Opcode(uint8_t opcode, uint8_t address) {
      SET_CS;
      SPCR &= ~(1 << SPE);               // SPI disable
     _delay_us(1);
      CLR_SK;
      SET_DI;                            // Send start bit
      SET_SK;
      CLR_SK;
      SPCR |= (1 << SPE);         // SPI enable
      Transfer((opcode << 6) | address); // Transmit byte
    }
  public:
    SPI_93LC46B() {
      SPCR =    CLEAN        // Set SPI control register
         & ~(1 << SPIE)  // SPI interrupt disable
         |  (1 << SPE)   // SPI enable
         & ~(1 << DORD)  // MSB first
         |  (1 << MSTR)  // SPI master device
         & ~(1 << CPOL)  // SPI
         & ~(1 << CPHA)  //  mode 0
         |  (1 << SPR1)  // XX/64 MHz
         & ~(1 << SPR0); //  speed
      SPSR =    CLEAN         // Init SPI status register
         & ~(1 << SPI2X); // SPI double speed
      DDR93LC46B =    CLEAN      // Set up inputs/outputs
             |  (1 << SK)  // Serial clock output
             |  (1 << DI)  // Data input (MOSI) output
             |  (1 << CS)  // Chip select output
             & ~(1 << DO); // Data output (MISO) input
      PORT93LC46B |= (1 << DO); // Data output (MISO) high
      CLR_DI;
      CLR_CS;
      CLR_SK;
     _delay_us(1);
    }
    ~SPI_93LC46B() {
      //
    }
    uint16_t Read(uint8_t address) {
      uint16_t data = 0;
      Opcode(READ, address);
      CLR_DI;
      SET_SK;
      CLR_SK;
      SPCR |=  (1 << CPHA);
      data = Transfer(0);
      data = (data << 8) | (Transfer(0));
     _delay_us(1);
      CLR_CS;
      CLR_DI;
      SPCR &= ~(1 << CPHA);
      return data;
   }
};

void setup(void) {
  Serial.begin(115200);
  _delay_ms(100);
  Serial.println("EEPROM writing/reading");
}

void loop(void) {
  Serial.println("new round");
  SPI_93LC46B _93LC46B;
  int i;
  uint16_t data;
  for(i = 0; i < 64; i++) {
    data = _93LC46B.Read(i);
    _delay_ms(50);
    Serial.print(data, HEX);
    Serial.print(" ");
    if((i + 1) % 8 == 0)
      Serial.println();
  }
  _delay_ms(10000);
}

This code is over complicated and has a lot of errors. Let us start with the obvious. Look closely at this section. Do you see the error(s)?
#define SK 13
#define DO 12
#define DI 11
#define CS 10

#define READ 0x02

#define SET_CS PORT93LC46B |= (1 << CS)
#define CLR_CS PORT93LC46B &= ~(1 << CS)

#define SET_SK {PORT93LC46B |= (1 << SK); _delay_us(0.01);}
#define CLR_SK PORT93LC46B &= ~(1 << SK)

#define SET_DI PORT93LC46B |= (1 << DI)
#define CLR_DI PORT93LC46B &= ~(1 << DI)

The symbols SK, D0, DI, CS seem to be pin numbers but look how they are used in the SET_XX and CLR_XX macros. That is very wrong. They should be the bit numbers in the PORT register instead.
There is more. How about this?
_delay_us(0.01);

What is the intention? _delay_ns(10)??? In any case yet another error.
Cheers!


text:
Too many Bytes Using Ultrasonic Sensors
I need to send one transmission and record multiple distances with 4 receivers, but everytime I use more than 2 receivers, the serial data does not print. What can I do?
P.S. I'm using 5 SRF-02 Sensors, 1 transmitter and 4 receivers all via I2C.
#include <Wire.h>

#define cmdByte 0x00                                 // Command byte
#define rangeByte 0x02                             // Byte for start of ranging data

byte highByte = 0x00;                                // Stores high byte from ranging
byte lowByte = 0x00;                                // Stored low byte from ranging
int range = 0;
int rangeData;

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

void loop() {
   D0_1= getRange(0x70, 0x71);
   Serial.println(D0_1);
   D0_2= getRange(0x70, 0x72);
   Serial.println(D0_2);
   D0_3= getRange(0x70, 0x73);
   Serial.println(D0_3);
   D0_4= getRange(0x70, 0x74);
   Serial.println(D0_4);
}

 int getRange (uint8_t send_address, uint8_t rec_address)
 {
  Wire.beginTransmission(rec_address);
  Wire.write((uint8_t)cmdByte);
  Wire.write((uint8_t)0x56);
  Wire.endTransmission();

  Wire.beginTransmission(send_address);             // Start communticating with SRF02
  Wire.write((uint8_t)cmdByte);                         // Send Command Byte
  Wire.write((uint8_t)0x5C);        // Transmit an 8 cycle 40khz burst - no ranging takes place
  Wire.endTransmission();

  delay(80);                                                           // Wait for ranging to be complete

  Wire.beginTransmission(rec_address);       // start communicating with SRFmodule
  Wire.write((uint8_t)rangeByte);                 // Call the register for start of ranging data
  Wire.endTransmission();

  Wire.requestFrom(rec_address, 2);            // Request 2 bytes from SRF module

  while(Wire.available() < 2);                    // Wait for data to arrive
  highByte = Wire.read();                           // Get high byte
  lowByte = Wire.read();                           // Get low byte

  range = (highByte << 8 ) + lowByte;              // Put them together

 delay(120);

 return(range);                                                    // Returns Range
 }

My magic crystal ball tells me that.... You didn't even say what ultrasonic sensor you are using!

Whoops, my apologies, I'm using SRF-02 sensors.

Now it's easier ;) Did you check the addresses on the bus? Check also the LEDS (see here for the led coding). And... Can you timeout when the I2C does not reply? Check with the main library or try to use a software one which does timeout...

the LEDS don't blink if I try to use more than 3 receivers.

@Umbus your code doesn't compile. Missing declarations of D0_x variables. Also did you changed the addresses of 4 sensors to 0xE2, 0xE4, 0xE6, 0xE8 and tested every single one alone? Did they respond correctly?

If the leds blink when you put 2 of them and don't if you put 3, then the prblem is 1) the power supply or 2) the pullups on the I2C. You put only two resistors (one on SCL and one on SDA) right?

i dont use resistors

@Personagem it compiles on my computer with a slight error and will run, and all the sensors have the right address, I've checked the blinking lights


text:
Board recommendations for GPRS/GSM for 'on the go'
I have been tasked to find a way of communicating to a webservice from my microcontroller - yay!
With little-no real grasp on sms/etc (due to not ever 'using' it before), it appears that my knowledge of GPRS is, well, none existent.
So, I've come here in hope that someone could tell me if there is such a way for a microcontroller to 'send data out' though, well, a 'sim card' via an sms message.

This has left me a little lost If i'm honest.
My project involves 'tracking' a vehicle (still working on finding a GPS module for that), and then sending the coordinates back to HQ at hourly intervals (via text message).
So, My obvious question is this: What GPRS sim card module will allow me to do this?
I read here, although the accepted answer there for a chip requires external power, and so is of no 'true' use to me as the whole unit needs to be powered and left 'unattended' for long hours at a time.
seeing as I also need to 'monitor current location' of the board, I am also in need to obtain a GPS location.
I was thinking that mobile phones have both of these cababilitys - is this done with a 'sim card module', or is there a way of 'one module does both - send an sms AND can also gain current GPS location'?

Sorry if this is too broad, but I'm certainly not 'gifted' in knowing too much about these technologies (esp. when all these acronyms use similar letters).
Any advice / input here would be very helpful.

I have a project that have the same idea that yours.
I used Ublox NEO-6M GPS Module for GPS tracking, the module cost in a range from $6 to $13 USD(it depends from where the seller ships, china o USA) in EBAY. You can connect it via UART.
For the internet I used a SIM800L V2.0 5V Wireless GSM GPRS MODULE, you can buy it from EBAY too, it cost no more than $10.00 USD, and you can connect to internet or send SMS using AT commands.
I used a combination of arduino and Raspberry pi zero, also I send the GPS data to a webserver (I pay 5dllr/month for a VPS) and then I can track using google maps.
Thats the basic information, you can use it to start working.


text:
Reverse turning of Stepper motor
I have a stepper motor connected to my Arduino like this using the ULN2003A Darlington Array:

(Ignore the potentiometer)
And I have programmed it with the following code:
#include <Stepper.h>

int in1Pin = 22;
int in2Pin = 23;
int in3Pin = 24;
int in4Pin = 25;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
    pinMode(in1Pin, OUTPUT);
    pinMode(in2Pin, OUTPUT);
    pinMode(in3Pin, OUTPUT);
    pinMode(in4Pin, OUTPUT);

    motor.setSpeed(25);
}

void loop()
{
    int steps = 360;

    motor.step(steps);
    delay(500);
}

At the moment the motor rotates clockwise, how could I have it so it rotates in the opposite direction?
My code was copied and edited from here.

The problem was that I had the two middle wires the wrong way round as said here: http://forum.arduino.cc/index.php?PHPSESSID=kvi8dt2b5en5hhk02dlmjrotl5&topic=143276.msg

The answer is simple. Just pass a negative number of steps as an argument to motor.step();.
Another note: You forgot a semicolon on your second to last line. IIRC this doesn't matter in C, but it's just bad practice to do this. If you add a line of code below that, then it won't work.
Example code:
#include <Stepper.h>

int in1Pin = 22;
int in2Pin = 23;
int in3Pin = 24;
int in4Pin = 25;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
    pinMode(in1Pin, OUTPUT);
    pinMode(in2Pin, OUTPUT);
    pinMode(in3Pin, OUTPUT);
    pinMode(in4Pin, OUTPUT);

    motor.setSpeed(25);
}

void loop()
{
    int steps = 360;
    motor.step(steps);
    delay(100);

    steps = -360;
    motor.step(steps);
    delay(500); //Semicolon added
}

Thanks about the semicolon, I was copying out my code in a rush. Also, I've tried a negative number of steps but it doesn't work.

@user12321 I'm not quite sure. Does it compile? This page says that a negative number will go the other way. All I can say is to make sure you copied all of the code right. I can't tell what "doesn't work" means.

Well it compiles and runs but carries on rotating in the same direction

I found the solution at the here: forum.arduino.cc/index.php?PHPSESSID=kvi8dt2b5en5hhk02dlmjrotl5&topic=143276.msg109779#msg109779. I had the wires the wrong way round.

@user Does the negative work then?

Yeah, it works like a dream!


text:
What is the diffrence between following arduino boards and which should i buy?
Arduino UNO R3 Compatible Board ATmega328P ATmega16U2
http://www.ebay.in/itm/UNO-R3-ATmega328P-ATmega16U2-Compatible-Board-For-Arduino-with-USB-Cable-/201367107680?pt=LH_DefaultDomain_203&hash=item2ee26a3860
Arduino UNO R3 ATmega328P USB Development Board CH340G
http://www.ebay.in/itm/UNO-R3-Development-Board-SMD-Chip-Arduino-Compatible-/301653217776?pt=LH_DefaultDomain_203&hash=item463beed1f0
I will be working on a windows 7 32 bit pc.

The first is an unofficial clone of an R3 using the same schematic as the real R3.  The second is a rough copy using a cheaper USB serial interface chip.
Neither of them are real Arduino boards.  The first one is closer to the real UNO and should do the same things that a real UNO should do (assuming it works at all).  The second one - well, who knows?  You certainly can't do any of the fancy things to the USB interface that you can with a real UNO R3.
Which should you buy? Well, really, you shouldn't buy either of them - but if you must go for one I'd pick the first one.  Better to buy a real UNO from Arduino though, at least then you know what it is you're getting, and you expect it to work.  With these cheap Chinese clones (Chinduinos) you may just get a bunch of counterfeit chips selotaped to a piece of cardboard.

You can't say 'selotape' anymore. The politically correct term is "sticky tape and promises".


text:
How do I remotely acquire data from Arduino based portable device?
I am making a device which will have an Arduino board and a sensor attached to it. The sensor will acquire data every 10 minutes and the data will be uploaded to my server. The size of every upload is about 200 characters. I'd like this device to work anywhere in my city (US).
What are my options for uploading data to my server? Keep in mind that it will work without human intervention. FYI... this is NOT for reconnaissance device! ;)

I can't guarantee anywhere in your city, but this hack will work pretty much wherever there is cell coverage for the carrier you choose.
You'll want the GSM shield.

Picture from Arduino
Anyway, it uses pins 2, 3, and 7 on it. It also has the ability to solder (on the bottom of it) a microphone and speaker connection. You'll need to buy a SIM card and a contract to connect your shield to a network. I don't know how often you would use this, but I've seen a pay-as-you-go plan that charges you $2 for unlimited talk/text/internet per day. If you're going to use this once a month, that would be the way to go. I didn't look to see if they supported the GSM shield (it was on TMobile's site). You would want to contact them for more details. Also, depending on where you live, I don't know if you would get good coverage. This goes with any cell phone provider, but make sure that you get coverage where you want to go (and don't always trust the maps they provide).


text:
How to connect more than 10 sensors to Arduino uno r3
How I can connect more than 10 sensors to Arduino Uno R3? I calculated it and I can connect just 4 fire flame sensors (sensors which can find a fire (a candle, for example)) and maybe 1 ultrasonic sensor. I need more for my project. I need an IR Sensor, a fire flame sensor on every side, and 1 ultrasonic sensor in front. Additionally, I need to connect 2 DC motors, 1 fan, and 1 servo-motor for ultrasonic sensor. How can I solve this? I must buy Arduino Mega?

Make a bus with protocol and some bus-devices :)

And if you don't want to make a bus:
Count the pins/protocols you need to use. Make a nice diagram out of it. And judge you requirements

Please want to know how to read the recording on a computer.Am a beginner

do you know how to solve the aforementioned problem with multiplexer TCA9548A?

You can easily increase number of I/O pins using an expander, e.g. PCF8574.
The expander can be connect using your SCL/SDA pins located next to GND/AREF pins. (Here you can find detailed photo: http://forum.arduino.cc/index.php?topic=84190.0) You can connect up to 8 such expanders to extend the number of your digital pins to 64. Once you connect it, here is a code snippet of how to use it:
#include <PCF8574.h> //library available at: https://github.com/skywodd/pcf8574_arduino_library

void setup() {
  PCF8574 sensors;
  sensors.begin(0x20); //0x20 means that you connected A0, A1, A2 pins of PCF8574 to the ground
  sensors.pinMode(0, INPUT_PULLUP);
  sensors.pinMode(1, INPUT_PULLUP);
/*...*/
}
void loop() {

  byte sensorValue = sensors.digitalRead(0); //reads digital value of 1st sensor connected to pin 0 of PCF8574 expander
  /*...*/
}

You can read more with this tutorial (note: they are using wire interface, so the code will differ. Choose the one you prefer).

I wouldn't recommend multiplexing, but I do agree that one way is to add a second MCU.
Another better option is to use an N-bit shift register.  These are little IC's that are exactly what the name entails: shift registers, and are much easier to setup and interface to than wasting a whole other microcontroller to add I/O's or multiplexing (which limits your application).  You effectively shift in the I/O settings that you want and then can latch those registers when you have the proper I/O sequence loaded into the register.  In other words if I wanted to have 8 new I/O pins, I could connect an 8-bit shift register to my MCU and if I wanted 4 of the first pins HIGH and the last 4 low, I would shift in 00001111b, then latch the data so that it appears on the output just as if it were any regular I/O pin on the MCU.
They only require a few pins to operate them (, so this is an easy way to add more sensors to your system.  As always, check the datasheet to make sure the IC meets your specs (in terms of current draw, voltage, etc).
A disadvantage to this is that for an N-bit shift register, you will burn N clock cycles to load in the data.  For most applications this should be fine, but it is worth noting.  It also makes for slightly more complex code (although I am sure there are libraries for them out there).
Note: I saw that you mentioned controlling things such as DC motors, etc.  Make sure you are not trying to directly drive them with the I/O pins, and are using a switch or transistor to control these types of peripherals.

The Mega is the easiest way to get many pins is, as you said, the Mega. It has many other advantages, such as more amperage, more memory, and more UART ports. I highly recommend doing this route for a beginner, even if you get a clone instead of an official board. If none of this would be an advantage to you, there are a few different things.

Second MCU. You can get another chip identical to the Uno's to connect. This is called an ATmega standalone. They're fairly cheap. I2C is the easiest way to connect them, using only two pins from each chip. The setup will depend on the project.
Multiplexing. There is a way that you can connect more stuff than there is pins on the Arduino. This is called multiplexing. It does affect performance a little, but for some applications it is worth it. Note: this won't work well with libraries or SPI/I2C. The 4051 chip seems like a decent chip. The Arduino playground has good introduction article on this chip..

There are a number of ways to get more inputs and outputs, with different implications.  And it depends on the types of sensors, and on the libraries or code snippets you want to use.
The first thing you need to do is list the sensors you want, along with the type of interface each uses; I use a spreadsheet.
For example, a flame sensor could just use a single digital output (going to a digital input on the Arduino), with the threshold set with a pot on the module.  Or it could output an analog signal which goes to an analog input on the Arduino, allowing the code to detect intensity or set varying thresholds without needing to move the pot.  Each approach has different implications.
There are still other sensor and actuator interfaces besides these two (simple digital and analog).  Some give a variable value (like analog) but based on timing a pulse on a digital signal; this is how most inexpensive ultrasonic rangefinders work.  And of course there are sensors which use standard (I2C or SPI) or proprietary (one-wire protocol, or the DHT-xx temp & humidity sensors).
Likewise some outputs will need PWM or other signally, beyond simple on/off.
Extra simple digital inputs, or outputs, can be had fairly easy with I2C extenders, or with shift registers.  For example, checking a digital output flame sensor, or turning on a light.
Extra analog inputs can be done with analog multiplexing (like an electronic switch), or via external ADC modules using I2C or SPI.
If timing is required, there are larger potential problems. Often you would use a library to handle such things.
Libraries. Most sensor and actuator libraries will be written to use direct input and output pins on the Arduino.  You may be able to pass a pin number when initializing, but if you are using a shift register or extender there's no way to tell the library how to use your custom extension.  In this case you will have to roll our own code without using the library, or make a modified version of the library which does I/O through your hardware extension hardware.
Special Pin Functions. A second problem is special pin functions; if the library or code snippet you want to use expects to use a special feature of a pin (like a pin interrupt, or a timer input capture), that may not be available from your extension hardware, or may be extra work to handle.  For example, some extenders may be able to signal an interrupt pin on the Arduino when one of their inputs changes - but you'll have to write your own interrupt handler to catch that, and replace the functionality of the direct pin interrupt.
Timing.  And a third problem is that sometimes tight timing is hard to manage through extension hardware.
Most of these can be resolved with appropriate effort, sometimes easy and sometimes not.  Look through your list of sensors and actuators; sort out which ones can most easily be attached to extension hardware (like a shift register), and which ones should be directly attached to the Arduino for simplicity or performance.  You could be lucky.
Recommendations
1) If you can handle any fancy sensors or actuators with direct pins, and cover any simple ones with shift registers or I2C extender chips, that's a viable option.  For example, if your code wants to check occasionally whether a flame has been sensed (digital version), or wants to turn on a motor, it's not that hard to go through a shift register instead of doing a direct pin access.
2) If you go beyond that, and run out of pins for things that are much easier to handle when directly connected, then I suggest going to a Mega or Mega2560.
It has more digital pins and more analog inputs and more PWM outputs.  Most (tho not all) libraries will adapt just by changing pin numbers.  It's much easier than rewriting libraries to use external digital and analog pins.