text:
Arduino radio communications
I have an Arduino and I am building a space satellite, just for fun. I'm not going to launch it obviously.
I have built all the sensors and everything works. I was looking into communication because if a satellite is in space it needs to send down the data.
Is it possible to have radio communication between two Arduino or an Arduino and something else that are 100km apart, it doesn't need to particle, I'm just wondering if it is possible and how it works. Is it possible without going out to buy shields?

There are three basic factors that control long distance communication:

Transmitter Power
Receiver Sensitivity
Signal Directionality

The more transmission power you have the "louder" your signal is at the receiver.
The more sensitive your receiver the "quieter" the signals it can pick up.
The more directional (focussed) your signal is the more arrives at the receiver and the less gets sent off elsewhere.
So you would think get all three of those and you're laughing, but it's not that simple:

High power transmission requires high-power power source
Good focus requires heavy and bulky antennae.

Neither of those are very good on a satellite, since you want it to be as small and light as possible and use as little power as possible.
So in general you have a medium to low power transmitter on the satellite with reasonable directionality, and put all the bulk on earth.  That is why satellite dishes are so big.  They give good focus, and the large size captures a lot of the signal making them more sensitive. You can also use very precise electronics to amplify the signal more.
There is, of course, nothing like that in a shield format, so you would have to create your own. The transmitter isn't so hard, since you don't want to have anything too meaty - the hard part comes when you want to make the base station.  If you can afford enough power to transmit a strong enough signal and have it with enough directionality you can use a satellite TV dish (not a little Sky dish, one of the bigger solid round ones - Sky satellites actually have quite powerful transmitters and the massive solar panels to go with it; not really practical for a small home-built satellite).  Getting the receiver and LNB (Low Noise Booster) tuned properly as well is vital - unless you're transmitting at the same frequency as the satellite the dish is intended to receive (which you mustn't or there'll be a lot of annoyed people around - there are specific frequency ranges you are allowed to use) then you will need to ensure the antenna is exactly the right length and that the LNB amplifies and filters the right frequency range.
Once you have got over all those hurdles the receiver is just a simple receiver.
The actual transmitter and receiver circuits themselves can be something fairly off-the-shelf (the lower the frequency the better since that goes further than higher frequencies) - it's what goes between - the antenna and amplifier - that makes it much more special and long range.

Majenko covered several aspects of radio communications between a satellite and a ground station.  An additional factor to consider is that the azimuth or altitude of a low-altitude satellite changes rapidly as it passes over a ground station.  For example, a satellite 100 km up takes about 86 minutes per orbit and travels at about 7.84 Km/s, and probably would be in view for less than a minute per pass.  [See eg Orbit of a satellite Calculator at casio.com.]  Unless a phased array is used, and assuming communication is highly directional, the big dish on the ground will need to swing at up to 4.5° per second (about 270° per minute) as it tracks the satellite passing over.  The much smaller antenna on the spacecraft should rotate at the same rate, the opposite direction.
Note, an alternative to radio communications is a tight-beam laser system.  Rather than using big, bulky microwave or UHF antennas to achieve directionality, you would use a small telescope (a few cm of aperture) on the satellite and a larger telescope (as much aperture as you can afford) at the ground station.  Infrared or visible light lasers at each end of the link would be modulated to transmit at a high data rate.  Accurate tracking and aiming might end up being important research projects for this approach.


text:
How to emulate an RFID tag with the RC522
Is it possible to emulate an RFID tag with the RC522? (Spec sheet: nxp MFRC522.pdf)
I want the RC522 to act like a NTAG213 nxp.com/documents/data_sheet/NTAG213_215_216.pdf and to be read/write by other readers/writers.
Are there libraries for that purpose?

Hi and welcome to the Arduino.SE site. To better help people answer your query you need to enhance your question with more information. At present it is not clear what you wish to achieve. Can you provide a usage example and more detail about what exactly you want to do?

No. Looking at the datasheet, card emulation is not a feature provided by the RC522.
Another popular chip, the PN532, does seem to indicate support for that feature, however, looking at the most popular library for this chip from Adafruit, it does not implement this feature. Another library from Seeed, does seem to implement it, but it looks rather limited as to which cards can be emulated, and the library itself hasn't been updated in a while.

source: Stack Exchange

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

sort: votes


text:
Bad LCD? Bad microcontroller? Or what?
So I recently bought an Arduino along with an LCD module and two extra ATmega328P-PU ICs. Yesterday it was working just fine then I disconnected everything and reconnected it and this happened.
What could possibly go wrong?
Setup:

with microcontroller that came with the board:

with the microcontroller that a purchase separately:
http://s1072.photobucket.com/user/Tonny_Cassidy/media/Mobile%20Uploads/20160128_012325_zpslavooxa2.jpg.html?filters[user]=143082917&filters[recent]=1&sort=1&o=1

Try wiggling all connections to make sure they are all properly seated in the breadboard and arduino-headers.

Also make sure that you actually connected all the wires up again properly to the right places. And then double check.

Are the wires soldered in place, or pushed into place? Instead of sending people off to PhotoBucket, how about posting the photos here as part of the question? You can embed photos into questions.

So i recently bought an arduino along with lcd module and 2 extra atmega328p-pu ,yesterday it was working just fine then i disconnect everything and reconnect it and this happen, what could possibly go wrong ?

I hope you understand how difficult it is for anyone to help with this type of question.
My quick answer is "follow the schematics and reconnect the wires correctly" and "double check all wires".
From the picture it looks like you need to adjust the LCD contrast and reduce the back-light. Please see typical schematics for this.
Another rule-of-thumb is to use wire colors in a meaningful way. For instance, black for GND, red for VCC, yellow for data, blue for control, green for clock, etc.
Cheers!

reconnected all the wires like 5 times,still the same,even tried changing the pin number that was connected to lcd on arduino,i find that my pin5 was dead so i change it to pin7,only half of the lcd working correctly ,and i have tried changing the contrast

These 16x2 LCDs are fairly sensitive about their power requirements.
As a first step, I would check the VCC and GND wires are well connected, and closely connected on the breadboard near the LCD.
If your LCD display shows rubbish characters, check the 4 data lines are connected in the correct order.
Also it looks like the contrast is at minimum (or LED backlight at maximum).  It could just be the photo, but best check both of these.

it turns out that my board have dead pin(pin5),but even with new microcontroller ,only half of the display works as shown here http://s1072.photobucket.com/user/Tonny_Cassidy/media/Mobile%20Uploads/20160128_012325_zpslavooxa2.jpg.html?filters[user]=143082917&filters[recent]=1&sort=1&o=1

Is it a simple bad solder joint?  Maybe just re-melting the solder will re-connect it.

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


text:
How can Arduino know that the number in a variable is a pin number and not something else?
I have a question with the topic variables.
So, a variable is a place where you can store data.
And when you make a variable with datatype int (int ledpin=13;) then you store a value 10 in a variable named ledpin.
BUT how can the Arduino know it's a pin number 13 from Arduino or a random number 13 that we are storing there?

Was the answer helpful? If so, please accept it by clicking on the "tick" icon next to the answer, and also possibly upvote it. This indicates to other users that you found the answer useful, and it also stops Stack Exchange from periodically "bumping" your question in the hope of getting an accepted answer. Thanks for your understanding and cooperation!

You need to put the correct number into the pinMode() function.
You could put the number into a variable like:
int ledPin = 13;
pinMode(ledPin, OUTPUT);

or you can put a number straight into pinMode() like this:
pinMode(13, OUTPUT);

Whatever number you put in will be the pin that you start using.
Here's an example to blink the onboard LED:
int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);      // Whatever number is in ledPin is made an output.
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

Yes, a variable is just somewhere to store some data.
It's what you do with the variable that is important.
For instance:
int ledpin = 13;
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, HIGH);

That will set the variable ledpin to 13, then the next line will query the ledpin variable to find out what number it is, then pass that number to the pinMode function to set the mode of the pin to OUTPUT. The line after then does the same thing but passes the number 13 that it read from ledpin to the digitalWrite function to turn the LED on.
However, if you do this:
int ledpin = 13;
pinMode(ledpin, OUTPUT);
ledpin = 10
digitalWrite(ledpin, HIGH);

then it will act just the same at first, but the digitalWrite function will get the number 10 not the number 13 since the value in ledpin has been changed to 10 in the third line.
Remember: an integer is just a number - it's only when you do something with that number that it has any meaning.

thank you so much. Finally i got it. It was an great explanation. :)

BUT how can the Arduino know it's a pin number 13 from Arduino or a random number 13 that we are storing there?

The Arduino does not "know" the intention of a variable. The variable "becomes" a pin number when passed as an argument to pinMode() or digitalRead().
The use of a variable to "name" a pin is part of a programming style. There are a lot of examples sketches that try to convey programming style. One of these is to reduce the amount of ripple effects of change; reduce the number of line to change for a logical change.
Continuing the LED pin number example above. The "baseline" code is:
void setup()
{
  pinMode(13, OUTPUT);
  ...
}
void loop()
{
   digitalWrite(13, HIGH);
   ...
   digitalWrite(13, LOW);
   ...
 }

This works just fine BUT what is the ripple effect if we change the pin "13". The example uses symbols OUTPUT, HIGH and LOW which are also just numbers.
Typically in C the tradition is to use the preprocessor and define a macro.
 #define LED 13

The preprocessor will replace LED in the source code with 13 and the compiler sees the same code as above.
An alternative is using a variable.
 int LED = 13;

The drawback is that memory is allocated and it is possible to change the value at run-time which is often a very bad idea especially for a pin. The definition should actually be:
 const int LED = 13;

The drawback with the macro is that it is just a value. In C++ it is best to use a constant variable. This tells the compiler both what data type and value it is. A constant variable cannot be assigned (again).
The next level to strength code quality and reduce ripple effects is to use lexical scope. A lexical scope such as a function body, class or namespace defines "when" a symbol is available.
An example; first global scope where definitions are available across the source code (just as for a macro):
const size_t BUF_MAX = 32;
static char buf[BUF_MAX];

const char* read()
{
   ...
   for (int i = 0; i < BUF_MAX; i++) buf[i] = ...
   ...
}

Local lexical scope; definitions within a function:
const char* read()
{
   const size_t BUF_MAX = 32;
   static char buf[BUF_MAX];
   ...
   for (int i = 0; i < BUF_MAX; i++) m_buf[i] = ...
}

