text:
Unable to read the IC Card UID
I have a RFID module using NXP RC522 chipset.

I have no idea that is it correct the module using 27.120 mHz

And I have 4 IC card,

A) 0005302176, (Blue color tag, come with the RFID module)
B) 0008846830 134,65006 (White card, come with the RFID module)
C) 0004189112 063,60344 (White card)
D) White card, no number print on the card. Only this card UID can be read.

Here is the pinout

Which I connected to Arduino UNO R3

     RFID         UNO R3
(Pin Name, Pin)    (Pin)
SDA        1        10
SCK        2        13
MOSI       3        11
MISO       4        12
IRQ        5        -No Connect-
GND        6        Ground
RST        7        9
3.3V       8        3.3V

PS: I am using this library, and this example.
PS: The serial return this information MFRC522 Software Version: 0x91 = v1.0

Can you clarify what the problem is please?

Why I can read 1 card UID only, but others three cards UID unable to read. PS: the blue tag was come with the module, but still can't read UID, am I something go wrong?

It's probably the fault of the cards, they are very cheap and I have had a few with dead cards. You seem to have a whole pack of dead cards.
You could try with a contactless payment card, transport card, or staff access card from work.

@unknowndomain, I had tried my two staff access card. These card also printed numbers, and I have 6 white cards (both can read UID and both nothing printed numbers). Could anyone can answer me that the module should able to read the cards which printed number, or module never read the card UID except white card. Or someone answer me that, I should enter the SN (Maybe on chip/card) for reading Card UID.

I presume you are aware that different cards use different technology and only some are compatible with this reader, that said the ones that came with it should work.

@unknowndomain, I just mention in the post. The cards (blue tag & IC card with number) are not readable, but another card using same technology (base on e-shop description) can read the card UID. If there are never success read the UID, it means reader is not work. Normally, is it should read the UID and never necessary to provide any SN/Key/code printed on chipset or cards ??

Little unclear what you mean, but I would take it to mean that this unit is defective, because I am using the code from the Arduino.cc website which links to github and that works fine with the cards provided, so something is faulty because one reader can read them and the other not.