The symbols buffer buf and the buffer size BUF_MAX are only available in the function.
class Reader {
public:
  void read()
  {
    ...
    for (int i = 0; i < BUF_MAX; i++) m_buf[i] = ...
  }
protected:
  const size_t BUF_MAX = 32;
  char m_buf[BUF_MAX];
  ...
};

Again the symbols are only available within the class and member function. Here is also another example of programming style. The prefix m_ is used to show that it is member data.
Last, the same example using a namespace:
namespace Reader {
  const size_t BUF_MAX = 32;
  char buf[BUF_MAX];
  ...
  void read()
  {
    ...
    for (int i = 0; i < BUF_MAX; i++) buf[i] = ...
  }
};
...
for (int i = 0; i < Reader::BUF_MAX; i++) Reader::buf[i] = ...;

All symbols must have the prefix Reader when used outside the namespace.
These techniques have been developed to allow writing larger programs with reuse. It is important to use them when writing a library for Arduino and especially when sharing. Ripple effects and symbol redefinition/collisions are reduced.


text:
Powering Motor doesnt work from Digital Pin, but works on 5V power
I am building a little car project, and I have come across an issue that has made me go mental.
I have a single motor (3V-5V), that on direct 3.3V & 5V output works fine. However, when I connect this to a digital port, it for some reason doesn't power. Of course, I first thought it was not supplying correct power, so I got myself a voltage meter and tried that. 3.3V outputs, well 3.3V, all fine. The digital port outputs 4-5V (when it is coded to). So here is my question: Why aren't my motors powering/turning?

Power is made up of two values, not one. Besides the voltage there is the current (P=VI), and it's the current you are lacking.
A motor needs a large amount of current to start turning (called the stall current) and a digital I/O pin can only supply a relatively small amount (absolute maximum 40mA, recommended maximum 25mA). The power pins though can supply many hundreds of mA.
You should never try and power a motor directly from an I/O pin since you risk damaging the I/O pin.  Instead you should use the I/O pin to control an NPN transistor or N-channel FET, which is then used to switch the power (actually the ground connection) to the motor from one of the power pins.
Here is a good tutorial: http://www.circuitstoday.com/pwm-generation-and-control-using-arduino

authors: Николай Николаевич


text:
How to avoid delays in the loop() function?
vI have this functions in my loop() and it publishes temperature reading to Ubidots(an IoT cloud service) using the #include  library but it seems it returns a boolean and so the loop is delayed until a true or false value is return and this takes a while there by slowing  down my loop() function and other functions in it.
Is there a way I can call this function without it having to slow the loop?
#include <math.h>
#include <Wire.h>
#include <Servo.h>
#include <WiFi.h>
#include <Ubidots.h>
#include "rgb_lcd.h"
#include "Timer.h"
//#include <SoftwareSerial.h>

//SoftwareSerial mySerial(11, 10); // RX, TX

char ssid[] = "ROSTALECOM_6916";                                                 //your network SSID (name)
char pass[] = "6PTDFYJD";                                                         //your network password (use for WPA, or use as key for WEP)
String api = "875c4a17d995ce4977bdfc1ace55233fd0591c7ce";                             //your API Key number
String idvari = "567d623a762542205cbc517f";                                          //the number of the Ubidots variable
String ctext = "{\"color\":\"blue\",\"status\":\"active\"}";
Ubidots ubiclient(api);                                                             //with that you call the api with the prefix ubiclient

byte p5[8] = {
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F
  };

int a;
int temperature;
int B=3975;                  //B value of the thermistor
float resistance;

String readString;
int val;
int hum = 70.35;
unsigned char base = 10;

//Temperature Limits
int maxTemp = 29;
int minTemp = 28.5;

//Declarations
rgb_lcd lcd;
Servo winServo;

//Ubidots timer
Timer t;

void setup()
{
    //Loading character
    lcd.createChar(0, p5);

Serial1.begin(9600);
Serial.begin(9600);
winServo.attach(3);
lcd.begin(16, 2);
//mySerial.begin(9600);

//Start Screen
lcd.print("--SmartGarden--");
for (int i = 0; i < 16; i++)
{
        // scroll one position left:
        lcd.setCursor(i, 1);
        lcd.write((uint8_t)0);
        delay(400);
 }
lcd.clear();
lcd.print("Connecting...");
//connect to  wifi network
boolean response;
int status = WL_IDLE_STATUS;
response = ubiclient.WifiCon(ssid, pass, status, api);
Serial.println(response);

//
t.every(1000, sendToUbi);

}

void readTemp()
{
   a=analogRead(0);
   resistance=(float)(1023-a)*10000/a;
   temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;

   //Send temperature via Bluetooth
   Serial.print(temperature);

   //print temperature to LCD
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Tmp:");
   lcd.print(temperature);
   //print humidity to LCD
   lcd.setCursor(8,0);
   lcd.print("Hm:");
   lcd.print("50");

   delay(1000);

}
void writeServo()
 {
  if (val != 0)
  {
  //val = map(val, 0, 1023, 0, 180);
  winServo.write(val);
  delay(100);
  }
 }

 void sendToUbi()
 {
 ubiclient.save_value(idvari, String(temperature));                                                  //this function is to post to ubidots and return True or False depending on the connection status
 Serial.println("The sensor value " + String(temperature) + " was sent to Ubidots");                //print the sensor value
 }

void timerMax()
{
  for (int i = 0; i < 60; i++)
  {

   }
   winServo.write(180);
 }

void loop()
{
  //read temperature
  readTemp();

  //Update ubidots timer
   t.update();

  while (Serial1.available()) {
    delay(3);
    char c = Serial1.read();
    readString += c;
  }
  if (readString.length() >0)
    {
      Serial.println(readString);
      delay(15);

       val = readString.toInt();
       if (val != 0)
       {
       //val = map(val, 0, 1023, 0, 180);
        winServo.write(val);
       delay(100);
       readString = "";
       }
       //writeServo();

    if (readString == "1")
       {
        digitalWrite(13, HIGH);
       }
     if (readString == "0")
       {
        digitalWrite(13, LOW);
       }
     readString = "";
  }

  if (temperature >= maxTemp)
  {
    timerMax();

  }

}

Please edit your post and format the code using the code formatting markdown (four leading spaces). For help see Markdown help. You should be able to do this by selecting the code and pressing Ctrl+K to have your browser do this for you.

Please edit your post and add links to the libraries you are using. Without these libraries it is very hard for anyone else to understand your code.

Please edit your post and remove confidential API tokens. :D

The tokens were all edited and invalid

See How to do multiple things at once

Also related "How and Why to avoid delay()" (see: http://playground.arduino.cc/Code/AvoidDelay)

How to avoid delays in the loop() function?

The question is why all the delays? Is there some logic missing? What are you trying to design?
Using delays is often a sign of an attempt to synchronize with external events. Wait for additional input, etc.
Let us walk through some of them:
void readTemp()
{
   ...
  delay(1000);
}

What is this about? The function does read an analog input BUT then there is a lot of output to Serial and LCD and last this delay. Why?
void writeServo()
{
  ...
 delay(100);
}

Again the same pattern. Now for your question "delays in the loop()".
void loop()
{
   readTemp(); // hidden 1000 ms delay

  while (Serial1.available()) {
    delay(3);
    ...
  }
  if (readString.length() >0)
  {
     ...
     delay(15);
     ...
     if (val != 0)
     {
       winServo.write(val);  // Possible hidden 100 ms delay
       delay(100);
       ...
     }
     ...
}

Consider using some logic instead of the delays. There seem to be a common pattern you are using.

As short reply and a general note, there is the millis() function that will be faster than a delay(). It returns the number of milliseconds since the Arduino board began running the current program. You use maths to check if you've waited long enough.
Like this:
  // check to see if it's time to do something; that is, if the
  // difference between the current time and last time you blinked
  // the LED is bigger than the interval at which you want to
  // blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // do something after the waiting interval here

   }

Edit: One should also be aware of Interrupts, but be warned they must be used correctly.


text:
MFRC522 Only working sometimes
   /*
 * --------------------------------------------------------------------------------------------------------------------
 * Example sketch/program showing how to read data from a PICC to serial.
 * --------------------------------------------------------------------------------------------------------------------
 * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
 *
 * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID
 * Reader on the Arduino SPI interface.
 *
 * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE
 * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When
 * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output
 * will show the ID/UID, type and any data blocks it can read. Note: you may see "Timeout in communication" messages
 * when removing the PICC from reading distance too early.
 *
 * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading).
 * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all
 * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so
 * keep the PICCs at reading distance until complete.
 *
 * @license Released into the public domain.
 *
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 */

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_PIN          10       // Configurable, see typical pin layout above

MFRC522 MFRC522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
    Serial.begin(9600);     // Initialize serial communications with the PC
    while (!Serial);        // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
    SPI.begin();            // Init SPI bus
    MFRC522.PCD_Init();     // Init MFRC522
    MFRC522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
    Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
  Serial.print("...");
}

void loop() {
    // Look for new cards
    if ( ! MFRC522.PICC_IsNewCardPresent()) {
    Serial.print("IsNewCardPresent");
        return;
    }

    // Select one of the cards
    if ( ! MFRC522.PICC_ReadCardSerial()) {
    Serial.print("ReadCardSerial");
        return;
    }

    // Dump debug info about the card; PICC_HaltA() is automatically called
    MFRC522.PICC_DumpToSerial(&(MFRC522.uid));
}

I have recently purchased a RC522 RFID Module for my Arduino UNO. I connected everything, and started the IDE, downloaded the correct library, and ran the DumpInfo example program. The first time that I ran it, all went well, and when I swiped a card in fro, I recieved the correct data dump.
However, I started it up today, and reset everything, ran a new program to clear the Arduino, restarted my PC, and it still did not work. In the serial monitor it says that all is well, no error messages or anything. But, when I put a card in front of it, absolutely nothing happens.
Any help would be great!

Loose connection?

Definitely not, I made sure that all of them were well connected, and that would have returned an error in the Monitor if one wasn't communicating.

Do you see the firmware number and so on when you run the sketch?

Yes. It says
Firmware Version: 0x92 = v2.0
Scan PICC to see UID, type, and data blocks...

And you have made no changes at all to your code since the last time you got results? Are you using the same card as before? Also swiping/waving it within 5cm of the RC522?

No changes to the code whatsoever. I'm using the same cards and going withing 5cm of the reader.

Should I try and use the ICSP connections instead?

You can try, though this is a weird one. By all indications, bi-directional communications have been established since you can read the version. Also this code has worked for you before (more than once?). Maybe you should try powering it with some other source, Also try placing Serial.print statements in each IF block in the loop() to see if those conditions are responsible.

I tried adding the Serial.print lines, and it just spams the Serial Monitor with isnewcardpresent, meaning that it's going through that loop.I tried swiping a card in front during, but it didn't get out of the loop.

I don't really have the ability to power it from any other place, and i'm not sure where you were going with that.

ran a new program to clear the Arduino - can you explain that bit?

Just clicked the new button on the IDE and ran it while it was connected to the Arduino to clear it.

So, I believe that it is some form of state that the RFID Module goes into when I shut down my comptuter, how would I go about reseting the module?

Just clicked the new button on the IDE and ran it while it was connected to the Arduino to clear it. - and after that, did you load the other program? The RFID one? I don't see any point in loading other code "to clear it". You may as well put a Star Wars DVD into your DVD player "to clear it" before watching something else entirely.

Yes, after that, I loaded the other program. Thank you for the Snarky remark. No, the issue isn't the programming, it's that the module is not resetting correctly after I restart my computer or it goes to sleep. As power is cut to the module, and then restored. I know it's not the program because I'm receiving the firmware version back from the module.

Check your power supply. I've seen so many weird results from inconsistent/under powered circuits. It's worth a look.
What does your circuit look like?
Are you powering the RFID reader from the Arduino or it's own source?
Are the grounds coupled?

I'm powering it from the Arduino, and it's getting ample power supply, as it is sending and receiving data. The grounds are fine.

If I am right then you have soldered the pins of the module yourself and I recommend you to desolder the pins and soldered them again.
I also used RC522 RFID Module with an Arduino and I faced same type of problem with the module. This way worked for me.

The first thing you could try is to increase the baud rate to 115200. I'm using a different library, and in the auth_read_write.ino sketch the Serial.begin() comments says "Read a fast as possible. There is a limit for how long we are allowed to read from the tags".
If changing the baud rate doesn't work, then have a look at this answer: RFID-RC522 not working, red led is on. It has a link to a different library which worked for me.

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


text:
How are HIDs (keyboard,joypad) created and mapped?
I am creating an electronic device that has a 4 position rotator switch and a SPST Momentary ON push button. For the knob, I plan for position 0 to be low (OFF). Position 1-3 are high (ON). But I want these positions to equate to a different signal so they each have different values. When push button is pressed, it sends a high (ON) signal.
Can someone point me into slightly setting up the circuit to accomplish this?
And how can I create a remapper program (preferably in C++) that detects the HID device and allows the end-user to remap the pushbutton signal to any QWERTY key? I want replicate this process for each input of my device.

Why not have the device send the appropriate key in the first place?

I want people to be able to remap the input, instead of just having a static key input.

And? Store the button-to-key mapping in EEPROM, and write a utility to change it.

I'll go with this example. I have a device that has one push button. I will program it to when the button is pressed, it sends a "generic" value to the computer. Now let's say I give this device to a friend, and he cannot re-program the device itself. How can I make it to where I have a computer software that can detect the "generic" button input and map it to whatever the friend wants to assign it to?

You'll need to write a driver that intercepts the generic HID message and translates it into an API call that the OS will understand. For every OS. It is much easier to write a program that uses a generic USB library to communicate with the device and tell it what each button should map to, and you only need to write it for one OS and publish the protocol for people who use the other OSes to use if they like.

Okay thanks. How would I go about coding that generic message in Arduino?

You wouldn't, because Arduino doesn't let you do that. Look at Atmel Studio and its USB examples, and do all the USB reading you can.

When the Arduino sends data to the computer using the HID protocol it sends what is called a HID Report. That is basically an array of numbers in a pre-defined format that correspond to what the computer is expecting.
In the case of keyboard events it sends a HID Keyboard Report

It can send events for up to 6 keys at once along with up to 8 meta keys.  How those key events are interpreted are down to the Keyboard Mapping used on the computer.  This is the setting (usually in the Language or Regional settings of the computer) that defines the layout of your keyboard - UK, US, French "AZERTY", etc.
While it is possible to create custom key mappings in many operating systems it is usually a very difficult and involved task. Also the mapping takes effect for every keyboard attached to the system, including the one you type on. So changing the mapping at will is probably not a good idea since it could break your normal keyboard usage.
So how would you go about doing what you want to do?  Well, my recommendation is not to do it on the computer, but to do it on the Arduino.  The Arduino has multiple interfaces available at once. As well as the HID interface for keyboard and mouse it also has the CDC/ACM interface for emulating serial. You can use both of these at once quite happily.  So you can use that USB serial interface to configure the way the Arduino works - including what key code to send for any particular event.  You could even write an easy-to-use GUI in Visual Basic or something that communicates with the Arduino over serial to adjust the settings.  How you do that communication (what protocol you come up with) is entirely up to you.