The question itself does not state a question. But it appears that the cards are "sometimes" working? It could be the cards or reader that are defective (depending on if one card will always work). And be sure to use an external power source (not using one often leads to "random" behaviour. The code is from a library and should be fine (given the fact that it read some cards).

Check your power source, if you are powering the module from arduino/USB=>part or something like that, there can be not much power for the module.
Also you can try powering it 5v (not 3,3 as they should be powered by reference).
In my case I have had problems reading some types of cards, and I have solved that problems by giving better power supply, also higher power supply than in reference for some of the cards.
"By magic" the cards that were not working started working as a charm.
Also you should check if the cards you are using are all  ISO14443 A
Only that kind of cards is compatible with that reader.
So if you got type B, or other type of ISO cards, that will not be working.
Some of them may use different frequency, there is a bunch of standards around.
Also as said before the cards can be damaged, or could be corrupted if you tried reading UID while writing to the card, the problem is known , and in that case you can damage the UID.
I hope it helps you.
cheers

The MFRC522 reader is for 13.56 Mhz tags; these tags normally dont have the UID printed on them, in my experience. 125khz cards, however, usually have their SNs printed on them; as you can see all the cards that didnt work, have a 10 digit SN that seems to follow the same pattern. These card SNs can't be read by the MFRC522, as they follow a different protocol. When you buy a tag/card, make sure that its a 13.56 Mhz tag (look for Mifare tags), if you want the MFRC522 to be able to read it.


text:
Good way to get automatically generated code into a sketch
Situation:
Mac OS, Arduino IDE 1.5.6r2
I've got a sketch with several files, all classic .cpp and .h source and header files except the main sketch file. As the project goes more complex I started to generate code automatically by another program. Now I have hard times integrating the generated code it into my sketch. The arduino IDE seems to load the code on opening the sketch. After that, the source files aren't beeing checked for external changes by the IDE (as I would expect it from a real editor like vim). On top of that, when I verify my code the IDE seems to save the files from RAM into a temporary build directory ignoring the contents of the sketch directory further. So if I let my code generator change a source file while the sketch is opened in the IDE, the changes won't reach the build. I had to close the IDE and reopen it. The next thing I tried is to include my autogenerated file from an existing and opened code file inside the IDE. But the IDE ignores files, which aren't opened completely. Hence, the file is missing in the build directory.
Is there a trick to let the IDE take the code unknown to itself along into the build directory? Or how else can I deal with this situation? I don't want to close and open the IDE a hundred times a day.

Select "Use external editor" in the preferences. Not ideal, but it might work for you.

This works. When verifying the sketch, the IDE now checks the content of the directory for new and changed files. The drawback is, I have to switch over to an editor. Probably I'm going to use vim.

According to the release notes starting with V1.5.2 of the IDE you can verify and upload from the command line.
You could use your favorite editor and then use the command line to do the arduino build/upload instead of the IDE.
See: https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc
I have not used it so I can't say if it work well or not.

Ok, I tried and used it. The outcome seems to be ok. I still have to think about using that method on a regular base. It is not the most comfortable way to get things done, but nothing really uncanny. Perhaps I can even do some integrative scripting around it. Thanks a lot.

source: Stack Exchange

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

sort: votes


text:
RTClib library dependency on Wire library
I downloaded the RTClib library from https://github.com/adafruit/RTClib.  In every provided example, #include <Wire.h> is written immediately above #include "RTClib.h" at the top of the sketch.
Why is this necessary?  I know the RTClib library requires the functionality of the Wire library but, if this is the case, why can't I just #include <Wire.h> at the top of RTClib.h?  I have tried the latter, even using just the following sketch, but my sketch failed to compile.
RTClib.h:
// Code by JeeLabs http://news.jeelabs.org/code/
// Released to the public domain! Enjoy!

#ifndef _RTCLIB_H_
#define _RTCLIB_H_

#include <Wire.h>
...

#endif // _RTCLIB_H_

Sketch:
#include "RTClib.h"
void setup() {}
void loop() {}

In addition, it's generally bad practice to include libraries in header functions that are exposed to the user because that can often lead to odd bugs with multiple definitions/etc.

Not getting too formal here, The arduino IDE looks at which libraries are included in the top level sketch when deciding what libraries to include in the compilation.
It would make sense for only RTClib.h to include Wire.h yes, but the IDE does not get the information to add Wire to the compilation list that way. It is a quirk of the IDE that makes implementing libraries that use other libraries a bit more painful.

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


text:
Home-made Arduino not receiving data
Me and my friend recently built a Breadboard Arduino. It switches on fine, and the LED changes a bit. I have added a 5V FTDI cable, but it wouldn't upload, trying to fix this, I used my friends 5V FTDI Basic USB-To-Serial converter chip, thinking this would upload fine, as it was new, but it still wouldn't upload, giving the very long error:
Arduino: 1.5.8 (Windows XP), Board: "Arduino Duemilanove or Diecimila, ATmega328"

Build options changed, rebuilding all

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\hooks.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\hooks.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WInterrupts.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WInterrupts.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_analog.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_analog.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_digital.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_pulse.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_pulse.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_shift.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_shift.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\abi.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\abi.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\CDC.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial0.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial1.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial1.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial2.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial3.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial3.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HID.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HID.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\IPAddress.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\IPAddress.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\main.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\main.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\new.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\new.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Print.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Stream.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Stream.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Tone.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Tone.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\USBCore.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\USBCore.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WMath.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WString.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WString.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\hooks.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WInterrupts.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_analog.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_digital.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_pulse.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_shift.c.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\abi.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\CDC.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial0.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial1.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial2.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial3.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HID.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\IPAddress.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\main.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\new.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Print.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Stream.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Tone.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\USBCore.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WMath.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WString.cpp.o

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp.o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a -LC:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp -lm

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.eep

C:\Program Files\Arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.hex

Sketch uses 450 bytes (1%) of program storage space. Maximum is 30,720 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.

C:\Program Files\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM8 -b57600 -D -Uflash:w:C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr  3 2014 at 23:12:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x01
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x01

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

The light on the USB-To-Serial board lights once for each failed upload, but the sketch won't upload. I am trying to upload the blink sketch. The chip I am using is an Atmel AtMega328P-PU. All answers greatly appreciated.

Did you burn the bootloader onto your AtMega328?

No, I bought an AtMega328P with the bootloader preloaded.

Is this correct   Overriding Baud Rate          : 57600 (may be). AVRdude correct?

How did you connect the DTR pin? It might be that you have to manually reset the arduino before uploading.

@RussellMcMahon - Checked the output (I have verbose enabled). Overriding baud rate is 57600.

@Gerben - The DTR Pin is connected to reset button on breadboard.

DTR should be connected via a small capacitor, not directly.

@Gerben - Connected DTR with small capacitor. The capacitor is 0.10uf, and links over the IC notch in the breadboard, but I still can't upload. I've also tried a different FTDI cable, but I still get the same result.

Does the led stop changing when uploading? Does manually resetting the AVR work?

Is your bootloader configured for an external crystal?  If so, are you providing one of the appropriate frequency with loading capacitors?  What baud rate does your bootloader expect?

Hold the reset button (or just keep it from booting) and then a tiny bit before the arduino IDE tells "Uploading..." release the button. Then the bootloader should be able to get the serial data and flash the new software. (If the Arduino is not in bootloader (1-2sec after releasing the reset button) you can't program it)

I would upload a blink sketch using the method Stephan suggested then plug it back into your breadboard.  If it runs the blink sketch then the problem is in your programming method, but  it is more likely there is something wrong in the setup.  Problems could be using the wrong crystal for your setup, mis-wired or loose connection, or having your chip turned around (happens more often than you think).  If it does run I would make sure that you are using all USB-to-Serial converter with all the wires used and having a resister on the reset pin.

I solved this by using an empty Uno-Board as a 'bridge' between the PC and the Bareduino (empty means with no controller chip). Just connect this guy via USB to the PC and then connect RX/TX, Ground, and Reset to your Bareduino. Just works fine for me.

How would this be superior to what the poster is doing (which has worked for many, including myself)?

Well - didn't he post because it is not working? It didn't work for me either and i am using my proposed solution since quite some time. Another advantage is - it is minimal invasive for the breaduino as only 3 cables have to be connected.

Four.  The same four you need with anything else.  Five if you get power from USB.

The likely causes of failure are

Wrong baud rate: you're already using 57600, the most common one.
Rx and Tx cross connected: try connecting them the other way round.
Wrong clock clock frequency in the chip: The tools usually assume an AtMega328 runs at 16MHz.
Chip is not in bootloader/programming state, in the very first seconds after releasing the reset button or powering the arduino, the bootloader is listening for instructions to start reprogramming the chip via serial communication, if there is none it will continue running the program on it. Hold reset -> Hold upload -> Release upload -> Release reset.

The above assumes, of course, that you have a working board. If that isn't certain, follow @Nathan's advice to plug in a chip pre-programmed with a Blinky sketch to confirm it. I use a combined Blinky and HelloWorld sketch to prove both the basic functioning and the serial I/O in one test.
A couple of these are handy to keep around, too, for proving there is power or a logic HIGH where you expect it:

       LED with current-limiting resistor on the cathode


text:
arduino resets or hangs after providing power to DHT22
I'm developing a low power project based on Atmega328p which among other things uses a DHT22 to measure air humidity. DHT22 spec says that it consumes 50uA when idle. This is too high for me (I'm aiming at sub 10uA consumption for the whole device when in sleep mode) so I've figured out that I'll just power it from one of Atmega328p pins. This will give me the ability to turn it off or on at software level. DHT22 consumes only 1.5mA during measurement so I should be fine (a single Atmega's pin can safely provide up to 20mA). I've set up a following test circuit:

The red wire powers DHT22, the blue one is for data transfer, the black one is GND and the 4.7k is a pull-up resistor.
My problem is that after I turn on the DHT22 using just:
digitalWrite(4, HIGH);

the Atmega either resets or hangs or... successfully turns on the DHT22 and keeps working, but that happens about 10% of the time. My suspicion is that there is some current spike in the moment of supplying power to the DHT22. Unfortunately I don't have an oscilloscope to confirm this.
I've added a 220 ohm resistor between VCC pin of DHT22 and the pin 4 on the Arduino and it solved the problem. My question is: will it work like this reliably? Are humidity readings reliable when voltage is not stabilized (but stays within 3.3-5.5V range as required by the datasheet)? I could of course use a transistor to turn it on/off, but I'd like to keep it as simple as possible.
Why DHT22's datasheet doesn't mention this current spike? Here it is for reference: http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf

This is probably due to a voltage drop when you start powering the DHT. Have you tried adding a decoupling cap between pin 4 and GND? Otherwise a MOSFET triggered by pin 4 and providing the supply to the DHT may be a good solution.

Please note that sub 10uA consumption when idle is very ambitious and I wonder how you'll be able to stay under this threshold with such a circuit.

The 220 resistor is a solution, but you probably want to add a capacitor after it, to smooth the voltage at the DHT. The datasheet already suggest adding a  100nF capacitor across the power of the sensor.

pinMode(4, OUTPUT)?

I haven't ever had to use the cap even with 20 meter cable runs.  (Maybe the cable does that for me.)  With that long of a run I get a definite voltage drop so it barely takes any current yet provides accurate values.  Never would I put a resistor across any of the pins, even if my cable is only 10cm long.  But have you tried it?

The sensor is a large capacitive load. You need to improve decoupling of the CPU power supply.
A 10 uF between 5V and GND will help for the current spike and the resistor in series with the sensor will not be an issue (50 uA on 250 Ohm makes only 12.5 mV voltage drop once the sensor is started).

The previous answers regarding adding decoupling capacitors are good.
You don't have to be concerned about the voltage drop across your 220 ohm resistor. MAC's answer states that only 12.5mv drop at 50uA (when not measuring).
During measurement, 1.5mA will result in 0.33v drop across the 220 ohm resistor. This should be noted, but is not a problem. The DHT22 data sheet shows that it will accept any supply voltage between 3.3v and 6v.
  Looks like you have a good design.

Decoupling capacitors do help, as mentioned in the other answers.
Also, to get a good reading, after powering up your digital pin 4, a delay of maybe 100-500ms may be required to allow the DHT22 to stabilize. For better results, you can also perform multiple readings (call delay(dht.getMinimumSamplingPeriod()) between the readings) and average them.
It looks like you are using an Arduino Uno. For further power savings, you might consider using a Pro Mini and performing some hardware modifications. For software power saving techniques, there is no better resource than Nick Gammon's Power saving techniques for microprocessors.


text:
Has anyone used an Arduino to transfer software to an Apple IIe?
Yes, you read that right.  An Apple IIe.
I have many retro computers and I was thinking that since the Apple II line of computers (especially the IIe) have pretty speedy serial ports that it should be somewhat simple to use an Arduino to send data to/from the Apple.
My issue is that all of my every-day computers are USB based with no RS232 serial.  I guess I could boot up an old Linux laptop that has a serial port but that seems too cumbersome given my limited desk space.  :-)
Anyway, I've Googled but I'm not finding anything.
Since most Apple IIe disk images are pretty small (<144k or so) they should fit pretty easily into, say, an Arduino DUE that I have.  Or better yet, using the DUE to mount as a USB device that could send over to the IIe would be great.
So, my question is, does anyone know of any site that explains how this could be done?
Thanks!
EDIT
OK, turns out it WAS pretty easy getting the Arduino DUE to send to the Apple IIe.  I simply connected 3 wires from TX1/TR1/GND to the Apple IIe serial port (SSC).
Now, when I launch ADT Pro and start sending, the IIe is receiving garbage.  Bunch of "9d9d9d9d" all over the place.
Here's my code:
// ADT.ino

int incomingByte = 0;

void setup() {

    Serial.begin(9600);
    Serial1.begin(9600);

}

void loop() {

    if(Serial.available() > 0) {

        while(Serial.available() > 0) {

            incomingByte = Serial.read();

        }

        Serial1.write(incomingByte);
        delay(100);
    }

}

The ADT Pro software is set to send the data over the USB port and it's obviously sending data to the IIe.  I'm just wondering if the formatting is wrong or something.

The Arduino part is easy peasy. Getting the ][e stuff is going to be the hard part.

What baud rate does IIe expect? | Is polarity correct? | Are there pauses between characters? | presumably sending N81? - what does IIe expect (no polarity or odd or even? 1 start almost always, 1 stop or two (irrelevant with gaps between)). Try a small pause between sent characters. Are you sending RS232 levels or TTL? ....

To be honest, I really don't know at this point. I think it expects RS-232 but I'm not sure.  For baud rate, everything I have read says it should be able to handle up to 19,200 and I've tried that and 9600.  This is where I'm getting my information from:  http://adtpro.sourceforge.net/connectionsserial.html

May be useful- http://adtpro.sourceforge.net/bootstrap.html | Maybe -> http://pdw.weinstein.org/2007/06/apple-hacking-for-fun-and-profit.html | LOOKS very useful -> http://mirrors.apple2.org.za/ground.icaen.uiowa.edu/Docs/SerialPortFirmwareInterfaceCommands.txt | Maybe -> http://apple2online.com/index.php?p=1_13_Apple-II-IIe | Wow !!! -> http://www.applelogic.org/UserManuals.html |

Realistically, you'd be better off with an off the shelf USB-serial (not "USB-TTL" as used with Arduinos) already incorporating the necessary inverting level translation.  Drastically cheaper, too.

You need to adapt the levels. Arduino Due operates on 0 - 3.3 V. Apple IIe is either on 0 - 5 V or +/- 12 V (depends which port you are using). There are standard ICs to do the level adaptation.

That's important yes.  But equally important to success is that the signals must be inverted.

Yes, correct connection and correct level. Non-adaptation of the voltage level may lead to the destruction of the Arduino board. A typical chip would be in the MAX220-MAX249 series from Maxim, and many other providers have compatible chips.

I went ahead and marked this as the answer.  My mistake is not realizing the differences in TTL vs. RS232.  I'm lucky I didn't fry my DUE!  I have always just plugged serial cables into that DB9 connector and never really understood what it was doing (like most people).  Only now, I need to know HOW it works because I want to build an SD card reader for my Apple IIe.  Anyway, I have bought the correct cable/converter off eBay.  In the meantime, I'm going to mess around with some MAX232 chips I have and experiment.  This time, with a better understanding.  :-D


text:
In system programming for avr?
I generally use sockets for AVRs in standalone circuits, but sometimes I sell my items and therefore I soldier the chip on the circuit. As you guess I can upgrade the code inside the chip with socket simply putting the chip out and putting it into the programmer board, but It doesn't work the same way with the ones which are soldiered on the circuit.
I know there are some ISP devices like USBtinyISP etc., but I want to be more professional and know exactly how an in system programmer work.
Do I have to use Avrdude If I design my own In system programmer? Isn't there any way that is more universal?
I searched the internet for a long time and I found only hobbyist stuff. Can anyone explain or simply direct me to a good source that explains this topic? Thank you in advance.

You can still use the Arduino IDE. Just change the "programmer" in the menu. Just add a ISP header to your project.

ISP works by using a serial connection (usually via the SPI and nRESET pins) to the MCU. The programmer talks to the device using the low-level protocol that the device expects, and connects to the host using a different, high-level protocol. The host then directs the programmer to perform the various programming actions on the device, and in turn the programmer reports to the host about its current status.
There are a number of programming protocols that already exist, such as the one described in AVR910. As long as both the connection type and the protocol itself are supported by AVRDUDE it will work transparently once the hardware is assembled.
Further details about ISP are available in both AVR910 as well as the "Serial Programming" section of the datasheet for the device in question.

You can use an ISP using the Arduino UI - simply select your programmer (tools->programmer) then "upload using programmer" (under the file menu).
Alternatively, you could use a pre-programmed AVR to do the programming - see http://www.atmel.com/images/doc0943.pdf for the spec. I think an AtTiny would be enough, depending on how big your program is, you might need some external storage. You could set it up with a "read" and a "write" option, so you program your dev AVR normally, then use an AtTiny to suck the data off, then push it up to one of the others. This is left as an exercise to the reader.
In any case, you would just need access to the 6 pins - VCC(power), GND(ground), RST(reset), SCK(clock), MISO(master->slave) and MOSI (slave->master). Note that the RST pin has to go high/low at specific times during the programming, so if programming from another AVR, it will need to be a data pin.


text:
Can stackable Arduino headers be automatically soldered?
I want to design an Arduino shield with stackable headers, so it will allow other shields to be mounted on top of it.

I was wondering if these could be soldered automatically. Neither wave nor reflow soldering seems to be an option. Wave soldering would leave solder on the pins so they won't fit in sockets, and for reflow (pin-in-paste) the long pins will completely pull the paste from the holes.
Is hand-soldering the only way (making the board more expensive), or is there still another way? Would it be a good idea to supply the shield with the headers not mounted to save cost?
Or shouldn't I assume the average Arduino user has a soldering iron?

Depends on where you have them manufactured. Chineese labor isn't as expensive. A lot of boards have a a few parts that go in manually. There are, by the way, robotic soldering machines, though you'd probably still have to manually insert the headers, and have some way to fixture the headers while the board is upside down. I've seen a few shield for sale, that don't have the headers inserted. Note that this also makes shipping easier. No real clear answer.

@Gerben: good point about shipping. Thanks for your comment.

I would suggest using SMD headers on one side and through hole on the other side. One side with this: http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/partdetails.aspx?Class=ASSMANN&ClsID=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&PartID=10-18062010-079808
and one side with this: http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/PartDetails.aspx?Class=ASSMANN&clsid=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&ManID=ASSMANN&PartFamilyID=10-23062010-067691&PartID=10-23062010-067691&SrchRsltId=1&SrchRsltType=0
You will shift upper side a few mm from bottom side, and use glue to have upper side set in place and then reflow for soldering on both sides.

I'm not a production engineer, but would SMD both sides work and not need the offset?

I would work but may need special equipment as these are tall SMD that may be difficult to maintain while you manipulate the board. In this case you will probably want to work with two solder pastes that have different fusion temperatures.

The proper way to work with SMT on both sides is to glue the parts if they're too heavy to stay in the solder paste capilarilly.

An SMD header this tall could be extremely prone to breaking off and quite possibly peeling tracks with it.  The idea is workable for unique lower profile board- board stacking headers, but probably not for the Arduino's high stacking height tradition.

You might look at getting a solder stencil.  It is still hand soldering, but significantly faster than doing it completely by hand.  Another option would be a pick and place machine; there would be a significant upfront cost but it would be more automatic.

Like I said in my question neither wave nor reflow soldering seems to be an option. For both automatic pick and place exist. And how does a stencil help here? It's used for reflow anyway.


text:
Why does a Piezo Buzzer not require a PWM digital pin (Gallileo Gen2)?
According to my current (poor) understanding, only the PWM pins (with the ~) among the digital pins (ignoring Analog pins) can be passed to analogWrite().  I understand the servo therefore - since interfaced by a variable voltage signal - must be connected to such a PWM pin.

Why is the humble Piezo Buzzer not bound to this condition?
Why can I connect the buzzer to a digital pin that is not PWM (and so should only be able to output binary LOW, HIGH voltage at some consistent frequency) and still achieve a varying sound by calls to the tone() function?
Surely under the limitations of being digital and non-PWM, the pin could only cause some consistent buzzer frequency?

I'm reading online that the Piezeo Buzzer does indeed require a PWM digital pin, but I can connect it to any digital pin on my Galileo gen2 and have it function seemingly correctly (differing tones produced).
Also, since slightly relevant; what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?

The PWM pins do hardware PWM. You can however also have the software do PWM. I guess that is what the library you use does. The analog pins are for reading an analog voltage between 0 and 5 volts. This has noting to do with PWM, besides the misleading name analogWrite arduino uses.

Why does a Piezo Buzzer not require a PWM digital pin?

Tone() uses the microcontroller's hardware timers to control the related code function but do not use the hardware PWM features. The timer can be assigned to any pin that has a digital output capability.
Tone() sends a "rail to rail" square wave (50% duty cycle) to the selected pin
Slightly more lower level information here under Ugly details
They say:

The library uses the hardware timers on the microcontroller to generate square-wave tones in the audible range.
You can output the tones on any pin (arbitrary). The number of tones that can be played simultaneously depends on the number of hardware timers (with CTC capability) available on the microcontroller.
ATmega8: 2 (timers 2, and 1)
ATmega168/328: 3 (timers 2, 1, and 0)
ATmega1280: 6 (timers 2, 3, 4, 5, 1, 0)
The timer order given above is the order in which the timers are allocated. Timer 0 is a sensitive timer on the Arduino since it provides millis() and PWM functionality.

... what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?

There is a misconception there.
Analog pins are capable of Analog INPUT functionality .
"PWM" output is known as "analogWrite" but is actually a purely digital function and is not related to whether a pin has analog read functionality.
PWM out = analogWrite is available on pins which have associated PWM hardware.
The actual signal is a "rail to rail" square wave with a mark:space (on:off)that varies.   Filtering the PWM produces DC at the average DC level. PWM range is 0 to 255 (8 bits)

Is there a difference in the square-wave produced by a digital pin via timers and that of a PWM digital pin? Why is any PWM hardware needed if timers can emulate analog output on all digital pins? Why can the servo not be operated from a non-PWM digital pin by a square wave produced using timers?

@AntiEarth, the PWM can be set up to do their thing, and then left to it (indefinitely, or until the settings are changed). To change any other pin from high to low, or from low to high, requires attention at the exact time of the transition.

@RussellMcMahon, so it's a matter of computational intensity (or at least, scheduling)? Why still is the servo bound to hardware PWM?

@AntiEarth AMADANON's answer would be correct in some systems but not here (probably). I'll check the hardware features of the uC before saying too much more, but whereas AMADANON is suggesting a pure software based answer, the tone() command uses system timers. It appears that the timers can be assigned to any pin. | Re PWM versus square wave. "Square wave" unless specified otherwise is assumed to mean a rail to rail waveform with 50:50 mark space ratio.  A servo's position control requires a variable mark:space ratio. The PWM does that, the timer does not. Note that ALL digital capable ....

.... pins are capable of outputting PWM under software control. For a single channel this is trivially easy. But, with due care and knowledge and skill [tm] you could probably have every output providing PWM by using the millis() or micros() functions. These allow you to run in an uninterrupted loop while checking the timer "on the fly". You can use this like a "round robin" scheduler with each PWM having its own timing register to compare with micros() result OR all channels could be combined with the routine waiting until each way-point arrived and changing relevant output bits. ....

Super rough pseudo code example of former. E&OE! : |// say 32:68 PWM; int mark = 32;  int space = 68; thenM=micros(); MainLOOP { IF thenM = micros()  { setPWMhigh(); thenS = micros() + mark;} IF thenS = micros() {setPWMlow(); thenM = micros() + space;}  Other stuff ... ; } // end of main loop
|| This does not handle micros() rollover and has other issues but shows general principle. Simplistically you could run N of these in a loop independently. Size of N depends on time taken clock speed etc.

The timer isn't "connected" to an arbitrary output pin. The timer is set to trigger an interrupt at a set frequency, and the interrupt handler uses digitalWrite() (or equivalent) to toggle the pin.

@Osvein Your comment does not relate to my answer - maybe you intended to post it against the original question? | The word 'connected' - which you quote and comment on, does not appear in my answer. | You mention an arbitrary output pin -  as does my answer. I explain the relationship between output pins and timers. It's not at all apparent that your comment relates to this. it PERHAPS adds a little as a comment on the OP's question. If you think that you have something useful to add I suggest that you create a new answer, or transfer your comment to the original post.

@Russell I was referring to your comment "it appears that the timers can be assigned to any pin". There also seems to be a misconception here that timers and PWM are separate parts of the hardware - PWM is just one of several different ways to configure the timers to generate a signal on the timer's output compare pins.

@osvein My answer, which is my definitive statement of what I'm stating. including viz " ... The timer can be assigned to any pin that has a digital output capability ...", which is true. The slightly more general comment in the comments re "any pin" is correct enough in context. IF a pin CAN be a digital output a timer can be assigned to it when using the TONE() command (which is what the question was and is about.). ...

@osvein ... Re misconceptions -> I dont see any. You seem to be straining at finding somewhat obscure points in the fine detail which
THE ANSWER as it is now and has been since 1 Feb 2015 seems to address the query without confusion, for most people, anyway.
If, 4 years on, you think that a better answer can be given, you are welcome to supply one. [Please do not attempt to modify my one to say something other than it already says].

@Russell I wasn't trying to refute your answer, I was just adding a piece of detail that I think is necessary to understand the difference between the implementation of analogWrite() and tone(). Re misconception, you seemed to imply that the duty cycle of a PWM signal was not controlled by the timer - "The PWM does that, the timer does not"

The signals that you mention are of different nature.
1) The PWM signal is a digital signal (output voltage is either ground or supply) that is modulated in time. It has a fixed period and its duty cycle varies from 0% (always ground) for value 0, to 100% (always supply) for value 255, the middle value being a signal that switches between ground and supply with 50% of its period at ground and 50% of its period at supply.
2) A servo is controlled by a signal that has a fixed period of 20 ms and a pulse of varying duration (between 0.5 to 2.5 ms).
3) A tone for a buzzer has a variable period (or variable frequency - both being linked by the equation frequency * period = 1). The period is audible if is is between 0.06 ms (15 kHz) and 60 ms (15 Hz) (the exact value change from person to person. If the frequency is higher than 15 kHz, you are entering ultra-sonic.
All three signals are digital in their voltage and modulated in time. But the modulation is very different as indicated above and the Arduino driver is therefore different for each one.

You don't explain how these differences make it possible to generate a tone on an arbitrary output pin. Truth is all of these could have been made to work on any pin with slightly less accuracy using timer interrupts, but the Arduino creators chose not to for reasons unbeknownst to me.

@osvein There can be a good reason: The MCU has specific hardware to support PWM output, it is therefore more efficient to use this hardware instead of interrupts when possible. But the way a PWM hardware is controlled is not ideal for some applications (like tone generation). The second part of your comment is on coding preferences, and that's to be discussed with the Arduino coding team.

The hardware timers can do tone generation directly on the output compare pins without interrupts just as well as they do PWM. See the datasheet.

Yes, sometimes, but you do not use a PWM to do tone generation. It's another way to use the timer hardware (and in some processors, these are separate timers).

but in the case of the Arduino, they're not separate hardware. It can use the exact same hardware (the same output compare pins on the same timers) for PWM and tone generation.


text:
Is it possible to use FrSky D8R-II Plus 8ch 2.4Ghz ACCST Receiver with an arduino Uno?
I'm in the process of buying a receiver and transmitter for my quad copter project. Would it be possible to use this receiver or a similar one to control the quad. I'm trying to read the signals using Pulse in. I'm inexperienced in RC and I only found one tutorial on how to do this.
I know that the receiver will have to be wired up to the analog pins on the arduino however, the receiver has an operating voltage of 3.5V-10V and an operating current of 100mA which exceeds the 40mA of the arduino board. I have seen videos of people using silar 2.4Ghz receivers on arduino Nanos without problems. Has anyone on this board done something similar and if so, can thou guide me?

I've used plenty of receivers like this with arduino.
The operating current is not really an issue; It is drawing power off of the 5v line, not the digital pins, which is capable of 100mA. In any case they usually have an extra "bat" line that you could plug in to a BEC from one of your speed controllers, and then just connect signal and ground lines to the arduino.
pulseIn works, but not ideally (especially for quadcopters). reading with pulseIn tends to have quite a bit of noise, and runs slow. Those receivers pulse around 50-60Hz, so reading those signals with pulseIn (which has to wait for the signal to finish) will take too long. I say "too long" because in all the open source quad copter programs I've looked at the sensor-read/stabilize update loop needs to run at 100 Hz or more.
What you need to use is the interrupt functionality of the AVR. That way you can detect the time between changes in state of the input pulse without causing the rest of the program to stop. This can get somewhat complicated so I'm not going to write a tutorial here. I recommend you research it yourself and ask new, specific questions here if you have any.
It doesn't magically fix everything for you though; the Uno only has 2 external interrupts. I think most arduino based quads use arduino megas or Leonardos, which have more. I know the APM 2 board has a separate chip converting those 8 single channel PPM signals into a single 8 channel PPM signal that goes into the main controller, despite the fact that it is a mega.
You can look into Aeroquad and Multiwii for inspiration. ArduPilot is open source as well but their code is messier, which makes reading it much more difficult. I don't think it is impossible to use an Uno, but it will be difficult.

Thank you. I have a mega 2560 too. I guess I'll be using that one.


text:
Imbedded loops based on inputs
I'm working on a project with 4 inputs and 7 possible outputs on an Arduino Uno.  Based on any combination of those inputs, I need to run a specific "loop" that will repeat until there is a change in ANY of the 4 inputs.  Specifically:

Input 1 = loop 1
Input 2 = loop 2
Input 3 = loop 3
Input 4 = loop 4
Input 2 and 3 = loop 5
Input 2 and 4 = loop 6
No input = do nothing

So I need to constantly read the 4 inputs and change output loops accordingly.  I have basic Arduino knowledge but am stumped.
This is what I've tried - I have 4 input pins and 8 output pins
int outPin = 0;
int inPin = 0;
int CAR = 0;
int pinRead = 0;

void setup()
{
 for (int outPin = 3; outPin < 11; outPin++);  {  //set pins 3 thru 10 as OUTPUT
   pinMode(outPin, OUTPUT);
  }

 for (int inPin = 9; inPin < 13; inPin++);  {    //set pins 9 thru 12 as INPUT
   pinMode(inPin, INPUT);
  }

}

void loop()
{
  for (int CAR = 3; CAR <11; CAR++); {  //set all pins to LOW
   digitalWrite(CAR, LOW);
  }

  // BRAKE

    {while (digitalRead(9 == HIGH) && digitalRead(10 == LOW) && digitalRead (11 == LOW) && digitalRead(12 == LOW)) {
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(10, HIGH);

  }}

  // LEFT

    {while (digitalRead(9 == LOW) && digitalRead(10 == HIGH) && digitalRead(11 == LOW) && digitalRead(12 == LOW)) {
    digitalWrite(0, HIGH);
    delay (200);
    digitalWrite(1, HIGH);
    digitalWrite(3, HIGH);
    delay (200);
    digitalWrite(2, HIGH);
    delay (200);
    digitalWrite(0, LOW);
    digitalWrite(1, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    delay (200);

  // RIGHT

  }}

    {while (digitalRead(9 == LOW) && digitalRead(10 == LOW) && digitalRead(11 == HIGH) && digitalRead(12 == LOW)) {
    digitalWrite(5, HIGH);
    delay (200);
    digitalWrite(4, HIGH);
    digitalWrite(6, HIGH);
    delay (200);
    digitalWrite(7, HIGH);
    delay (200);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    delay (200);

  // HAZARD

  }}

    {while (digitalRead(9 == LOW) && digitalRead(10 == LOW) && digitalRead(11 == LOW) && digitalRead(12 == HIGH)) {
    digitalWrite(0, HIGH);
    digitalWrite(5, HIGH);
    delay (200);
    digitalWrite(1, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    delay (200);
    digitalWrite(2, HIGH);
    digitalWrite(7, HIGH);
    delay (200);

      for (int CAR = 0; CAR < 8; CAR++); {  //set all pins to LOW
       digitalWrite(CAR, LOW);
    delay (200);}}

  // BRAKELEFT

  }

    {while ( digitalRead(9 == HIGH) && digitalRead(10 == HIGH) && digitalRead(11 == LOW) && digitalRead(12 == LOW)) {
    digitalWrite(0, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    delay (200);
    digitalWrite(1, HIGH);
    digitalWrite(3, HIGH);
    delay (200);
    digitalWrite(2, HIGH);
    delay (200);
    digitalWrite(0, LOW);
    digitalWrite(1, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    delay (200);
    }
  }

  // BRAKERIGHT

    {while (digitalRead(9 == HIGH) && digitalRead(10 == LOW) && digitalRead(11 == HIGH) && digitalRead(12 == LOW)) {
    digitalWrite(0, HIGH);
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
    delay (200);
    digitalWrite(4, HIGH);
    digitalWrite(6, HIGH);
    delay (200);
    digitalWrite(7, HIGH);
    delay (200);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    delay (200);
    }
  }

  // NOTHING

    {while (digitalRead(9 == LOW) && digitalRead(10 == LOW) && digitalRead(11 == LOW) && digitalRead(12 == LOW)) {

       for (int CAR = 0; CAR < 8; CAR++); {  //set all pins to LOW
         digitalWrite(CAR, LOW); }}
    }
}

What have you done already? Can you post your current code?

Yes.  Added to post above

From your code, there is a conflict for pins 9 and 10, it seems you want to define the as both inputs and outputs!

Please note this gets way harder when you use delay().

When you need repeating behaviour in an Arduino program, putting loops within the loop() function often isn't the best approach. It leads to a lot of confusing logic which is quite hard to get right, and becomes quite unwieldy to maintain.
A more effective approach would be something like a simple state machine. At the start of loop() you would check the input values and figure out which behaviour (or state) you want to execute: BRAKE, LEFT, RIGHT etc.. You might want to store this information in a variable somewhere, e.g. state 0 could be BRAKE, state 1 could be LEFT, and so on.
Next, you simply check what the state value is, and execute the appropriate instructions once. For example:
switch (state)
{
    case 0:
        // BRAKE instructions here...
        break;

    case 1:
        // LEFT instructions here...
        break;

    // etc...
}

There's no need for any while loops because loop() is going to get called all the time anyway. There are two big advantages of this approach. First, you only need all the input conditions in one place, which makes the code easier to manage. And second, it means you can easily have your program doing other things later in loop() because it's no longer stuck in nested loops all the time.

As a side note, it's very important to mention that lines like this are incorrect:
digitalRead(9 == HIGH)

What you're doing here is comparing the number 9 to HIGH, and then passing the result (which is 0) to the digitalRead() function. That means you're effectively only ever checking pin 0. What you actually want to do is pass 9 to the function, and then compare the overall result to HIGH, like this:
digitalRead(9) == HIGH

I've looked at the switch (case) before, but didn't get it.  Based on your reply, I've constructed this-

void loop() {
{if (digitalRead(9) == HIGH && digitalRead(10) == LOW && digitalRead(11) == LOW && digitalRead(12) == LOW)
button = 0;}
{if (digitalRead(9) == LOW && digitalRead(10) == HIGH && digitalRead(11) == LOW && digitalRead(12) == LOW)
button = 1;}
{if (digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(11) == HIGH && digitalRead(12) == LOW)
button = 2;}
ETC then,
switch (button) {
case 0: // BRAKE
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);

ETC

Not sure how to format code for comments.  Sorry.

@ASM Google "switch statement" and you'll get a quick description. Basically, it evaluates the value at the very beginning and if it's equal to the first value, then only that code is executed. If it's equal to the second value, only that code is executed (and so on). However, it seems like you need an if statement that's nested since, as far as I'm aware, you can't use the && operator except at the very beginning.


text:
Bluetooth shield/module for file transfer?
I'm currently working on a project that requires to display images on a touchscreen on my arduino. These images are neither stored in arduino nor any memory card. I want to be able to send the images via Bluetooth from an app and display it on the touchscreen. The problem is I couldn't find a good and solid Bluetooth shield or module that provide file transfer via bluetooth from an iOS app to arduino. If you can name a few bluetooh shields or modules that'd be great. In the thread below, someone claimed hc-05 works. Can anyone support that claim? Thanks.
http://forum.arduino.cc/index.php?topic=208306.0

Bluetooth shields do (mostly) not have built-in file-transfer support. For the reason  that Microcontrollers (mostly) don't have file-systems. You could however, write your own protocol, or directly store the characters you get and attempt to display that as an image.
For projects with: images/camera/filesystems/USB I would recommend using a raspberry PI.

where you successful in transferring text file over bluetooth to your android app???? if yes, then can you share your code?

I would use an HC-05 (or HC-06 - there seems to be little difference) - You will need to do your own file transfer protocol - for small images, zmodem or xmodem (usual file-over-serial) are probably completely overly complex. You would also need your own app for the phone.
Alternatively, you could use a network (ethernet or wifi) addon on your arduino - I think I read the Arduino Yun has built in ethernet and wifi.http://arduino.cc/en/Tutorial/WebServer has a webserver, this could be adapted to accept uploaded files. You can then use a webbrowser on your phone (or indeed anywhere else!) to send the files. If you want to send from outside your local network, you may need to set up port forwarding on your router (google: port forward) - the port you want to forwards is 80.

I'm going to go with the first approach but using a different bluetooth module. I'm already using bluetooth to talk with my iPad; i want to keep the cost down so I'd decided not to use WIFI. Thanks for the tips.


text:
analogWrite never outputs a non-zero voltage
With a very simple connection of an LED (which can withstand 5V) to ground and to a pin on my Galileo gen2, I can never output a non-zero voltage from the pin via analogWrite, regardless of whether the pin is digital or analog (although PWM digital works)
The LED is in the correct bias and I'm calling pinMode(pin, OUTPUT) before attempting to call analogWrite(pin, 255) (or any 2nd parameter in-between), even though it's not even necessary.
The LED glows if I call digitalWrite(pin, HIGH) on both analog and digital pins, but does not glow at all for analogWrite(pin, 255) with the same configuration and pins, nor does it for any 2nd param in [0, 255]. This holds for whether the call is attempted in loop() or setup().
The only possible way I can get the LED to receive any power from analogWrite is through a digital PWM pin, but I know the other digital pins can still produce square-waves with timers and the analog pins should certainly be able to use PWM.
(So far, I've been to scared of short-circuits to connect the analogWrite output straight into an analog input to read the voltage)
Is there something I don't understand about the underlying board, or am I experiencing some strange malfunction?
Thanks,
Tyson

(I could understand it not working on non-PWM digital pins, because perhaps analogWrite doesn't make the necessary use of timers to simulate a square-wave, unlike the function tone. But why wouldn't analog pins write analog?!

When simulating on 123d.circuits.io, again only PWM digital pins work as expected, but analog and digital pins interpret analogWrite as binary digitalWrites, thresholding past 255/2 (slightly different to always being 0 on my Galileo)

As per other answer: analogWrite ONLY works on hardware-PWM capable pins*. What you see is correct operation. * uC's with DAC may allow analog.write on DAC equipp3d pins.

On most boards, the standard implementation of Arduino's analogWrite() will only ever produce PWM, and only on a specific set of (digital) pins. These are usually pins 3, 5, 6, 9, 10, and 11, although it's slightly different on some boards.
The only official board which has 'true' analog output is the Due (pins DAC0 and DAC1).
If you want any other behaviour (such as outputting PWM on non-standard pins), you'll either need to modify the Arduino implementation, or directly manipulate the microcontroller's special registers. Note though that modifying the chip's configuration could cause other standard Arduino functions not to work as expected.

So the analog pins don't support PWM (they're only titled such because they can read analog)? What about the use of timers to produce square-waves which emulate analog as discussed here: http://arduino.stackexchange.com/questions/8357/why-does-a-piezo-buzzer-not-require-a-pwm-digital-pin-gallileo-gen2/8363?noredirect=1#comment15232_8363

@AntiEarth Yes, analog pins are for reading analog only. For square wave output, the MC's timers can usually be routed to any GPIO pin in theory. The tone() function can output to any pin, for example, but it comes with its own limitations. It's important to note that Arduino is only designed to support a subset of the underlying MC's capabilities. The official Arduino website documents all of this if you need to look anything up.

So to clarify/summarize: only digital PWM pins can actually produce square waves upon calling analogWrite. The other pins (normal & analog) can achieve square waves using timers, but this is not implemented in the analogWrite function, nor in the Servo definition. Have I understood correctly?

@AntiEarth You're right about everything except the Servo library. It can work with any pin because it doesn't use analogWrite(). It manipulates the timers directly. This unfortunately means it can prevent PWM from working in some cases, so you have to be careful about how you use it.

That is exactly opposite what I've discovered experimentally; simple calls to the Servo functions only work on digital PWM pins on my Galileo (gen2); they absolutely do not work on other digital pins or analog pins. The mystery continues!

@AntiEarth I suppose it's possible that the Galileo is different, since it has a different chip at its core. I'm just going by what the Servo library documentation says! :)

I don't believe Galileo has a D/A converter, which is what it sounds like you're expecting. In the Arduino 'eco-system', analogWrite() sets a PWM duty cycle - that's kinda-sorta somewhat like an analog output, but not really. You could add external circuitry to low-pass filter the PWM and produce some sort of proportional DC but it might be a good trick get it clean enough for whatever you plan to put downstream.

As discussed here http://arduino.stackexchange.com/questions/8357/why-does-a-piezo-buzzer-not-require-a-pwm-digital-pin-gallileo-gen2/8363?noredirect=1#comment15232_8363, I'm just trying to emulate an analog signal by digital square-waves

I am not sure where you are getting your LEDs but the ones I purchase do not survive 5 volts. You need to put a resistor in series with then, something in the 220 to 510 ohm range.  When you get some resistors test your LEDs you may have damaged them as well. A good indication of this if there color if obviously off and or dim. If the timers are set up correctly the digitalwrite will set the PWM value, somewhere from 8 to 16 bits depending on the Arduino and timer used. This PWM output will appear to control the brightness of the LED. It does this by simply turning it on and off at a speed the eyes cannot follow. the longer it is on the brighter it is. Hopefully this will help you get your arms around the circuit.

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


text:
How can I analyse large packets on an Arduino?
I'm trying to send a large packet to an Arduino with an ethernet shield on it. I'm using the built-in RX buffer of the W5100 controller to store the data, but I need more memory (at least 16K of buffer space, the W5100 only has 8K of RX buffer space). I have control over the server side of things as I'm writing the server process myself, so I can take solutions on that side.
Is there some hack I can use in the TCP protocol to have the packet broken up?
Edit: I'm using the SFML 2.1 network API on the server side.

TCP does indeed allow telling the other end about your buffer window.  I'd be a bit surprised if the actual link level packets are individually too big.  But an Arduino is not a good choice where you need large buffers - by the time you added the ethernet shield you could have had orders of magnitude more memory at a comparable price.

@ChrisStratton The person I'm working with on this with insists on using arduino for this. On the server side I'm kind of treating the large string I need to send as one big packet.

If you are using TCP on a conventional system, you have very little visibility into what a "packet" is.  It's quite likely that your single network API call payload gets transmitted as many smaller packets. In an embedded implementation sometimes the layers collapse and you do have more detail, but the Arduino side shouldn't have to claim more than one link-level packet worth of data at a time.

@ChrisStratton, please confirm that the Arduino is not capable of receiving the "many smaller packets" and that the the OP should just send smaller packets. He could add a memory shield and fix the overflow, but that wouldn't address his question about TCP.

An application developer does not "send packets" over TCP, they send data which the TCP and lower level stacks packetize.  If the Arduino can or cannot receive the small link level packets depends on the software stack on the Ethernet module. Getting it to properly set its TCP window should help too, as that should stop data flow until the Arduino has drained the module's buffer.  Anyone proposing a "memory shield" (as in RAM) needs to have their head examined, as using the right MCU for the job is drastically faster and cheaper.

This sounds like a job for WireShark; https://en.wikipedia.org/wiki/Wireshark.

All you need to do is analyse the packet on-the-fly using a state machine.
http://www.gammon.com.au/statemachine
You certainly don't need to hold the entire packet at once, however you do need room for the information the packet contains.
Say, for example, that the packet, although wordy, contains 4 x 32-bit numbers of interest. All you need memory for is those 4 numbers, plus a minor extra amount for the current data you are processing (eg. the current state, and the current number being assembled).
Conceptually it is like streaming a movie to your PC. The PC doesn't need to hold the whole movie, it just needs to hold the current frame, and a few seconds in advance, just to keep things running smoothly.

As usual, Nick to the rescue. Your website is a treasure trove!


text:
Why are pin 18 and 19 always HIGH?
I wired my switch just like in the default button program. I know it works because it works fine on other pins, just not pin 18 or 19. What am I doing wrong?
const int buttonPin = 18;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

The Uno only goes up to 13...

@ignacio And then there are 6 analog pins 14-19

Those are designated A0 through A5.

The analog pins function as digital pins number 14 - 19, with 14 being A0 and 19 being A5. I had hooked it up backwards.
This time we're gonna get funky
Everybody check your pins
Check check check check your pins
Check check check check your pins


text:
Arduino UNO does not get recognized by PC(no USB connecting sound), also TX and RX not blinking, neither are lit
I am trying to build a robot, which needs motors to roll around. So I was trying to control two DC motors with H-Bridge that comes with Arduino StarterKit(H-bridge motor driver [L293D]). I used Sketch that looks something like that
I did read that Arduino needs separate powering, but i did not use any only USB connection. I connected 5V that comes from arduino to where + pin from battery should have been connected and motors were controlled and working.
However when i tried using 9V battery and connecting it as seen on above picture ,H-bridge did not control mototrs and nothing was working.
There is also another aspect - when robot was touching the surface then wheels did not move aka motors did not rotate and when you picked it up motors accelerated to quite some speed. Also when robot was on the surface and connected via USB, the PC made these USB connecting sounds repeatedly.
I am not sure when RX and TX stopped working. Power LED and L13 LED do work correctly.
Any ideas? Is it Fixable?

Probably not - connecting a higher voltage to the 5v line likely killed it.  As for your performance issue, bipolar bridges such as L293/L298 have a lot of loss, so on batteries you may do better with an FET device like a TB6612FNG - but beware it is more delicate in the face of electrical abuse.  Did your bridge get hot?  What is the voltage & current ratung if your motors?

I did not touch the bridge so I do not know if the bridge got hot or not. Motors operating voltage is 1.5V to 3,3V and 10000rmp. What do you mean "connecting a higher voltage to the 5v"? I never connected 9V battery to arduino's 5V pin.

You should definitely avoid connecting anything else than 5v to these 5v(!) PINs. The Uno has regulators, but these only work when powered through the power-dc-connector (or USB). You can easily buy a 9v-block to dc-jack cable to connect power to the right point easily.

The "5V" pin takes only regulated 5V input.  Your schematic shows the the board powered here, and you mention 9V battery.  That's not a good idea.
If you have 7V-12V, then you can supply the board via the "Vin" pin.  It passes through the same regulation circuits that the DC jack does.
http://arduino.cc/en/Main/ArduinoBoardUno

VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.

May be your ATmega328 IC would have been damaged or ATmega16u or ATmega8u chip was damaged. I also got same few days ago.


text:
What is the most accurate sensor for detecting ping pong ball?
What is the most accurate proximity sensor for a ping pong ball? I will be using this to calculate 3D positioning of a ping pong ball in flight. I only need to detect the ball within 0-5 feet (basically on one side of ping pong table).

The range of motion is roughly a ping pong table length and width and maybe 4 feet in height.

Perhaps you should look into something like a leapmotion, or Xbox kinect. Not arduino.

Steven Levy in Hackers reports a tale about Marvin Minsky nearly being swatted by an early ping-pong robot when his bald head satisfied the vision system's ball-detection criteria.

The Arduino itself isn't really fit for video processing. We've used two webcams, one top and one side, to get an 3D location. Your algorithm has to be fast, we had most luck by using an orange ping pong ball on a green tabletennis background, and by just searching for the first orange pixel. Circle detection was way too slow for us.

If you're looking to make something functional, using a 2D airhockey table is much easier. Especially if you think of making a keeper robot.

I've had some good luck with using the Pixy camera system.
http://www.cmucam.org/projects/cmucam5/wiki
You get a maximum of 50 FPS and can detect and locate different objects based on hue. The library function getBlocks() returns the X and Y center location of each of the objects the camera detects. You teach the camera what hues to recognize as blocks, and adjust the detection thresholds. I use mine in monochrome infrared light by adding a visible filter and lens kit from http://irlock.com/

In the meantime a student has made a really impressive implementation, that might answer your question: interactive tennis table


text:
Waking Raspberry Pi on time schedule using Sleepy Pi
I'm have a Sleepy Pi and am having extreme difficulties trying to program a wake/sleep cycle. Sleepy Pi is an Arduino board with a RTC. My ultimate goal is for a time-lapse project.
I have the Raspberry Pi programmed and operational to take a picture on boot, my trouble is coming from trying to program the Arduino board to actually do it's job.
I would like the Sleepy Pi to wake at 8am, 9am, 10am, ..., 3pm, 4pm, and 5pm, each for 5 minutes, then go back to sleep. I've been working with the SleepyPi, Time, TimeAlarms, LowPower, and DS1374RTC libraries in the Arduino IDE. However, I cannot find any examples on how to put everything to sleep until a specific time comes around. Also, in several of my tests, it seems that the clock actually stops when the Sleepy Pi is asleep!
Here is what I've been working with (and this is non-working). It's probably completely wrong.
#include "SleepyPi.h"
#include <Time.h>
#include <TimeAlarms.h>
#include <LowPower.h>
#include <DS1374RTC.h>
#include <Wire.h>

// Set the status LED pin constant
const int LED_PIN = 13;

void setup()
{
  // Configure "Standard" LED pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN,LOW); // Switch off LED

  // Start with the Pi off
  SleepyPi.enablePiPower(false);

  // Set our communication rate
  Serial.begin(9600);

  // Set up our boot times
  Alarm.alarmRepeat(8,0,0, startPiUp);
  Alarm.alarmRepeat(9,0,0, startPiUp);
  Alarm.alarmRepeat(10,0,0, startPiUp);
  Alarm.alarmRepeat(11,0,0, startPiUp);
  Alarm.alarmRepeat(12,0,0, startPiUp);
  Alarm.alarmRepeat(13,0,0, startPiUp);
  Alarm.alarmRepeat(14,0,0, startPiUp);
  Alarm.alarmRepeat(15,0,0, startPiUp);
  Alarm.alarmRepeat(16,0,0, startPiUp);
  Alarm.alarmRepeat(17,0,0, startPiUp);
}

void loop()
{
  // Tick the alarm clock every second
  SleepyPi.enableWakeupAlarm();
  Alarm.delay(1000);

  // Cut Power if we detect Pi not running
  bool pi_running;
  pi_running = SleepyPi.checkPiStatus(true);
  if(pi_running == false){
    SleepyPi.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  }

  // Flash the LED
  digitalWrite(LED_PIN,HIGH);
  delay(1000);
  digitalWrite(LED_PIN,LOW);
}

// Function to tell the Pi to boot up
void startPiUp()
{
  // Turn the Pi on
  SleepyPi.enablePiPower(true);

  // Turn on the LED to signal we're here
  digitalWrite(LED_PIN,HIGH);

  // Keep the Pi on for 5 minutes
  delay(300000);

  // Start a shutdown
  digitalWrite(LED_PIN,LOW);
  SleepyPi.piShutdown(true);
}

I also cannot find a good way to "debug" things. I've been trying to use the LED flashes as a "I'm here" echo, but have been unsuccessful with this as well.
NOTE: I do not have enough reputation on this site yet to create new tags. Someone with over 150, please tag this with raspberry-pi and sleepy-pi. Thank you.

I would have thought you would use this device to wake the Pi, then have that do it's job & shutdown -h now, & use the checkPiStatus command to watch for that - it should save more battery than a set 5 minutes. You will then have the Pi status LEDs to se that power up/down, and can use the SleepyPi to monitor itself - Does it have a serial comms capability?

You're probably right, but I'm not even that far. I'm trying to get the device to just wake the Pi up on a set schedule using the RTC, and I cannot even get that part working. There seems to be no actual documentation about how to use the TimeAlarms library, and it seems like when I program the Arduino and the try to start the cycle, the RTC doesn't continue ticking.

I have just received my Sleepy Pi and am having trouble programming it to use for a timelapse controller for my Rpi. I just wondered if you have got any further with yours? I'm with you on the desire to set specific times in the day to fire up my Pi - all the code samples I've come across elsewhere just put the Pi to sleep for a nominated period.
There doesn't seem to be any decent documentation to support the Sleepy Pi code examples so I'm struggling to find my way forward with this

I have the same problem and  I just saw that they fixed a bug in a library used by SleepyPi
More specific, the RTC library file DS1374RTC.cpp reads since March: '2015
(which is after the question was asked)

Releases
    ========
    V1_0 - 10 Aug 2013 - Initial release
    V1_1 - 11 Mar 2015 - Mod:    Added "ackAlarm" and "ackRTCOSF" functions to aid Alarm use
  - Bugfix: Changed the way the "SetAlarm(tmElements_t   &tm)" was updating the Alarm time. It wasn't mapping correctly

They also added a new example to wake up the Pi: WakePeriodicallySimple.ino

Same probem. Kludgy solution ... but it works
Get the startstopsimple skectch from GitHub.
Set the period to 60 minutes
Set the timeout to whatever makes sense for you
Modify the setup function to loop until the clock says the minute is 59.
something like
do
{
   delay (100);
} while !(minute() == 59);

Then it will go into the loop function. It will be asleep. So it will then do a whole "empty" loop and sync after that, dunno how one gets rid of first the empty loop. But it works .... :-)


text:
Where can I find beginner tutorials for the Arduino?
I am new to all of this so anything is helpful.

There are hundreds of Arduino tutorials on the web (more than we could list here). A search engine should help you find them, and the official Arduino website is always a good place to start.

As above - PLUS load the Arduino IDE (you don'y have to own one) and on menu click Help then Reference. Each instruction is included with example code and explanations. Also in Help is "Getting Started" and "Frequently asked questions". Then in menu item File open "Examples" and you'll find many subfolders with working example code covering most areas.


text:
How do I use this sound sensor?
I bought one of these:

There are 3 pins on it:

5V
GND
OUT

My guess is that OUT is an analogue signal that I can measure with my Arduino, am I right?
I am using the "Analogue Output" example code but I just get 5V all the time, it does not seems to change with the sound levels.
Am I doing something wrong? What am I adjusting with the blue square on the board? Should I maybe do that?

Output should be +5V with no sound and 0V with sound. The AnalogInOutSerial example should display on your monitor wit values close to mx for no speech and close to ground for speech present.

The wording on this particular eBay item is pretty poor but there are plenty of similar products with better descriptions that are photographically identical... example that make a little bit more sense.
Anyway, I don't think this gives an analog value output, the LM393 is a comparator, so I think the blue dial sets the 'threshold level' and any sounds over that level cause a logic low. i.e. it compares the audio level and the dial and when one exceeds the other it gives a signal.
The features also say "The output effective signal is low level" which is probably Chinglish for the signal is a logic low, i.e. when the sound is heard it goes to 0V rather than 5V which is what I think you were expecting.
In summary: This device is is more like a Clapper, it detects a loud noise and sends a digital low signal.
Try making a loud noise with the same setup you already have, and if not try adjusting the potentiometer by turning it, but not too far! It probably only turns 180-270º.

Sound good, I will try to change potentiometer and check the output. Is it easy to turn it too far?


text:
what is the use of "<<=" operator?
I recently read this piece of code and I dont know what is the use of "<<=" in the for loop:
for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit

This is the entire code:
//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include <ctype.h>

#define bit9600Delay 100
#define halfBit9600Delay 500
#define bit4800Delay 188
#define halfBit4800Delay 94

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  delay(2);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay);
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread();
    SWprint(toupper(SWval));
}

As stated in the other answers, the <<= operator shifts the byte to the left; however, the number '1'  after it specifies how far to shift it - so, 2 <<= 2 == 8.
Possibly clearer in binary:
00000001 <<= 1 == 00000010
00000010 <<= 1 == 00000100
00000001 <<= 2 == 00000100

In simpler terms mask <<= 1 is shorthand for mask = mask << 1
In general
variable operator= operand

is the augmented assignment operator which means
variable = variable operator operand

<< is the left bit-shift operator. That means it takes the binary contents of a number and moves everything left by a certain number of binary places (1 place in this case). <<= simply combines the left bit-shift with an assignment, so it takes the current value of mask, shifts it left, and then stores the result back in mask.
In this situation, the mask variable starts with a value of 1. The second time round the loop, it will be 10 (binary). Next time, it will be 100, and so on. Since mask is a byte (which is 8 bits), it will go all the way up to 10000000 and then stop. After that, the 1 effectively falls-off the left and mask ends up with a value of 0.
The purpose of this in the code you provided is to test each individual bit within the data parameter. It basically goes through from least- to most-significant and checks if each bit is 1 or 0. It will then pull an output pin HIGH or LOW (respectively) to match. This allows it to send the contents of the variable digitally to some other device.
Doing low-level binary (aka bit-wise) operations like this is very common in microcontroller programming. If you're not familiar with it then I'd definitely recommend looking up some tutorials online. It opens up a huge range of new possibilities for your projects.


text:
Xbee power issue
I want to power xbee s2 module through atmel 328p digital output pin. And I am powering atmel 328p IC using 3.7 li-ion cell 5500 mAh. In sleep mode atmel consume current in micro Amp but xbee consuming around 40 mA. I want to reduce it. I tried xbee in power down mode but its not working for me. Is der any way to switch xbee automatically with as atmel sleep & wake-up. Circuit works properly when I power xbee through 3.7 v li-ion cell but consume power continuously.

The best solution would be to determine why your Xbee is not being switched into power down mode.
But, if you wish to turn the Xbee power off using the Arduino then there are many ways of doing this. One method is shown on the diagram below {from here}. This requires two transistors and three resistors. Almost any small transistors would work. Good choices if buying new components would be BC337 / BC817 for T1 and BC327 / BC807 for T2. The first part number in each pair is a through hole part and the second number is the equivalent surface mount part. If buying these try to get the -40 suffix versions, although in this case any version would work OK.
This circuit was drawn for use with a PIC processor controlling a 12V supply, but the Arduino works equally well controlling a 3.7V LiIon supply. The load is shown as a light bulb - that's where you'd connect the XBee.

Input low turns 1 off which turns T2 off. To enable/disable the XBee you have to raise / lower the input pin.

I would use a sleep mode, e.g. PIN sleep, in order to reduce the power consumption of the Xbee. At the hardware level, the XBee uses pin 9 as a control pin. This pin can be used to sleep the radio: setting it to 3,3V (“high” or “asserted”) causes the radio to sleep; setting it to 0V (“low” or “deasserted”) wakes the radio up. You can find some useful hints on the following websites http://citizen-sensing.org/2013/08/xbee-sleeping/ or https://www.digi.com/wiki/developer/index.php/Designing_a_Sleeping_XBee_Sensor  or here http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index.

Welcome to Arduino SE! Can you please edit your answer to include how exactly to do this and any relevant code/diagrams/etc.? Thanks!