As for the hardware side of things - all you really need is just the switches / buttons and wire.  Just follow the on-line tutorials (there's millions of them) for connecting switches and buttons to the Arduino. Enable the internal pullups, and connect the switch between the I/O pin and ground.  For the rotary switch you will have 4 inputs and 1 output, so connect the 4 inputs to I/O pins and the 1 output to ground.

Is this sort of similar to how joypads work? What I'm trying to understand is how joypads can be remapped using software. For instance, Button 1 can be assigned to key F or key 4. I want to be able to replicate this with Arduino, as I will write a program to allow this remapping. So after reading this comment, can you kindly confirm that your post will accomplish this task.

All USB HID devices send HID reports. The format of each report for each device is different as befits the device. What is this "joypad" that you are on about?

The joypad is for video games. I'm trying to understand how games can detect a gamepad/joypad is connected and then allows you to assign a key per button.

@O.J.: Gamepads have their own HID report format.

@O.J. The game pad sends a report in its own format with its own numbers in the various fields. It's then up to the game what it does with those numbers. Windows doesn't really do anything much with the game pad - it just presents the numbers sent by it to the game. With a keyboard it is different because windows handles the incoming reports and maps them to key events.

Understood. So my overall result is to be able to create an API in C++ that can read the switch positions, etc.. Functions like Device.isConnected() and Device. GetSwitchPos() and Device.isButtonPressed().

@O.J.: If you're generating standard HID reports then the standard HID drivers will handle them. That is why I made the comment about having the device generate the correct report and having the software tell it which reports to generate. Otherwise you will have to go fully custom with your HID implementation.


text:
What is the Proper Voltage to supply an enough Current to the Arduino
I'm just confused about the supply that I should use in driving my arduino. Is it okay to use a 3.7V with a 1000mAh to supply it?
I will be using a Lilypad Arduino.
Your replies would be a big help to me.
Cheers!

The Technical Specs say that 2.7-5.5V DC is ok so you should be good at 3.7V DC.
Remember though:  Power consumption = Current  x  Voltage
So check that your power supply has enough current available. The current amount used will depend on how many pins you are using. The maximum each digital pin may use is 40mA. 1A (1000mA) will be plenty but mAh (milliampere hours) sounds like a battery specification.
Also, a word from the wise is that some cheap power supplies can be bad (little spikes and dips). If you are having trouble with strange issues it can be a good idea to check the power is ok.

I/O pins do not consume 40mA. They have an absolute maximum limit on what they are able to supply of 40mA and a recommended sustained maximum of 25mA. The actual current drawn through the I/O pin is dependent on what is connected to that pin.

Majenko raises a good point about the max rating (40ma).


text:
Why does an RGB LED between VCC and PWM work?
I'm an Arduino beginner and I recently bought a cheap starter kit on eBay. One of the lessons in the starter kit is an RGB LED controlled by 3 PWM output pins. However, the arrangement of the connections seems a bit funny to me:

To my surprise, it worked. I could see the three LEDs inside the plastic change colors. Why does this work? Do the PWM pins accept current whilst low? Is this a common arrangement? See the above link for the code provided in the lesson.

This is a common arrangement and is known as Common Anode, and the I/O pin is said to be sinking current.
To better understand what is happening here it's best to think of an I/O pin as a two-position switch:

When the I/O pin is HIGH point 1 is connected to point 2. When the I/O pin is LOW point 1 is connected to point 3.
So when HIGH the circuit is Vcc -> D1 -> R1 -> Vcc (or the other way around - I have done it that way because of the polarity of the LED), and no current can flow since it has nowhere that isn't at a lower potential than Vcc to flow to.
But when the I/O pin is LOW the circuit is now Vcc -> D1 -> R1 -> GND and so current can flow through it all to ground.  As a result the LED now lights up.
One thing you may have noticed now is that the operation is backwards.  Set the IO pin to LOW to turn the LED ON. That has the effect, as well, that PWM duty cycles are reversed.  analogWrite(ledPin, 0) will be full brightness and analogWrite(ledPin, 255) will be off.

Do the PWM pins accept current whilst low?

The pins sink current when low. And yes, that is commonly done. The pins are not "do nothing" at LOW, and "put 5V there" at HIGH. They are specifically designed to try to source (drive high) current when HIGH and sink (drive low) current when LOW.
To have pins (more or less) do nothing, you have to set them to INPUT mode. Then they try to neither source nor sink.
Caveat: if you enable the internal pull-ups they will try to weakly source current.

Is this a common arrangement?

It is quite common, depending on whether the device you are controlling is active high, or active low.

The RGB LED is common anode. This is why it is connected to VCC and the PWM pins pulls down to light resp LED.
A common cathode RGB LED would be connect to GND and the PWM pins would pull up to light
Cheers!


text:
Arduino mini being programmed with CH340G
So, I have bought this USB programmer with CH340G chip on it, but it seems, that I cannot program arduino mini clone.
So, this programmer has pinout of 5V|GND|TX|RX|3V3.
I have connected TX to TX and RX to RX (and also switched, because these programmers sometimes have marked where certain pins supposed to go, not what they represent).
I have also wired the DSR leg from the chip and connected it to the RESET on arduino mini clone.
There's still no connection between them.
Now I'm wondering, if I just connect the power supply and TX and RX connectors, when am I supposed to press reset for the succesfull programming?

First of all you should connect the DTR (not the DSR) pin to the reset terminal WITH a 100nF capacitor. See this page or the arduino uno schematics to see how to put the capacitor (it's simply in series with the signal.
However I suggest you to start programming WITHOUT the autoreset; once you are sure that you can program it then try soldering that capacitor to program the arduino without having to hit the reset button.
As for when, watch the IDE status: when it stops compiling and shows the "Uploading" string, press the reset button on the board. You will usually have a couple of seconds to press it.


text:
What's the difference between setting a variable outside a function and setting a variable inside a function?
I'm programming C++ for arduino and today I have seen an example like this
void loop() {
    byte variable = 0; // << This variable is the question.
    //more stuff here
}

Is the same as this?:
byte variable = 0;

void loop() {
    //stuff here
}

If the answer is "no", my question is "why?".
Thanks for your time!

To make them act the same while restricting scope of variable to loop(), use eg void loop() {     static byte variable = 0; ...}

The difference is not only about where you set the variable, but about where you defined it as well.
Defined outside the function, it will have global scope and lifetime, meaning it is visible everywhere and it exists for the entire duration of the program.  If you then place an initializer inside the function, whatever value it had just before function-entry will be replaced by the initializer value.
If you define it inside the function (and without a "static" specifier) it only exists while that function is executing, and is only visible to code inside the function. Because it only comes into existence when the function is entered, you must initialize it within the function, somehow.
If you define it inside the function, but with a static specifier,
static byte variable = 0;

then it will exist for the entire execution of the program but will only be visible to code within the function. In addition, an initializer on its definition (as opposed to other assignments to the variable) will only be executed once, just before the program begins executing, and will not be executed within function.
Using local and static (as opposed to global) variables is considered good program-variable hygiene because it hides those variables (to a greater or lesser degree) from code that needn't and shouldn't be able see or alter them.

No, it's not the same. Instructions within the loop() repeat every time the program gets to the end. If you set your variable at the start of the loop, it will automatically get reset to the default when you might not want it to be reset. The author of the example wants to reset to default every time the loop completes.


text:
Atmega328 PWM frequency setting not working
I have an Arduino UNO with Atmega 328 SMD, and I am trying to use PWM, but by setting registers, not using analogWrite(). My code is:
DDRD |= (1 << PORTD6); //Setting pin D6 as output
OCR0A = 128; //50% duty cycle
TCCR0A |= (1 << COM0A1)|(1 << WGM01)|(1 << WGM00); //setting mode and fast pwm
TCCR0B |= (1 << CS01); //setting the prescaler to 8, which should yield PWM with frequency of 8 kHz

The problem is with the last line. No matter what I do, it results in PWM with frequency of 1 kHz. Setting different prescaler bits just yield 1 kHz PWM again. I was thinking that maybe its because I am programming this in Arduino IDE, and I kHz is Arduinos default frequency?
Or where am I making the mistake? Thanks for any answers.

but when I write this instead of the last line, it works:  TCCR0B = TCCR0B & B11111000 | B00000010;

Your code assumes that TCCR0n are zero. But what if they are not. What if there is some hidden initialization?
Timer0 is used by the Arduino micro/millis counter and the prescale (TCCR0B) is initiated by setting bits CS00 and CS01 in init() before setup() is called.
If you really want to use Timer0 you will need to set/clear all the prescale bits. Alternatively clear the register before setting any bit.

To clarify; |= doesn't overwrite any previously set bits. So instead you should use =.


text:
Problem sending colors from an audio visualizer to Arduino
Sorry in advance for the length of my question; I want to provide proper context. I wrote an audio visualization program in Java that (in addition to making "pretty pictures" based off of the amplitudes of different frequencies being sent from the computer) sends a color to an Arduino Uno based off the sound it is "hearing."
I know the algorithm for generating this color is functional (in addition to sending that color to the Arduino, it also changes the color of an item on the DrawingCanvas). When the color is sent to the Arduino (as 3 bytes representing red, green, and blue), though, the physical LEDs don't respond correctly (they become a random color for a few seconds then switch to another random color for a bit – the behavior is hard to describe, but certainly not desired!).
I have been able to send colors to the Arduino using the same client program, but when the audio visualizer sends colors by the same method, this odd behavior occurs. My thought is that, because the audio visualizer sends color profiles dozens of times per second, the Arduino might be getting overloaded with data. Is that possible?
Here are the relevant pieces of code from the client, the audio visualizer, and the Arduino:
Client:
public class Client extends WindowController{
  //USB is a class I wrote that extends PApplet. Unless baud rates are the issue, I don't think we need to worry about this.
  static USB port = new USB("COM3", 9600);
  byte[] code = new byte[LENGTH];
  static byte killTerm = -100;
  private AudioVisualizer vis;

public void begin() {
  resize(1500,900);
  for (int k=0;k<LENGTH;k++){
    code[k]=killTerm;
  }
  vis = new AudioVisualizer(10,30,1200,300,canvas);
}

public void onMouseClick(Location point) {
  runVis = !runVis;
  if(runVis) {
    vis.start();
    code[0]=-22;
    sendCodeUSB(code);
  } else
    vis.stop();
}

public static void sendCodeUSB(byte[] code) {
  for (int k=0; k<code.length; k++) {
    port.writeProfile(code[k]);
  }
}

AudioVisualizer
public class AudioVisualizer implements Runnable {
  Thread thread = null;
  DrawingCanvas canvas;
  byte[] code = new byte[3];
  private int xPos;
  private int yPos;
  private int width;
  private int height;
  private int scale;
  private Location topLeft;
  private Location bottomRight;
  private FilledRect background;
  private int brightness=0;
  private boolean needOff = false;

  public AudioVisualizer(int x, int y, int w, int h, DrawingCanvas myCanvas) {
    canvas=myCanvas;
    xPos=x;
    yPos=y;
    topLeft = new Location (xPos,yPos);
    bottomRight = new Location (xPos+width, yPos+height);
    width=w;
    height=h;
    background = new FilledRect(topLeft,width,height,canvas);
    background.setColor(Color.BLACK);
    initiateMonitor();
    scale = height/30;
  }

  public void start() {
    if (thread == null) {
      thread = new Thread(this);
      thread.start();
    }
  }

  public void stop() {
    thread=null;
  }

  public void run() {
    while (thread != null) {
      try {
        Thread.sleep(40);
      } catch (InterruptedException e) {
      }
      graphAmps();
    }
    thread = null;
  }

  public void graphAmps() {
    //there is a whole bunch of stuff here that is unrelated that I removed.
    //basically, just know that graphAmps() calls avgColors()
    avgColors();
  }

  public void avgColors(){
    //there is stuff here that generates avgRed,avgGreen,and avgBlue (known to be working)
    Color c = new Color (avgRed,avgGreen,avgBlue);
    background.setColor(c);
    //so we don't spam the Arduino more than we need to
    if(avgRed>10 || avgGreen>10 || avgBlue>10) {
      sendArduinoColor(c);
      needOff = true;
    } else if (!(avgRed>10 || avgGreen>10 || avgBlue>10) && needOff) {
      sendArduinoColor(c);
    }
  }

  public void sendArduinoColor(Color c) {
    //takes the color and sets code = an array of 3 bytes with values from 0-100 (100 is the highest brightness I ever want the LEDs to be)
    //I am sure this is done correctly so I've left it out.
    constrainArduinoColor(c);
    //calls the static method from the client and passes in the byte array with the rgb values
    Client.sendCodeUSB(code);
  }
}

Arduino
#include <EEPROM.h>

int redPin = 11;
int bluePin = 10;
int greenPin = 9;
//declared here for debugging ease of access
int r;
int g;
int b;
//are we going through the Spectrum Cycle loop for the first time?
boolean sclFirstTime = true;
//temporary initialization
boolean waiting = true;
int index = 0;
const int LENGTH = 20;
byte profile[LENGTH];
byte avProfile[3];
byte killTerm = -100;
byte audioVisualizationCode = -22;

void setup() {
  //start the serial communication
  Serial.begin(9600);
  //initialize the profile to all -1 values
  clearProfile();
}

void loop() {
  //if there is nothing over serial and nothing is in the EPROM, we are waiting
  if (!eepromProfileAvailable() && Serial.available()==0){
    waiting = true;
  } else if (eepromProfileAvailable() && Serial.available()==0) {
    //if there is something in EEPROM and nothing over Serial, we aren't waiting and load the EEPROM profile
    waiting = false;
    loadEEPROMProfile();
    //load the EPROM color profile into the array
  } else if (Serial.available()>0) {
    //if something enters over Serial, we aren't waiting, clear the profile, and load the new profile with the serial info
    waiting = false;
    clearProfile();
    while (Serial.available()<LENGTH) {}
    // Wait until there are LENGTH number of Bytes waiting
    for(int n=0; n<LENGTH; n++) {
      profile[n] = Serial.read(); // place them in the profile.
    }
    Serial.flush();
    //clear out the serial to prep for next time
  }
  //if we have a profile (either from EEPROM or Serial), save it, check for special codes (if found, apply the effect),
  //and if there are no special codes, the profile is a static color profile, and set LEDS to that.
  if(!waiting) {
    saveEEPROMProfile(); //omitted but working
    if (profile[0]==101) {
      while (Serial.available()==0)
        spectrumCycle(); //omitted but working
    } else if (profile[0]==-22) {
      audioVis();
    } else {
      anodeSafteyOut(redPin,profile[0]);
      anodeSafteyOut(greenPin,profile[1]);
      anodeSafteyOut(bluePin,profile[2]);
    }
  }
}

//a bunch of preset color effects omitted
//we are using a common Anode LED, so low value is 255 instead of 0
void anodeSafteyOut(int pin, int c) {
  if(c>=0) {
    c = 255 - c;
    //as a safety measure because there are no resistors (yes, I know im breaking an intergalactic law by not using any), make sure we aren't writing something too bright
    if (c>=155) {
      analogWrite(pin,c);
    }
  }
}

//wait for 3 bytes to come in, assign them to the avProfile, set the colors to that, do it again
//THIS IS PROBABLY WHERE THE PROBLEM IS
void audioVis() {
  while (Serial.available()<3);
  for (int k=0;k<3;k++)
    avProfile[k]=Serial.read();
  anodeSafteyOut(redPin,avProfile[0]);
  anodeSafteyOut(greenPin,avProfile[1]);
  anodeSafteyOut(bluePin,avProfile[2]);
  audioVis();
}

So that's a lot, and I've left a lot out that I didn't think was necessary, though I'm happy to provide the full programs if needed. Thanks for your help!
Here is constrainColorArduino:
public void constrainArduinoColor(Color c) {
  int r = c.getRed();
  int b = c.getBlue();
  int g = c.getGreen();
  int r1 = (int)(r*0.4);
  int b1 = (int)(b*0.4);
  int g1 = (int)(g*0.4);
  byte r2=0;
  byte b2=0;
  byte g2=0;
  for (int k=0; k<r1; k++)
    r2++;
  for (int k=0; k<b1; k++)
    b2++;
  for (int k=0; k<g1; k++)
    g2++;
  System.out.println(r+" "+g+" "+b);
  System.out.println(r1+" "+g1+" "+b1);
  if (r2>100) r2=100;
  if (b2>100) b2=100;
  if (g2>100) g2=100;
  if (r2<0) r2=0;
  if (b2<0) b2=0;
  if (g2<0) g2=0;
  System.out.println(r2+" "+g2+" "+b2);
  code[0]=r2;
  code[1]=g2;
  code[2]=b2;
}

constrainArduinoColor(c)?

takes a color, finds the red green and blue ints, creates bytes based off of those numbers, applies them to the array code.

but where is the mapping from color c to the code[]?

added the method to the bottom of my post

true but im sending a byte. for example, if i code was {r,g,b} and that is sent over where rgb are each bytes and r is initialized to 100 and g and b are 0, the LEDs become all red.

have you traced the stream?

I've called println when I was first debuging to ensure that the rgb components of c were being properly translated to the array. i've also done separate tests where ive "manually" created the array and sent it over, and the color was correct. I'm starting to think that the issue here is synchronization. I'll try sending a start code each time before the color profile

My thought is that, because the audio visualizer sends color profiles dozens of times per second, the Arduino might be getting overloaded with data. Is that possible?

Close, but the source of the problem is probably this line
  Serial.flush(); //clear out the serial to prep for next time

Because your audio visualizer keeps sending data, it's quite likely that by the time you get around to claiming a record, at least some part of another one (or more) has also arrived.   When you discard that with flush(), you are probably most of the time not going to be discarding exactly a record's worth of bytes, but rather some arbitrary number more or less.  This introduces a synchronization problem.
You've already had some advice on solving synchronization problems.  There are a variety of workable methods, binary and otherwise.  One simple one that works in a lot of situations is to encode bytes textually in hex and terminate the record with a newline.  It does have just over a factor of two overhead, but it has the debug/test advantage of being human readable, and you can basically cover the overhead by switching from 9600 to 19200 baud.

Your idea that there's a synchronization issue seems plausible.  Whenever any byte gets skipped, color assignments shift from RGB to GBR or BRG, etc.
While sending a start code before the color profile is a possible approach to fixing the problem, it may be that occasionally one of the RGB values matches the start code, which could result in temporary desynchronization.
For an alternative method that doesn't require a start code, consider encoding the data into four bytes.  In the first byte, send the high two bits for RGB; in the second, the next two bits of each color; etc.  Set the low two bits of each byte to 11, 10, 01, 00 for first, second, third, fourth.
That is, each byte you send would be encoded BBGGRRdd where the capital letters are appropriate bits from RGB brightness levels and dd indicates which pairs of bits are being sent.
Here's some (untested) code that implements the decode:
byte code = Serial.read();
byte shif = 2*(code & 3);
byte mask = ~(3<<shif);
code >>= 2;
for (byte i=0; i<3; ++i) {
  profile[i] = (profile[i] & mask) | ((code & 3)<<shif);
  code >>= 2;
}

The following shows a function sendData3() that encodes three bytes from an array of RGB data into four bytes to be sent to the Arduino.  It also shows a convenience function sendDataRGB().  A call like sendDataRGB(100, 0, 42); puts three R, G, B values into a three-byte array and calls sendData3() to send it off.  [Substitute as appropriate in place of Serial.write]
void sendData3 (byte *dataIn) { // dataIn[] has R,G,B levels
  byte code;
  byte mask=3;          // mask for low 2 bits of a byte
  for (int b=4; b; ) {
    --b;
    byte shif = 2*b;    // For moving bits to align with mask
    code = 0;
    for (int k=3; k; ) { // Loop to handle dIn[2], dIn[1], dIn[0]
      --k;
      code |= (dataIn[k]>>shif) & 3; // Pick off 2 color bits
      code <<= 2;            // Roll up
    }
    Serial.write (code | b);    // Send encoded bits
  }
}

void sendDataRGB (byte R, byte G, byte B) {
  byte dataEg[] = { R, G, B };
  sendData3(dataEg);
}

I'll first try sending an extra sentinel byte outside of the range of any of the rgb bytes (like -7, for example), and if that doesn't work out, I'll try this. Hopefully, this will resolve the issue, but I also wonder if this will only fix the color mutation problem and not the latency one. Thanks for the detailed explanation. I look forward to getting back to you.

Just finished trying my method of ending each color transmission with an end term, and there was no improvement in behavior so I would like to attempt your method. Could you explain how I would encode the rgb values into 4 byes? I've never done something like that so some additional detail/example would be very much appreciated. If I wanted to send the byte color (100, 0, 42) how would that work, for example?

@KentAshfield, I added a C++ example of encoding the data.  Call routine sendData3  or sendDataRGB to encode and write an RGB triplet in four bytes.   ¶ I haven't looked very closely at most of your host-computer code; there, it might make sense to substitute some simple code that cycles through five or six simple colors at about 2 seconds each, and at the Arduino end, have a simpler program without EEPROM stuff, just for testing communications

*jwpat7 thanks for the guidance. Before I jump into the encoding, I might try raising the minimum threshold for sending a color profile from the audio visualizer to something that would correspond to a more prominent call in the music (like a beat, kick, snare, or hat). Doing so would reduce the amount of data being sent to something much more reasonable without sacrificing much of the effect after some tweaks to my equalizer. I'll keep you posted.

Ok great news. When I set up the "simplest scenario" with all excess code removed and a higher minimum threshold, the program worked mostly as desired (equalizers need more fine tuning and my color generator favors blue too much but those are somewhat trivial issues for now). I guess now I just need to go step by step adding in the other code segments again and seeing where the visualizer runs into trouble.


text:
Where to start?
I am totally new to Arduino and I'm a real beginner with electronics and robotics. I would like to know where to start, knowing that my ultimate goal is to build an autonomous robot (I know that I will not be able to do this project before learning a lot of things). I am a developer so I have no problem with C and C++, actually I am using C++ at work.
Thanks

After typing my answer, I wouldn't be too surprised if someone tries to close your question as "too broad". You probably need to focus it a bit to guard against this possibility. See, for example: Getting started

I would start with a lot of small projects, each designed to give you confidence over one small aspect. For example:

Detect variations in light with an LDR
Operate a motor (there are various types of motors) - including controlling one with a MOSFET or BJT transistor
Blink LEDs
Connect something with a fancier interface (eg. I2C or SPI) and get the hang of "talking" to a more sophisticated interface chip (you'll probably need this for things like balancing)
Try distance detection. Eg. with bouncing light or sound off an obstacle
Communicate between two Arduinos - get used to communications protocols, reliability, packet loss, etc.
Get used to detecting switch presses, either individual ones, or a keypad (or both)
Look into reverse polarity protection
Look into detecting low voltages on your batteries
Try radio communications (probably need to send your robot instructions) - there are various different ways of doing that
Possibly experiment with motor-driver boards (eg. H-bridges) which you may need for driving wheels
Investigate reading continuous values (eg. potentiometers, rotary encoders)
Investigate read-outs (eg. 7-segment LED displays, or LCD displays)
Investigate generating sounds (beeps, tunes)

You could take a look at my radio controlled car project. I look into some of those things there, and describe how I handled them.

I would do these things initially on the bench. Don't try to assemble something fancy until you have some experience with how the individual parts work.

What an answer!

well... you probably should try this as well.... http://www.allitebooks.com/?s=arduino there's good way to start with.

It's sounds silly, but just get an UNO, a breadboard, wires, 1 resistor (220 ohm) and an LED.
Wire up a LED circuit, and program the Arduino to flash the LED.
(There's a million examples of this all over the internet).
Without getting into any sort of heavy circuits or complex programming, you'll have a quick stress-free introduction to Arduino.
This will teach you:

using a breadboard
wiring digital ports on the Arduino
polarity of components (LED yes, Resistor no)
using the Arduino IDE
uploading to the board

This is a great jumping-in point because it's reasonably fool-proof.
Sure you can eventually be PID-controlling the balance of a 2-wheel robot.  But build yourself a working foundation of good knowledge first.

Personally I think the best way to start is hands on with a small robot. I mean the kind that have a couple of wheels, are circular and only a few inches in diameter. You can add many kinds of sensors or actuators as you learn. You get to see it move and hold it and pick it up.
The idea is to start with basic LED control and then get motors turning, sensors on, and then improvements and upgrades.
If you're ok at coding then electronics may be the bottle neck. Get a good book is my advice. As far has hardware the EEVBLOG guy Dave gives a good run down on what he recommends here.
Just start.


text:
Arduino code not working
Basically its an arduino project in which i am using an analog temperature sensor ky 013. The sensor is reading the temperatures correctly but what i want is to print the temperatures showed on the serial monitor to a lcd screen. I did the wiring and everything correctly  but there is something wrong with the code which i couldnt figure out.
Here is the code.
#include <math.h>

#include <LiquidCrystal.h>
LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 2);

const int sensorPin = A0;
int switchState=0;

double Thermistor(int RawADC)
{
    double Temp;
    Temp = log(((10240000/RawADC) - 10000));
    Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
    Temp = Temp - 273.15;
    return Temp;
}

void setup()
{
    Serial.begin(9600);
    lcd.begin(16, 2);
    pinMode(sensorPin,INPUT);
}

void loop()
{

 switchState=digitalRead(sensorPin);
 int readVal=analogRead(sensorPin);
 double temp =  Thermistor(readVal);
 Serial.print("Temp. : ");
 Serial.print(temp);
 Serial.println(" Celsius");
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Temp: ");
 lcd.print(temp);
 lcd.print(" C");
 delay(500);
}

Please edit your post and format the code using the code formatting markdown (four leading spaces). For help see Markdown help. You should be able to do this by selecting the code and pressing Ctrl+K to have your browser do this for you.

You haven't actually said what's wrong. If we don't know what's happening, we can't tell you why happening.

Have you checked if the pin defining is right for the LCD?

Does the lcd show "Temp: " as expected?

Please format your code.  I know it takes longer, but the payoff is in readability and maintainability.  It's well worth the extra effort.
LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 2);

const int sensorPin = A0;
int switchState = 0;

double Thermistor(int RawADC)
{
    double Temp;
    Temp = log(((10240000 / RawADC) - 10000));
    Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp)) * Temp);
    Temp = Temp - 273.15;
    return Temp;
}

void setup()
{
    Serial.begin(9600);
    lcd.begin(16, 2);
    pinMode(sensorPin, INPUT);
}

void loop()
{
    switchState = digitalRead(sensorPin);
    int readVal = analogRead(sensorPin);
    double temp = Thermistor(readVal);
    Serial.print("Temp. : ");
    Serial.print(temp);
    Serial.println(" Celsius");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Temp: ");
    lcd.print(temp);
    lcd.print(" C");
    delay(500);
}

I think the problem is the
lcd.print(temp);

Try casting it to a float from a double (and two decimal places).  Maybe you just need the decimal places.
lcd.print((float)temp, 2);


text:
Speeding up Arduino DC Motors
I am using the Adafruit Motor Shield v2.3 for Arduino Uno. I am using the analogWrite() command to power my DC motor and have set the speed to 255. Is there any way to speed up the Arduino motor even further? Thanks!

The speed of a motor is a function of the motor itself and the voltage applied to it. There is no programmatic way of increasing the speed of a motor. You would either need to increase the voltage being applied to the motor (as long as it is within the limits of your motor and speed controller) or find a different motor to use that is faster.
It appears the Adafruit motor shield accepts between 5-12 volts, if you are not already at the maximum of 12 volts, and your motor is rated to allow it, you can increase the voltage you are applying to the shield. All that 255 means in this case is give the motor all the power that is available, so if you are only giving the controller 5 volts, it is only going to give the motor 5 volts.
Also I might recommend instead of using analogWrite() that you use the official Adafruit library to control your shield as it uses its own PWM library which is more performant for motor control than the built-in Arduino one.
EDIT
Actually, with v2 of the shield, it has its own PWM driver controlled over I2C. In which case analogWrite() shouldn't work at all, or at least it doesn't do what you think it does. Instead use the official Adafruit library and I also recommend following the official tutorial as well.

Sorry about that, I was actually using the Adafruit Library. My Arduino us being powered by a 9v battery. However, the motor is only getting 5v. Is there any way to give the motor more power? I can't power the Motor Shield via another source of power; I have to use the VIN Jumper.

There are plenty of other questions on this site that address this, but the short version is do NOT use a 9v battery for motors https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/faq#faq-14


text:
Analogue input 0 staying at 0 when sensing light with Arduino and a photocell
I am doing a circuit for capturing light intensities.
I followed the tutorial provided by Adil Moujahid
Yet, when I plug the jumper wires on 5V the circuit stops working and when I plug on 3.3V the analog in A0 sent back only a series of zero...
What did I missed? I acknowledge that I tried to be the most economical on the jumper wires...
The sketches, program and circuit given by Adil Mouhajid

My attempt

While the code is not relevant to your issue here, in the future please place your code text into the question directly, instead of as a screenshot.

What did I missed? I acknowledge that I tried to be the most economical on the jumper wires. - that's what you missed. The bottom two lines are connected horizontally (all the way along) - thus you just shorted everything together.

The two strips on either side of the bread board, color red and blue (typically) are power rails, and each strip is all connected. Your circuit connections that are on that strip are shorted together and will not work. I suggest following his layout exactly to begin with, and once you've learned the basics of breadboard connections, you can start doing your own layouts.


text:
Will this AC-DC converter chip really work with arduino?
I am looking for a compact solution to convert some 220V/20amp AC to something edible by our arduinos (like 5V/2amp DC). I would like to plug directly my arduino to the wall. I found many things like some Hi-link (HLK-PM01) chips ... But I also found this one :

LNK564DN - US $0.34 / piece
LNK564DN - US $1.14 / piece

That seems perfect, but unfortunatly, I can not find any tuto or example of use for this, shipping included, really cheap chip.
The datasheet is here.
What do you think about it ?

" I would like to plug directly my arduino to the wall." - Why? What for?
If you want to power the Arduino you could use one of these. If you want to sense 220VAC try this.

Where will you source the transformer from?

The goal is to create a compact prototype which can be pluged into the 220v (France) wall plug. Don't you think the LNK564DN should do the job to give the prototype the current it needs ? Thanks.

The LNK564DN is the controller for a power conversion circuit.  To use it, you also need four diodes, four capacitors, three resistors, a special transformer, and a circuit board. You can get an "AC 100-240V 0.3A DC 5V 2A EU Plug USB Power Supply Adapter Charger" on Ebay for $1.74 with free shipping.

@Charaf What EXACTLY are you plugging into the 220VAC? I mean exactly what pins?

@James 200VAC plug -> AC-DC converter -> Arduino nano -> HC-06 + ESP8266. I am trying to put all of this in a simple compact case.

@jwpat7 Thank you ! I thought it was as simple as the hlk-pm01 =)

So you are powering the nano not sensing the 220VAC. Like @Jake C told you: It's dangerous. We use an off the shelf power supply, or a wall adapter. That's the best solution but it's over to you whether you take the advice.

What do you think about it ?

If you have to ask, don't do it. Mains voltage can be dangerous and should only be done if you know what you are doing and how to be safe. The best choice is to just use pre-built adapters from reputable sources.

It is a good advice. Thank you. But I think I can take the risk, it's for learning purposes =)

Buying random chips from China and asking on internet forums is not the best way to be learning about how to work with mains voltage.


text:
multiple relays not triggering correctly
quick description of the sketch: its a clap on/off relay that turns on only when it's dark.
Cannot seem to get the relays to stay off. What happens is they are off by default then when I do the double clap to turn them on that works, after this I double clap to turn them off and then go off then immediately go on again. I can get a single relay to work perfectly but when I uncomment the rest there seems to be a problem.
I am assuming it has something to do with the delay for the clap sensor, but I am not entirely sure-- I have tried quite a few things to try to resolve it but am really lost as to why this might be happening. ideas?
int soundSensor = A2;
int relay = A0;
int relay2 = A3;
int relay3 = A4;
int relay4 = A5;
int claps = 0;
long detectionSpanInitial = 0;
long detectionSpan = 0;
boolean clapState = false;
int doubleClap = 0;

//Light sensor
int photocellPin = A1;
int photocellReading;
int LEDbrightness;

//int delayValue = 100;
int photoSensor = 0;

void setup() {
  pinMode(soundSensor, INPUT);
  pinMode(relay, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  Serial.begin(9600);
}

void loop() {

  /////////////
  // photo sensor
  ////////////////////
  photocellReading = analogRead(photocellPin);
  photocellReading = 1023 - photocellReading;
  LEDbrightness = map(photocellReading, 0, 1023, 0, 255);

  if(photocellReading > 500){
      photoSensor = 0;
  }
  if(photocellReading < 500){
    photoSensor = 1;
  }

  /////////////
  // clap sensor
  /////////////////////
  int sensorState = digitalRead(soundSensor);
  //erial.println(sensorState);
  if (sensorState == 1)
  {
    if (claps == 0)
    {
      detectionSpanInitial = detectionSpan = millis();
      claps++;
    }
    else if (claps > 0 && millis()-detectionSpan >= 50)
    {
      detectionSpan = millis();
      claps++;
    }
  }

  if (millis()-detectionSpanInitial >= 500)
  {
    if (claps == 2)
    {
      if (doubleClap == 0)
        {
          doubleClap = 1;
        }
        else if (doubleClap == 1)
        {
          doubleClap = 0;
        }
    }
    claps = 0;
  }

  if(doubleClap == 1 && photoSensor == 0){
    digitalWrite(relay, LOW);
    digitalWrite(relay2, LOW);
    digitalWrite(relay3, LOW);
    digitalWrite(relay4, LOW);
    Serial.println("off");

  }
  else{
    digitalWrite(relay, HIGH);
    digitalWrite(relay2, HIGH);
    digitalWrite(relay3, HIGH);
    digitalWrite(relay4, HIGH);
    Serial.println("on");
  };

}

I suggest some debugging displays. After a clap is registered, print the value of doubleClap and claps. I suspect they won't be exactly what you expect. Maybe also print the current value of millis() which will probably help you debug.

It may be the fact that the photosensor is floating around 500 value and causing "false" triggers. Try to add a threashold or create a hysteresis cycle.

As it happens, you are debugging in the dark.  You have half a dozen devices attached to (presumably) some Arduino, driven by some hard-to-read code that might not work properly even if all the devices work ok, and definitely won't work properly if any of them fail or are incorrectly attached.
For example, you can't tell from that code whether your photoSensor works, whether your clap sensor works, or whether your relays work.  Before messing around further trying to test all at once, run some definitive tests on each device individually.  For example, run the following sketch and see if your system is able to turn on all of the relays at the same time.
// Test if relays work ok: First individually for a second each,
// then all together for 2.5 seconds
enum {relay=A0, relay2=A3, relay3=A4, relay4=A5, nRelays=4};
byte rePins[] = { relay, relay2, relay3, relay4};

void setup() {
  for (int r=0; r<nRelays; ++r) {
    pinMode(rePins[r], OUTPUT);    // Set pin to outputs
    digitalWrite(rePins[r], LOW);  // Turn off relay
  }
  Serial.begin(115200);
}

void loop() {
  byte r;
  // Turn relays on individually for a second each, with half-second gaps
  for (r=0; r<nRelays; ++r) {
    delay(500);         // Wait half a second
    Serial.print("Turning on relay #");
    Serial.print(r+1);
    Serial.print(" at ");
    Serial.println(millis());
    digitalWrite(rePins[r], HIGH); // Turn on relay
    delay(1000);           // One on for a second
    digitalWrite(rePins[r], LOW);  // Turn off relay
  }

  // Turn all the relays on
  Serial.print("Turning all relays on at ");
  Serial.println(millis());
  for (r=0; r<nRelays; ++r)
    digitalWrite(rePins[r], HIGH); // Turn on relay

  delay(2500);          // Wait 2.5 seconds

  // Turn all the relays off
  Serial.print("Turning all relays off at ");
  Serial.println(millis());
  for (r=0; r<nRelays; ++r)
    digitalWrite(rePins[r], LOW); // Turn off relay
}

Next, write a sketch to report results from photosensor and clap sensor readings.  Once you know if your hardware is working, try to get your double-clap logic to work without involving the photosensor, or vice versa.  Also, try to make the double-clap logic work just using a button in place of the clap sensor.
Note, to shorten your code and to get rid of some of the features that make it hard to read, do some of the following changes.  With the code slightly shorter, it may be easier to comprehend and debug.
(a) Instead of introducing program constants as integer variables, introduce them as program constants.  For example, instead of the verbose
int relay = A0;
int relay2 = A3;
int relay3 = A4;
int relay4 = A5;

say something like
enum {relay=A0, relay2=A3, relay3=A4, relay4=A5};

which tells the compiler that relay is a constant with the value A0, etc.
(b) Since you don't use variable LEDbrightness for anything, take it out.  With that gone, change the verbose
photocellReading = analogRead(photocellPin);
photocellReading = 1023 - photocellReading;
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);

if(photocellReading > 500){
    photoSensor = 0;
}
if(photocellReading < 500){
  photoSensor = 1;
}

to
photoSensor = analogRead(photocellPin) > 523;

which will set photoSensor to 0 or 1 much as before.  (It is slightly different: It handles a photocellReading==500 case that your code ignores.)
(c) Change the verbose and badly formatted
  if (doubleClap == 0)
    {
      doubleClap = 1;
    }
    else if (doubleClap == 1)
    {
      doubleClap = 0;
    }

to
 doubleClap = 1 - doubleClap;

(d) Refactor to cut about half the code involving detectionSpan.


text:
How to test Arduino behaviour on Windows?
Hello fellow Arduino enthusiasts,
I created an Arduino project for a Mega2560 board in Microsoft Visual Studio.
Before loading the code on the board I want to test it on my Windows desktop computer.
I'd like to automatically provide input (e.g. with a file containing some values) for the 4 hardware Serials as well as the I2C/Wire bus and check their output for validity.
How can one achieve that?
I read about mocking (e.g. "Arduino-mock") but this does not seem to be what I need since it is more a way of ignoring the absence of object implementations.
Are there maybe some simulators that can automatically generate input and create output logs or even check the output?
Thank you for any advice!

You can check this thread for some ideas: http://arduino.stackexchange.com/questions/61/can-i-program-for-arduino-without-having-a-real-board The question is a couple of years old, but not much has changed since then. There are a whole bunch of half implemented solutions that don't work very well. The best way to test Arduino code at this point in time is still to just run it on the hardware.

Shameless plug: check out this I2C test example: https://iobtoolkit.com/docs/tutorials/i2c_python_mcp7940n_test.html
This project is in active development. If you need some specific I/O function it'd like to hear from you.


text:
where I can find ground?
there is AVR AVR ATmega32 and a board within.
there is outputs for all ports (A, B, C, D) on board, and Vcc.
the problem is - I have no external GND output.
to watch current - I should search for GND pin everytime.
and now I need ground on my solderless board for LEDs and temperature sensor.
let's guess that I have no idea what is current or electricity.
so the question is: where I can find ground to connect it to solderless board?
maybe I can use something else, except MCU? (like my hand or smth :D)

Without knowing what your board is it's impossible to answer you.

Image is broken.

@Majenko, reuploaded, check it now

I'm amazed that there are six Vcc pins yet not a single GND pin. Have you tested for continuity to see if it's an error in the silkscreen?

to watch current - I should search for GND pin everytime - I don't understand this bit. How does finding GND help you watch current?

It looks like there are two pins at each of the I/O pin locations. Is one of the ground? Measure with a meter to a known ground (e.g., on the reset switch or in the programmer sockets).

I've just sorted things out.
There is two interfaces - ISP and JTAG. ISP is busy with programmer everytime, but JTAG is free.
So, I have found pinout of JTAG interface and achieved GND.
There is pinout:

(source: digital-circuitry.com)

You can check if any pin at J1 to J8 happens to be GND also.

Pin 11 of the chip itself is GND (see below). In the photo it appears to have a decoupling capacitor between GND and VCC (pin 10). You could solder a wire onto pin 11 (on the chip socket, not the pin itself) - it might be easier on the back of the board. Also pin 31 would be an option.

Also the reset switch is almost certainly wired (on one side) to GND. It looks to me like most of the board is "ground plane" (continuous copper) so find which part of the switch is wired to that, and solder a wire to it.


text:
Problem while writing sketch for GSM module sim800
I wanted to my GSM to recieve SMSs. I have written a sketch for it. But while verifying the sketch an error pops out in this part:
if (sms.available()) {
      sms.remoteNumber(senderNnumber, 20);
      if (senderNumber == "09432167015") {
        c = sms.read();
      if (c == "yes") {
          alarm_police();
          }
        }
      }
The error message:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
GuardDog_v2.5.ino: In function 'void loop()':
  GuardDog_v2.5:201: error: 'senderNnumber' was not declared in this scope
  GuardDog_v2.5:204: error: ISO C++ forbids comparison between pointer and >integer [-fpermissive]
  'senderNnumber' was not declared in this scope
This report would have more information with
   "Show verbose output during compilation"
   enabled in File > Preferences.

I have checked the receiving sms example and have written the sketch according to the example.I need help regarding this error and how to fix it

You have a scope problem and you are comparing a pointer to an integer. Show us the rest of your sketch and provide a link to the library u're using

The sketch is a bit too big and contains parts which are not related to GSM. Should I show the complete sketch? BTW the library I used is the default GSM library which is present in the IDE.

You misspelled the variable senderNumber. Correct it. Also you aren't reading the SMS properly or comparing the phone numbers properly. Your code should be like this (using the examples):
#define MAX_MSG 50

char senderNumber[20];
char sms_buf[MAX_MSG];   // a buffer for your sms, max len = 50

if (sms.available()) {    // this part should be in loop()
  sms.remoteNumber(senderNumber, 20);
  if (strcmp(senderNumber, "09432167015") == 0) { // compare numbers
    while (sms.available() == 0);   // wait for a char
    char i = 0;
    while (i < MAX_MSG - 1){    // till max len is reached; 1 byte for null
      c = sms.read();
      if (c == '\0')  // assuming the modem terminates sms with null
        break;
      sms_buf[i++] = c;   // write char to the buffer
      while (sms.available() == 0);   //wait for a char
    }
    sms_buf[i] = 0;   // terminate the string, just in case
    if (strstr(sms_buf, "yes") != NULL)  // look for 'yes' in buffer
      alarm_police();
  }
}

is MAX_MSG an int

It can be a char or int; just edited it

during the upload an error for char sms_buf[MAX_MSG]; pops up: array bound is not an integer constant before ']' token.

Change MAX_MSG to int and try again

I had used int for MAX_MSG it doesn't work for both char and int

Oh, i remember now....use #define MAX_MSG 50

@Reptile1234 Array bounds have to be integer constants. So the previous declaration didnt work (unless u make it 'const int').


text:
Does a graphical driver chip exist for this project?
I need some expert advice. I'm using an Arduino Leonardo, which I have got working with a Nokia 3310 monochrome screen. I wrote some code to draw any graphics to the screen.
What I want to know is, can I buy a chip from somewhere that will offload most of the CPU usage (for graphics from the Leonardo) that draws numbers and letters to the screen and basic graphics (different types of polygons and lines)? So I'm looking for a chip designed to do the graphical work and a data sheet reference for the chip.

Just get a second arduino. e.g. a pro-mini.

I have no idea if there is a chip or not, but I doubt it.
But then, why do you need one?
You already know how to communicate with the screen, so why not off-load those functions on to another Arduino (make your own small ATMega328P based board to do it) and then communicate with that through whatever means you like from your Leonardo?
You don't need a dedicated chip to do what you can quite easily program an Arduino to do.

authors: Aleksandr ведерников


text:
Programming many Arduinos simultaneously with a wireless broadcast
I will have many microcontroller-based devices which will be independent from each other, but all will run the same program.
I would like to upload a program to all of them at the same time with a wireless broadcast. Ideally the user would plug in a USB controller to his computer, and upload a program from the Arduino environment as if s/he were programming a single device.
To get a better idea of what I'm talking about, please take a look at this video. This was achieved with Atmel microcontrollers but a custom-made, non-Arduino bootloader.
From a Google search for "Arduino infrared programming" this interesting project came up. The main drawback is that the reset button still has to be pressed manually. Ideally I would like the devices to be in a low-power state by default, and wake up to receive a program when they sense a signal from the controller. Still, this may be a good starting point for me.
I just wanted to get some perspectives from people who are familiar with Arduinos as to whether they think this is feasible before I jump in.

Check this website http://lowpowerlab.com/blog/category/moteino/wireless-programming/

Which platform are you using to upload your sketches from?

TL;DR -
You have the options of either BlueTooth or XBee (amongst others: IR, for example?) for wireless uploading. However, I believe that only one board can be uploaded to, at a time, so you will need to cycle through the boards one at a time, see Programming multiple ATMegas/Arduinos at once.

When uploading a sketch or using a programmer (for sketch or bootloader), the software does not just write the code, it actually communicates with the microcontroller.
You can't program them all at once. But you can program them one by one in some automatic way.

Your question is a very interesting one, and asks a question that I am sure that I would never have thought of, but would be extremely useful and labour saving, especially if one has, as I do, many Arduino controlled sensor points located around the house. Here is one rather inelegant solution that may be worth trying.
Wireless upload hardware
If you use BlueTooth to wirelessly upload your sketches, then this solution might be of use, Wireless upload program to Arduino without USB cable. Note that this solution ties up pins D0 and D1:

But be careful that it maybe not compatible with some projects which need to use the D0 and D1 as hardware UART TX, RX. Because the wireless programmer needs to permanently occupy the two pins.

Looking at it, it employs a custom Arduino Wireless Programmer, to which you may have been referring in your question. However, don't be fooled by the name, it is simply a Bluetooth shield. It is basically a BT HC-05 (or similar) device, bolted onto an Arduino, see also Bluetooth Wireless Upload.
Alternatively, en lieu of BlueTooth, you could use XBee devices, see Wireless Programming of Arduino. The advantage of using XBees is that you would not have to go through the pairing new device loop (see below), that would be required when using BT. Instead you would merely have to cycle through the XBee network IDs.
However, in addition to that, you would need to automate the switching of BT devices, selecting the appropriate port and uploading to each Arduino in turn, as you are not able to broadcast sketches. (If am I wrong, then will someone please correct me).
Selecting the port and uploading the sketch
You could use a script along with the command line version of the Arduino IDE, to select the port that the BT device is connected to, before each upload. How you do this will vary for which ever platform you are compiling upon, see Command line Arduino compiling and downloading? This can be done using the environment variable ARDUINO_COMPORT (see the possibly out of date Windows command line build), or the arduino cmd line option --port <portname> ( see the man page). The sketch would then be uploaded using the option --upload <filename>. You could do this in one fell swoop:
arduino --upload --port <portname> FILE.ino

Note that on Windows you should use arduino_debug.exe.
Or you could use Ino, if you are not using a Windows PC... but that might make the next part, which deals with the looping more complex than it needs be.
Selecting each of the Arduinos (i.e. the BT devices)
Next, you would need to add a loop to the script, that pairs the PC to each BT device in turn and thereafter calls the Arduino IDE, for the port selection and uploading. Unfortunately, this would not be platform agnostic at all, and would require a different solution for what ever platform you are using. Take a look at Bluetooth from the Command Line, but for Windows you would probably require the Blue Tooth Command Line tools suite.
On OS X you may be best off resorting to using AppleScript, see Connect to bluetooth device (iPhone) via command line on MacOSX, as the cmd line tools for controlling BT seem a little scant - there is BlueUtil, see How to control Bluetooth wireless radio from the command line? but that only appears to turn the BT on of off. However, bolting AppleScript on to the rest of the Arduino IDE control script quickly makes things more complex, although you could just put the Arduino command within the AppleScript, I guess.

You could use ESP-LINK to program the Arduino over WiFi.
The ESP8266 is simple cheap Wi-Fi MCU that can be programmed with Arduino IDE.
ESP-LINK is firmware for the ESP8266 that makes the ESP act like serial connection (USB) to Arduino.
The firmware can be found here at ESP-LINK ESP8266.

One can use something like this. It is a custom bootloader to update a Arduino's code via a NRF24L01+ radio module.*
*It only works under Linux machines.


text:
sending midi to software using arduino
Friends Here is what i want to ask.
I have a midi keyboard that is casio cps7. Its an old model so its not a USB midi keyboard.
I use it with a cheap midi to usb cable.
I just wanted to use my arduino to act like a midi to USB adapter. So, i can use my midi keyboard with that too.
I found some tutorials that uses this arduino like usb serial device. And there is also a code for it. The code itself has a command to play midi notes.
We receive serial signals from arduino and convert them into midi (by using another software that is serial midi converter, there is also virtual midi port for it which is midi-yoke). Thats how i used my arduino board once but the program code for it (what i installed) plays its own notes. I just want to send my midi out (from my keyboard casio cps7) to pc as serial via arduino. Thanks
I hope you guys now understand what i wanted to say :)

You want to do what? What keyboard? Which Arduino? Do you have MIDI conversion hardware? I think the change should be in the program code - what code? I already have installed midi yoke - what yoke? Link? I already have installed ... serial midi coverter in pc - what midi converter? Link? Please read How do I ask a good question?

So you want to connect the Uno's first UART to the PC, and the second UART to the keyboard, and let the Uno act as a bridge?

Yes u got that right. I want to use arduino uno to act like interface to pc over usb for my 5pin midi out of my casio cps7 keyboard


text:
HC-SR505 PIR Sensor only outputting HIGH
I recently bought an HC-SR505 Mini PIR sensor. I connected its positive to my Arduino UNO's 5v, output to digital pin 2, and ground to ground. I used Adafruit's code to test it, but all the serial monitor displayed was "Motion detected", which meant the PIR was always on a HIGH state. I then also tried powering it using 3V3 but the PIR kept on cycling on a HIGH and LOW state. Any help on getting my sensor to actually work would be greatly appreciated.

The PIR sensor has delay of 8 seconds. So when you turn on arduino, take care that no movement is on the PIR, and then after 8 seconds it should detect no movement. And it has always this delay,every time when detects movement.

It depends, don't generalize (<-however you write that word).

Depends on what?

The PIR sensor has delay of 8 seconds is not a fact that affects all PIRs.

I'm talking about Hc sr505

I was struggling on the same issue. Here's the specs also: https://www.elecrow.com/wiki/index.php?title=HC-SR505_Mini_PIR_Motion_Sensor
Thanks for clarrifying it up. To sum it up. The 8 seconds start by the time it last sensed a movement.

The PIR works at 5V but you need to tweak the amount of sensibility and the signal length.
Usually when a motion is detected, the PIR keeps sending HIGH until x seconds defined by a potentiometer on the board, when it goes down, the sensor is ready to capture another motion.

Thanks for the explanation. Just want to point out that the HC-SR505 doesn't have a pot on it. Also, do you know if the output voltage is 5v or 3V3?

I have similar problem with the HC-SR505 sensor. First few seconds it holds 0 on the output pin, and then always 1.
I think it was bad batch of sensors. Bad batch in chinese manufacturing means thousands (or hundreds of thousands) bad modules flooded the market.
Meanwhile I decided to choose one of options:

Stick with HC-SR501 sensor. It's bigger but works more or less.
Buy expensive ($5.90) PIR sensor from seeed.
Build my own PIR module by my required dimensions and function (in progress).

Update:
From 5 sensors received 2 do the job. Supply voltage must be 5V or higher. First 20-60 seconds the output is not reliable and should be ignored. Then it works OK (if it works at all). Since the module has 3.3V LDO onboard the output signal is 3.3V.

Switch to use 5v for Vcc, the sensor will work correctly. I have the same trouble if I use 3.3v for Vcc. The output still 3.3v even your Vcc is higher than 5v.

While using 3.3v does sound problematic, if you read the question again you will see that the asker started their experiments with the 5v supply, and found that not to work.  So the actual problem must be something else.

I tried with another power source, not from the board. In my case I'm using an ESP8266 and to get 5v I need another power source.

You may be using an ESP8266, but the asker is using an Arduino Uno.

Let the asker try 5v from another power source, not from Uno. Does it make sense?

Even though this may not help the OP, this was my problem and I am thankful for having found this answer.

I'm a noob. I had the same problem.
I connected the signal to pin 7 so I listened to gpio7 which always gave 1. But pin 7 is gpio4... Listening to gpio4 fixed the issue :)


text:
Arduino motor control using digital pins
I am new to these Arduino things, and I am currently using an Uno board for my projects.
I don't know how to control the DC motor with the help of digital pins via L293D. But I cannot use the PWM pins of Arduino, since I have already used them for controlling servos and other things, which need higher accuracy.
I tried using the SoftPWM library to control motor, but it is conflicting with other things like ultrasonic sensor. I don't know what the problem is.
Could someone suggest me a solution?

This is not an answer, but looking at softPWM library disables regular pwm? might help.

You can implement PWM using digital pins by turning the pin on and off with respect to your duty cycle, because PWM (Pulse Width Modulation) depends upon the duty cycle the % amount during which the pin is HIGH or LOW
Let say pin 13 of arduino is connected to your l293D enable pin
Sample Code:
void setup()
{
  pinMode(13, OUTPUT);
}
void loop()
{
  digitalWrite(13, HIGH);
  delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz
  digitalWrite(13, LOW);
  delayMicroseconds(1000 - 100);
}
Details are also on Arduino Help
https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM


text:
Arduino Mega connect to 2.1 speakers
I am new to Arduino and I want to connect it to my 2.1 speakers and later to a 5.1 surround system.
The purpose is to play some wav sounds when a button is clicked or when a trip laser is cut. What should I do in order to play those wav around through the speakers? I also have an SD shield.

What have you tried so far? You need to divide your project into manageable blocks: Input, sound generation, reading wavs from SD card, etc. Which part(s) are you having trouble with?

i am having trouble making the speaker play the wav files i have in my SD. the speaker i have for test is an 8 Ohm speaker and when i finish with that i want to connect it to my 2.1 speaker system.

First, you need to figure out the bandwidth requirements and if this is possible at all. You need to do some basic calculations and answer the question if the Arduino and the different components have the bandwidth (byte/second) that is required.
The Arduino MCU (AVR) is too "weak" to do this on it's own. A special shield is required. Such as https://www.adafruit.com/products/1788
The Arduino Due has more processing power but still not stereo quality; https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer
More info to be googled.
Cheers!


text:
It seems my Arduino doesn't work
I've got an Arduino Uno.
I was building a simple circuit with only one switch and it doesn't seem to work (I followed the Arduino project book from the Arduino starter kit).
This is my circuit :

Then I try again to move the switch and then it works (but I don't understand why).

So I tried to understand where the error is and I try to read digital input from the simple circuit with only one LED :

And this is my code :
int SWITCH = 13;

void setup() {
    Serial.begin(9600);
    pinMode(SWITCH, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
    int val;
    val = digitalRead(SWITCH);
    if(val == HIGH) {
        Serial.println("OKAY");
    }
}

I expect to see on the Serial Monitor "OKAY OKAY" and so on... but nothing appears on the Serial monitor.
Then I try to change the condition :
if(val == LOW)

And now I see "OKAY OKAY" and so on...
I think that there is something wrong with this Arduino... Can someone tell me something about what is happening? Am I stupid or there is really something wrong with this?

Could you try to turn the led around. And maybe even take out the switch.
If that doesn't work, try another LED and turn it around when it won't work.
LED's have polarity, which means they only work one way around.

I tryied with a lot of different leds and switches. In the lastest image (link) the led is on so this works right but if a read digital input from that I see that there is no voltage. Why?

It looks to me like your arduino is working just fine.
In the first two images you use the arduino only to provide 5v power to the circuit on the breadboard. In the first image you haven't connected your button to properly function as a button. I don't know the exact pin layout of the button (which should be explained in a datasheet of that button), but it is also good to know exactly how to holes in a breadboard are connected. This picture shows why your button works on your second image but not your first:

This picture also shows how the breadboard holes are connected:

In your third image you have practically connected input pin 13 to GND, so it makes sense that digitalRead(13) in your code always returns LOW. Thus, the variable var is always LOW (or 0). Thus, the comparison (var == HIGH) is FALSE, which won't send "OKAY" to the serial monitor. And, the comparison (var == LOW) is TRUE, which will* send "OKAY" to the serial monitor.
I hope you can follow the logical steps and it is clear to you what is happening.

Thanks so much for your answer. I've build now the same circuit and it works right. If i push my switch the led turn on. Here is the picture of my circuit : http://imgur.com/6DWyWr6 . If I use the same code than above using val == LOW than print "OKAY" what I have to expect in output if my switch is open, and what if my switch is closed? (i tryied to print Serial.println(digitalRead(SWITCH)) and also if my switch is open or close i always have 0) Why? Thanks.