text:
nRF24L01+ RF24 library - can send but can't receive
I'm prototyping out a board with temperature, humidity, windspeed sensors, and using an NRF2401+ board to send values to a Raspberry Pi base station that will record the data.
Using a Leonardo clone board, I'm able to successfully run the pingair_dyn sketch to send test payloads to the RPi and receive acks.  (So I know the RPi can send and recieve OK.)
Moving the same NRF2401+ to a breadboard setup with an ATMEGA328P-PU, the same sketch can send payloads which are received on the RPi, but always hits the timeout trying to get the ack (which the RPi is dutifully sending).
In fact when running pingair_dyn as a receiver, it just spins in the loop waiting for radio.available() to return true, which it never does.
The immediate problem is that radio.available() is always returning false.  So basically I can send but can't receive.
I have checked my wiring several times, and I'm mostly confident that it's right.

CE - physical pin 14 (arduino digital pin 8 )
CSN - physical pin 13 (arduino digital pin 7)
SCK - physical pin 19, per atmega328 datasheet
MOSI - physical pin 17, per datasheet
MISO - physical pin 18, per datasheet

In the software, I construct the RF24 instance:

RF24 radio(8,7);

Any ideas?  I tried swapping CE <--> CSN, then nothing worked.  Is there some wiring problem that would cause XMIT to work but RECV to fail?
I've tried putting a 2.2 uF capacitor across the 3.3V - GND as I've seen mentioned in other threads, but no difference.
Any suggestions on what is useful information to dig out of the RF24 library to give some idea of what's going on?
More background
Here is the RF24 debug info from the mega328
STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1    = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5    = 0xc3 0xc4 0xc5 0xc6
TX_ADDR       = 0xf0f0f0f0d2
RX_PW_P0-6    = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA       = 0x3f
EN_RXADDR    = 0x02
RF_CH      = 0x4c
RF_SETUP    = 0x07
CONFIG       = 0x0f
DYNPD/FEATURE    = 0x3f 0x04
Data Rate    = 1 MBPS
Model       = nRF24L01+
CRC Length    = 16 bits
PA Power    = PA_MAX

Here is the debug info from the base station (Raspberry Pi):
pyRF24/examples/pingpair_dyn/
================ SPI Configuration ================
CSN Pin          = CE0 (PI Hardware Driven)
CE Pin           = Custom GPIO22
Clock Speed      = 8 Mhz
================ NRF Configuration ================
STATUS           = 0x0e RX_DR=0 TX_DS=0
MAX_RT=0 RX_P_NO=7     TX_FULL=0         RX_ADDR_P0-1     =
0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR          = 0xe7e7e7e7e7
RX_PW_P0-6       = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA            = 0x3f
EN_RXADDR        = 0x03
RF_CH            = 0x4c
RF_SETUP         = 0x07
CONFIG           = 0x0e
DYNPD/FEATURE    = 0x3f 0x04
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_MAX

I have tha same problem, and this happens only with ATMEGA328P-Au microcontroler

The pins could be wrong for ATMega328.
It should be.
NRF24L01 - Arduino UNO
GND - GND
VCC - 3.3V
CE - 7
CSN - 8
SCK - 13
MOSI - 11
MISO - 12
or B. You need to connect a 500uF electrolytic capacitor to your NRF24L01+ VCC and GND pins directly. To reduce noise related issues. With clone arduinos/cheap regulators/clone NRFs then noise might start creating issues especially with receiving.

FWIW, I had packet loss issues using these boards, until I introduced those 3.3 V piggy back boards to supply current. I use them on both RX and TX now, but experimentation showed that the RX was where it made the crucial difference. Omitting the filter cap also didn't make any difference.
I don't know why these 5 V to 3.3 V piggy back boards were so effective; they're just a regulator. Maybe they've got better quality specs, or their own on board filter caps have a better frequency range for driving the nRF.
They only cost about a $, and save so much agro.

have a look at https://github.com/TMRh20 he's done some great work on the nrf24 radios and has code allowing connection between arduinos and pi's.
Oh and while i've played with non ip addressed data transfer a bit it wasn't the main focus of my research, but shouldn't the tx addresses be matched up?
also you mention a 2.2uf cap on the 3.3v line, but what is supplying the 3.3v line on the arduino side?
iirc the pi will supply enough current on its 3.3v line to supply the radio (i remember it working well enough) and i don't know what voltage your running the MEGA at, 3.3v or 5v with level shifters, either way i would imagine your power supply would be sufficient. Unless your running the mega at 16mhz and on a 3.3v (to be stable needs ~4.1v https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz)
Also iirc most nrf24's are happy enough with 5v logic level, although there are plenty of clones out there, you'll have to do your own testing.
And if you have one to hand would suggest starting off with a non breadboard arduino, get it to work before moving onto the breadboard... there is less that could go wrong :)

Answering questions in reverse order...
I mentioned that I was able to get a successful ping-and-response using an Arduino Leonardo before going to the breadboard.  So that was to establish that the nRF20L01+ hardware is in working order, and that the Pi setup was also working.
Currently running MEGA at 5V @8MHz, but supplying the radio a separate 3.3V feed off of an Arduino Uno that I have set up adjacent for use as the programmer ("Arduino as ISP").
As for TX addresses not matching, it didn't seem to matter with the Leonardo.  The Pi seems to have random value for RX_ADDR_P0.


text:
ttyACM0 no such file or directory On Ubunutu 14.04
I have an Arduino Uno which communicated with the computer (Ubunutu 14.04) fine till 6 days ago (I assume some software update is to blame).
Now when trying to upload I get
processing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu?   at processing.app.Serial.(Serial.java:191)    at processing.app.Serial.(Serial.java:77)     at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)    at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175)   at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)     at processing.app.Sketch.upload(Sketch.java:1671)   at processing.app.Sketch.exportApplet(Sketch.java:1627)     at processing.app.Sketch.exportApplet(Sketch.java:1599)     at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)     at java.lang.Thread.run(Thread.java:745)
When I sudo ls /dev/ttyA*
I get
ls: cannot access /dev/ttyA*: No such file or directory

So it does not look like a permission issue.
when I lsusb
I get
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 04f2:b39a Chicony Electronics Co., Ltd
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So it does not even see the device (which is connected and pulling current).
when I dmesg before and after connecting the Arduino, I don't see anything new.
I tried switching USB cables, and switching USB ports on the machine (both ports work with a mouse), but in vain.
What went wrong and how do I fix it ?
Thanks,
David.

Can you try the Arduino on someone else's computer?

@Majenko I tried on my wife's Mac and it didn't work, but I only installed the software on that machine for the purpose of the troubleshooting, so I still have hope that I did something wrong on it; I say "hope" because currently the leading options I see are: 1) something bad happened to the USB controller, 2) two faulty cables (that one is hard to believe)

Does the power light illuminate?  Does the LED on pin 13 blink a couple of times when you first connect it?

@Majenko even better - there was a program on it (which my kid wrote at the beginning of the week); when we plug the arduino it still runs ...

The next step would be to try to access the USB comm chip out of band. You wouldn't happen to have a AVR ISP programmer or a second, working Arduino, would you?

@IgnacioVazquez-Abrams I'll get my hands on a second arduino on Sunday. What should I do then ?

Follow the ArduinoISP tutorial and hook it up to the 6-pin connector near the small chip (Atmega16U2) closest to the USB connector, then use avrdude to try and communicate with the chip.

Ok, it sounds like there is an issue with the ATMega(8/16)U2 chip or its surroundings.  It might just need its firmware refreshing (which can be done with another Arduino as a programmer) or it might be plain dead.
Another possibility is the USB socket itself.  I have two UNOs, one which is perfectly fine, and one where I need to hold the cable at just the right angle for it to connect properly.  You can try using a fine needle to try and raise the four metal strips in the USB connector a fraction to make better contact.

source: Stack Exchange

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

sort: votes


text:
Lithium Polymer/LiPo set to power Arduinos
I want to switch from using disposable 9V blocks to a proper setup of 3.7V LiPolys for all my portable Arduino (Uno/Mega) projects consisting of:

only 3.7V LiPo units
charger
upconverter (to 5V)

My questions:

Is this generally a good idea? Or is there a better solution for portable Arduino power?
How should I actually hook the LiPolys up to the Arduino? They usually ship with JST connectors. Should I use the Vin/GND Pins or should I build my own JST/DC-Connector adaptor? I want to create a robust, pluggable solution.
Am I actually losing power twice that way (once in the upconverter and then in the Arduino voltage regulator)?

If you are using the boosting regulator to get 5V you wouldn't need to put it into the Vin pin, so you won't loose power there. The boosting regulators are also efficient anyway.

Keep safety in mind when moving to LiPo batteries.  Many people don't know that they are more volatile than your average battery.  Research/youtube LiPo fire, they're not common but actually do occur.  Lots of people out there charge in a fire retardant lipo bag.  Your choice, but always good to be informed.

Thanks to all the replies! However, I still feel my questions are not actually addressed yet.

If you can get away with it, I recommend not using a boost converter and instead connecting the battery directly to the supply voltage input (the "5V" pin).
The AVR chips used in most Arduinos (but not the Due or Zero [and the Yún and Tre are a totally different kettle of fish entirely]) can operate with anywhere between 2.7 and 5.5 volts, with the ATmega328P found in the Uno able to run with as little as 1.8V. This is a much larger range than the 3.0-4.2V available from rechargeable Li-ion/Li-poly/LiFePO4 cells.
Naturally you will need to make sure that any external components can run with the reduced voltage as well, but quite a few are able to work with anything from 2.0 to 5.5 volts.

When the lipo is near the 3V range and the uno board is at 16MHz one might need to disable the resonator surely?

Or just set the prescaler to /2. For added safety, program the CKDIV8 fuse and set the prescaler in setup().

good point ;) should have thought. +1

You don't mention the DC plug. That should not be used in this case? How can I create a solution with plug?

Isn't the "5V" pin output? Or do you mean "VIN"?

@HaukeHoltkamp: You don't want to use the plug. The plug passes through the linear regulator.

@FuaZe: The "5V" pin is the output of the regulator, but it is the input of the MCU supply rail.

Ah, so you bypass the regulator. Will it work with an USB cable connected?

@FuaZe: Not without effort. It would probably easier in the long run to use a breakout board for the MCU and a USB comm chip with a level translator.

Sparkfun do the ideal solution for you - their "LiPower" shield:

https://www.sparkfun.com/products/10711

It contains the Li-Ion / Li-Poly charger, 5V boost converter, and MAX17043G+U fuel gauge chip.

Note their warning re a hardware bug that disables low voltage cutoff and the need to implement a software work-around.

@RussellMcMahon Yea, that is a bit of a pain - but with the fuel gauge chip you can guestimate how much power is left, and with a simple P-channel MOSFET circuit you can shut off the power completely when it gets too low.

I just ordered one. What is that bug exactly?

There is a facility in the charge chip to monitor the voltage and if it's too low to trigger a shut-down circuit. They just didn't use it. You can connect the + of the battery direct to an ADC input and monitor the voltage yourself if you want to protect the battery against over-discharge.

Consider using 2 x LiPo is series (2S). Vmax is 2 x 4.2V = 8.4V
This may be attractive compared to boosting from a single cell.
This is still < the 9V you used previously.
Vmin is say 2 x 3V = 6V - but higher is better for the LiPos.
You can use a buck converter or a linear regulator as desired, and could use one or other depending on project.
You could even use linear + buck in parallel for applications where sleep current is very small and buck converters may find efficiency at very low I challenging.
Using 5V rather than less than 5 is attractive in that you do not need to ensure the processor speed will accommodate the lower voltages.
Using a linear regulator and 5V:
Efficiency at 4V/cell = 5/8 = 62.5%.
Efficiency at 3V/cell = 5/6 = 83%.
Any sensible buck regulators will be more efficient at more than a few mA but at very low currents that may be acceptable.
2 LiPo in 2S will notionally need balancing occasionally but this is easy to do informally occasionally or using any of the many available charging ICs.

How would I plug the two LiPos together reliably (and portably)? And should I use the Arduino's DC plug?

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


text:
What are the different types of high-speed serial data transfer protocols, and how do they work (ex: baudrate, synchronous vs asynchronous, etc)?
Otherwise worded: How do I resolve my understanding about baud rates and high speed serial data transfer?
From what I understand, serial communication is relatively slow.  By slow, I mean that the fastest common rate of transmission of data is 115.2 kBaud.
However, also from what I understand there are fast ways of transferring data serially.  I know that some serial configurations through Firewire or Ethernet can transfer data at speeds that are orders of magnitude higher than 115.2 kBaud.  These data streams are able to be read on simple computers that you can buy from Staples.  I don't know how these systems receive data at such a high speed if common baud rates are so low.
I know something is wrong with my understanding of it all.  I am new to electrical engineering and I am trying to teach myself some basic ideas for my research project - with much frustration.  I know that I need to have a system that can receive a pulse train at a minimum speed of 10MHz (hopefully up to 500MHz).  I will then program it to process this data.  The system that I currently have to receive the data is an Arduino certified product:
http://store.arduino.cc/product/E000052
Programming in the Arduino language is not a problem, I already know how to do this.  I just want to understand what I can do to receive this data stream.  Do I need something faster than this?  Or will this suffice?  I'm more interested in the theory than the device; it is more valuable for me to bolster my education than for me to solve my problem (though it needs to be solved).

Basically there are two kinds of serial: Asynchronous and Synchronous.
With asynchronous, which is what serial as in UART and RS-232 are, it's all down to how accurate a system's clock is.  Both ends of the line have to agree on the same speed (baud rate) and any deviation from that causes transmission errors.  The more accurately the two ends can agree on their baud rates the faster you can transfer data.
Note that on many systems (Arduino included) when you ask for one baud rate you actually get a slightly different baud rate.  That's due to the way that the internal UART hardware works - it divides the system clock into finer and finer bits to get as close to the requested baud rate as possible.  Lower baud rates are easer to get close to, but higher ones are much harder.  So it's "safer" to use a lower baud rate which gives more reliable communication to a greater variety of devices.

http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

The other kind of serial, synchronous, uses an extra wire for the transmitting (or master) end of the connection to send the clock to the receiving (slave) end.  The receiver uses the incoming clock to know precisely when it should look at the data line to receive a bit of data.  This is how things like SPI and I²C work, and very high baud rates can be achieved.  Speeds in the tens of megahertz are common.

http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
http://en.wikipedia.org/wiki/I%C2%B2C

Some synchronous systems (such as Ethernet), instead of providing the clock as a discrete wire, encode the clock into the data stream.  This keeps the number of wires to a minimum yet allows high speed data transfer.  The down side is that this usually means the maximum speed you can run at is actually slightly lower since the effective size of the data being transmitted is increased.

http://en.wikipedia.org/wiki/Clock_recovery

The other answers have really good info in them, but I'd still like to expound a bit on the different types of serial protocols, and how they vary in speed. I'll also mention a few devices and show some comparisons. For synchronous vs asynchronous and what that means, see Majenko's really good answer.
Clarification:
Your phrasing of "receive a pulse train at a minimum speed of 10MHz" is quite confusing to me. Perhaps this is because when I hear "pulse train" I think you mean you want to read pulse widths in order to obtain data, ie: like the PPM pulse train used in Radio Control communication signals.
Is what you mean simply that you want 10Mbps (megabit per second) transmission rates? If so, the Arduino Intel Galileo can do SPI serial communication at a rate of up to 25MHz, or you can do Ethernet communication with this board up to 10 MHz or 100 MHz (see previous link as well). Note that some Ethernet devices can communicate up to 1000 MHz (like the Orange Pi Plus), but the Intel Galileo only goes up to 100 MHz, according to the link above.
USB3.1 serial communication, if a device supports it, however, can be done up to 10Gbps.
Standard RS-232 0-5V (TTL) Serial, and example:
Now, as for standard RS-232-type serial done with TTL logic levels (ie: signal voltage levels 0 to 5V), via a UART (piece of hardware that allows this type of asynchronous communication protocol), I have written C++ code on a PC and on a standard Arduino (ex: Nano, Uno, or Pro Mini--under $10 cost + $2 external UART) which communicates at 250kbaud (though 2Mbaud is possible on an Arduino Uno--see Connor Wolf's answer here).
When communicating via a serial UART type device, plugged into a PC via a USB plug, a Windows-based computer sees it as a "COM" port. The UART simply does USB to RS-232 TTL data conversion, so I can use this COM port as a serial port on the PC. Since pretty much every Arduino supports standard Serial communication, even the cheapest ones, this is very appealing to me to learn how to write C++ code to do this. I spent the last couple weeks working on my communication code.
At a serial communication speed of 250kbaud (250kbps in my case) I am able to transfer 25-byte binary data packets from my PC to my sub-$10 Arduino at a rate of up to 1000 packets/sec, while doing error checking on the Arduino receiving the data. In my case, each packet contains 8 commands, plus error checking bytes and a couple other things, to control an RC vehicle.

Here's a few key serial protocols, and their associated speeds, to be aware of.
All of these are different types of serial communication protocols:

I2C:
Normal Arduino (ex: Uno) default speed is 100kbps; it can be increased to 400kbps. Some non-Arduino devices can do 1Mbps or 3.4Mbps.
SPI:
Arduino default speed is 4Mbps. Normal Arduinos can go up to 8Mbps; Galileo can do 25Mbps. I have seen some devices (ex: Wiznet W5200 Ethernet chip), which can do SPI serial communication up to 80Mbps (source).
RS-232 TTL via UART:
This is what most people mean I think when they just use the word "serial" without specifying it further by saying "SPI," "I2C," etc. Whenever you see the term "baud" or "baudrate," this is the type of serial communication they are referring to too. Hardware (UART)-based serial communication is done via pins 0 and 1 on most Arduinos. Normally, the "high-end" speed is considered 115200bps, but I regularly use 250kbps on an Arduino. Up to 2 Mbps is theoretically possible under the right conditions for the Atmel AVR-based Arduinos, like the Uno. See Connor Wolf's answer here. Arduino also includes a software serial library for this type of serial communication on any of the Arduino's pins, and I have used it up to 250kbps. I haven't yet tested it beyond that speed, but being software-based, I'd expect it to become unreliable much beyond that.
USB:
USB Speeds (https://en.wikipedia.org/wiki/USB)
USB 1.0: Low Speed mode (1.5Mbps), Full Speed mode (12Mbps)
USB 2.0: High Speed (480Mbps)
USB 3.0: SuperSpeed (5Gbps)
USB 3.1: SuperSpeed+ (10Gbps)
Ethernet:
Standard rates are 10/100/1000 Mbps.

Conclusions:

If you must have a minimum of 10MHz (AKA mbps) communication rates, you can use the SPI, USB, or Ethernet protocols. I2C and RS-232 TTL serial are too slow.
If you really want the ~500MHz communication rate, you can use USB 2.0 or higher, or Ethernet 1000Mbps. All the rest are too slow.

Note that embedded boards and devices, microcontrollers, etc, can all do some type of serial communication, even if it's just slow bit-banged RS-232 TTL-type or SPI-type serial. Nevertheless, some high-end devices can do really high speed serial communication via USB, USB 3.0, high-speed Ethernet, high-speed SPI, etc. When it comes to really fast serial communication methods (~3Mbps and higher), synchronous techniques must generally be used rather than asynchronous techniques, as the errors in clock-rates caused by using separate clocks begin to be too pronounced.
You just need to look at your actual needs. For most of my needs, 250kbaud is plenty fast using the built-in UART inside every cheapo low-end AVR-based Arduino device. Your needs, however may be different.

Different serial communications protocols use different signal modulation methods to encode data; if you want to roll your own wire protocol, you'll want to learn about those.
Back in the day, low-rate UART serial systems were mostly used with modems that had to transmit long distances over voice telephone circuits. Those circuits were bandwidth-limited to the needs of voice communication, and were frequently "noisy", so phone line modems never evolved beyond 56Kbit/s rates. The UARTs themselves could go faster, so if you were doing a local serial connection you could get up to 115kbps. These UARTs were relatively cheap.
More advanced encoding schemes plus more expensive hardware (with a lower noise floor) allowed connections about 100 times faster -- 10mbps ethernet. That's a much more common standard now than RS-232 serial connections, and as it became widely adopted it got cheap, and so 100mbps and gigabit ethernets followed the same form factor and basic electrical characteristics because (under good conditions) all could work over the same wiring, so compatibility with existing systems was good; the endpoints for the most part can automatically downgrade to whatever speed is supported by both ends of a given wire.


text:
Simple question about the SPI clock for Intel Edison
I am doing a project with an Intel Edison Arduino breakout board.
http://store.arduino.cc/product/E000052
http://download.intel.com/support/edison/sb/edisonmodule_hg_331189002.pdf
I have a device that I want to communicate with by SPI.  This device can receive a maximum of 16MHz for its clock.  I want this maximum speed of 16 MHz.  From what I understand, the Edison can output a clock speed of 19.2 MHz.
I don't know much about clocks and I am still learning.  Is it possible to program the Edison to operate its SPI output clock at a speed of 16 MHz?  If so, how would this be done?

SPI.setClockDivider(SPI_CLOCK_DIV2); would make it run at 9.6mHz

Is it only possible to divide the clock by 2?  Not by decimal numbers?

Look into the function mraa_spi_frequency.


text:
How to use code for OV7670 on Arduino Uno
I want to interface my OV7670 camera (without FIFO) to my Arduino Uno. I have browsed internet quite a lot about it and found people either saying it's not possible or they just give me the link to this github repository (As this guy has done exactly what I want). As the author of this repository is a man of few words, he did not help me very much. I just want to know how to use this to get image sent to my PC serially. I only know how to use Arduino IDE in windows platform and no other platform.

rename main.c to .ino, and change int main(void){ to void loop(void){

Hello, I did exactly that and now it shows this error.
sketch_apr17a.cpp.o: In function loop': H:\arduino-1.0.3_1/sketch_apr17a.ino:122: undefined reference to camInit()'
H:\arduino-1.0.3_1/sketch_apr17a.ino:124: undefined reference to setRes(unsigned char)' H:\arduino-1.0.3_1/sketch_apr17a.ino:125: undefined reference to setColor(unsigned char)'
H:\arduino-1.0.3_1/sketch_apr17a.ino:126: undefined reference to wrReg(unsigned char, unsigned char)' core.a(main.cpp.o): In function main':
H:\arduino-1.0.3_1\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'

Apply the fix in http://stackoverflow.com/a/21276414 to 0v7670.h

Hey, gerben. What I did is just changed the name of the main.c to .ino and copied the content of ov7670.c to that sketch and compiled and it compiled succefully. All I want to know is, can I do it this way?

I am ComputerNerd. I read this post and realized the real problem and why I am having difficulty helping you. You are asking the wrong question. What you should be asking is "how do I compile it using GNU Make and Avr-Gcc on Windows?". Instead you are asking "how can I use this code in the Arduino IDE?".
The answer to what you should be asking is simple. Use what you already have. The Arduino IDE ships with Avr-gcc and (maybe) GNU Make. Just run the programs directly. Better yet download MinGW and compile GCC to target the AVR yourself.

Thanks ComputerNerd, I was not able to ask more technically right question but I anyway got the solution about running your code in Arduino IDE.

ComputerNerds work is good, but it is has only code and limited description. I have prepared detailed instruction using his code. You can try it: How to use OV7670 and Arduino uno

I have successfully compiled the project in arduino IDE, simply concatenated main.c and ov7670.c ov7670.h into .ino file
didn't test it with the camera yet, but it uploaded to my arduino (Duemilanove)
Tell me if it worked for you...
see here:
https://github.com/eranws/ov7670-no-ram-arduino-uno


text:
Communicating with Arduino
In this Question how does the code Processing work?
Which programming language is it written in? How to run it?

Note that you aren't required to use Processing in order to communicate with the Arduino; the Arduino uses standard serial communications, supported by almost every programming language in one form or another.

Can I use C++? If so, how? I know basics of C++, so it will be easier for me.

Can C++ support standard serial communications?

@IgnacioVazquez-Abrams , Yeah, but very long and difficult process.

"Processing" is a simplified programming language/environment based on Java. It's designed to be very easy for non-programmers to use, and is quite a popular choice for using alongside Arduino projects.
You can download it for free (and get lots of tutorials/documentation) from here:

https://processing.org

As a side note, the Arduino IDE was based on Processing, so it will probably look familiar!

how to run Processing programs alongside Arduino?

@Mathsman100 You run Processing on your PC or Mac or whatever and generally communicate with the Arduino via serial connection (USB).

So, do you first run the Processing program or do you open the Serial port before that?

@Mathsman100 Your Processing program needs to open the serial port. There are lots of tutorials online which you might find helpful. Here's one: https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing


text:
Can't communicate with arduino using python (Windows)
I am new to programming and am trying to communicate with my arduino using python through serial communication. I am using the following code:
Arduino code:
int ledPin = 11;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
}

void loop() {
  digitalWrite(ledPin,LOW);
    if (Serial.read() == 'M'){
      digitalWrite(ledPin,HIGH);}
}

Python code:
import imaplib
import serial
ser = serial.Serial("COM3",9600)
ser.write(b'T')
ser.close()

I get the following error on running the python script:

serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)

After you figure out why you get that error (based on the answers below) there is another potential problem in your python code - when opening the serial port the Arduino will reset, so anything sent immediately after connection will not get to your sketch. Using a delay after connection will help

More than likely you ran the Arduino program from the Arduino IDE, and left the terminal window open. You must close it before you run the python program, as it will already 'own' the port until it closes. You dont have to quit Arduino IDE, just close the terminal window.

Not sure what 'terminal window' user6569 meant, but closing the Serial Monitor window from my Arduino IDE did help.

There can be several reasons as highlighted in these questions:

https://stackoverflow.com/questions/6032568/using-serial-on-python-win7
https://stackoverflow.com/questions/6105182/error-while-opening-port-in-python

They include:

port is already in use by another application
permissions are set to deny access to normal users
problems in the code (top answer in first link)

Try to run with administrator priviledges ("run as administrator"). Others claim that a simple retry might help.

Either run your python program in "administrator mode" or close any other programs using the port intended for

Are you by any chance using Jupyter Notebok? I was having a similar error today and managed to solve it by opening Jupyter Notebook through Anaconda Navigator instead of opening it through Anaconda Prompt.

you must use this code
>>> import serial
>>> ser.close()             # close port

Please add detail on how this solves the problem the OP is asking.

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


text:
Why Firmata Test doesn't allow me to choose a port?
I'm a beginner and, sorry, also I don't speak English very well. However, I'm going to try to explain my problem.
I'm working on Ubuntu 14.04.2 and Arduino Uno R3.
I downloaded Firmata Test binaries for Linux 64 bit, I gave it permissions with chmod 754 <file>. Also I uploaded StandardFirmata from Arduino IDE to the board. Afterwards, I quit Arduino IDE and ran Firmata Test with ./file. But, the Port menu has no items within. I tried restarting the board and the application as well.
What can I do?

If your user does not have access to serial ports, rather than running an application as root with sudo, try giving your user the appropriate permissions by adding to the dialout group before you run it.
https://askubuntu.com/questions/112568/how-do-i-allow-a-non-default-user-to-use-serial-device-ttyusb0

I had the same problem until I ran it as:
sudo ./file


text:
error C1083: Cannot open include file: 'Ethernet.h':
i'm trying to compile native code in VC++ using galileo sdk for windows iot.
I've copied Ethernet.h file to the include directory of
D:\galileo-sdk-develop\galileo-sdk-develop\source> but still getting error on cannot open include file "Ethernet.h"


text:
Arduino Yun not showing up in Windows or Linux [software issue?]
I've got my Arduino Yun (less than a year old) connected to my computer via a USB cable. The device seems to be on (that is, the lights are all on). However, the Arduino is not showing up in either the /dev/ttyACMx (linux) or COMx on my Windows boot. Does anyone have any suggestions for why this could be? I've tried to reset the Yun to factory settings by holding the WRT RST button for 30+ seconds, but that still didn't fix anything.
I'm afraid that I'm now looking at a bricked Yun; if this is the case, what could / should I do?
Thanks!
EDIT: I have the 1.6.0 version running. I'm indeed using a microUSB cable to connect to the arduino via USB. If I'm connected to the Arduino-90xxxxxxx wifi network, I can still push sketches to the arduino. However, I'm unable to see the arduino over serial, both in the IDE / terminal. The only port I see in the IDE is 192.168.240.1
EDIT2: I was able to see my Arduino Yun in the IDE again after flashing the blink sketch via wifi and resetting the 32u4. This makes me think that it's a software issue due to the sketch I'm pushing. Is there something that I could be calling which would make the Arduino unable to connect via serial?

Can confirm that connecting to the YUN via WiFi and flashing some simple program like the blink sketch to it will fix the issue. Would suggest moving your EDIT2 to a self answer so it's obvious there is a solution found.


text:
What is the physical location of the U1A symbol on Arduino Uno?
I'm trying to find an easy way to allow an Arduino Uno to determine if it's being powered from USB or the DC barrel jack. In this thread, one user recommends wiring the output of the on-board comparator op-amp (U5A pin 1) into the digital input pin.
I couldn't find U5A on the current schematic, but I think he's actually referring to U1A pin 1. Is this correct?
Unfortunately, I'm not sure where on the physical Arduino that device is located. I have one in front of me, and almost none of the parts are labeled on the silk screen. How do I find out where it is? I've googled for Arduino Uno part placement schematics, but all I'm finding are blurry unlabeled low-res images.

The op-amp is a LM358 so you can look at the ICs themselves. Also it's a dual comparator with 8 pins. On my example image below you can see it below the crystal. I can't comment if that's the correct way to sense what you need, but it seems the comparator output should be 1 if there is external power applied. You could check with a multimeter.


text:
Difference between print() and println()
What is the difference between print( ) and println( )?
I see none when I run a code.

Really? Try a few of each in sequence and see if you see any difference.

Ya, now I see a difference

The answer to this question could have easily be found on the Arduino site.

The ln from println comes from line, meaning it will print a new line character at the end

print() prints whatever you send in.
println() does the same thing, only after using println, anything new that is printed gets printed in next line, I.e. a new line is formed.

Could you post your code please, as my answer is kind of incomplete now.

An easy way to see the difference is using Serial.print();/Serial.println();.
print();

will print out whatever you input wherever the cursor currently is. For example:
Serial.print("Test");
Serial.print("Words");

This will print:
TestWords_

The underscore marks where the cursor is (and therefore where the next print command will start). In contrast, the code:
Serial.println("Test");
Serial.println("Words");

will print the following:
Test
Words
_

You can also print multiple statements and then follow with println like so (note the space at the end/beginning of the strings):
Serial.print("These ");
Serial.print("Test");
Serial.println(" Words.");

to get the following output:
These Test Words.
_

You can also use println(); to add a newline character in general. If you would print a variable that doesn't return a newline character, println(); can be used for formatting. Example:
int x = 50;
Serial.print(x);
Serial.println();

This will print:
50
_

Finally, you can add in special characters like a tab \t inside your quotes for formatting. Example:
Serial.println("Test\tTest")

This will return:
Test    Test
_

Your answer tells us that println() function prints what's in the parenthesis then prints a newline character rather that printing a newline character first and then printing what's inside the parenthesis. Your idea of underscore for showing the cursor position is quite very nice. +1 for all that.

The print("aString") method prints just the string "aString", but does not move the cursor to a new line. Hence, subsequent printing instructions will print on the same line.
The println("aString") method prints the string "aString" and moves the cursor to a new line.
The println() method can also be used without parameters, to position the cursor on the next line.
Regards

print() print which you want but in one line.
For example,
Serial.print("Hello");

Then output in Serial Monitor look like,
HelloHelloHelloHelloHello

println() print same things but in new line.
For example,
Serial.println("Hello");

Then output in Serial Monitor look like,
Hello
Hello
Hello
Hello
Hello


text:
Alternative to Tone( )
Is there any way to make sounds using an Arduino without using the tone function?
It must be possible via this new method to control frequency of sound.

Do you want "sounds" or do you want "notes"?

I'm not sure, but does analogWrite(200); make a sound for you?

Why would you want to? Pretty much the only way, is to create a 50% duty cycle PWM at a certain frequency. And that is exactly what tone does. If you are interested in how it does that, you can look at the source code (https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Tone.cpp)

@Gerben reasons not to use tone: timer clash with other libraries; (apparently) increased code size; and potentially just to understand and explore the low level engineering

I've used a somewhat more complex method with some success, which uses 2 timers to play 8kHz sampled audio. The idea is that one of the timers runs at 8kHz to determine the PWM duty cycle of the other, which runs at as fast a frequency as possible.
While the original code uses a short stored sample (On an Arduino, you could store maybe 3 seconds of audio that way), my usages involved computing the audio on the fly by overlapping several sine waves or using table lookups with varying strides. As long as computation is kept simple, this just barely works.

You wrote that?  Thanks!!  That helped me so much a few months ago!

To clarify: I did not write the code on arduino.cc, but I used a modified version of it in some projects of my own.

Thanks a lot, but anyway, I got an answer myself.
I can use the simple delaymicroseconds( ) .
Also, I can use timer interrupts to do basically the same thing
And these are a lot less complicated than the other answers I got.


text:
Porting Arduino code to AVR/C++ input not working?
So. I'm trying to read an input on the Arduino Nano using C++/AVR/Eclipse instead of the regular arduino IDE.
The code below is working in the arduino IDE
void setup() {
  // put your setup code here, to run once:
  pinMode(13, OUTPUT);
  pinMode(5, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(5)){
    digitalWrite(13,1);
  }else{
    digitalWrite(13,0);
  }
}

I'm porting the code to AVR/C++ in Eclipse, regular blinking leds is working... but I can't read inputs for some reason...
#define F_CPU 16000000UL //16MHz
#include <avr/io.h>
#include <util/delay.h>

#define set_bit(Y,bit_x) (Y|=(1<<bit_x))
#define clear_bit(Y,bit_x) (Y&=~(1<<bit_x))
#define isset_bit(Y,bit_x) (Y&(1<<bit_x))
#define toggle_bit(Y,bit_x) (Y^=(1<<bit_x))

int main( ){
    DDRB = 0xFF;//Setting all portB pins to output (D13/PB5 - LED)
    DDRD = 0x00;//Setting all portD pins to input  (D5 /PD5 - INPUT)

    while(1){
        if(isset_bit(PORTD,PD5)){//if input... doesn't work?
            set_bit(PORTB,PB5);//Set output (Tested to be working)
        }else{
            clear_bit(PORTB,PB5);//Clear output
        }
    }
}

Use the checkmark next to the answer rather than changing the title to indicate that the question has been answered.

During the creation of this question I found out the answer... Though I wanted to share it with you guys for later reference.
It has been quite a time since I have worked with AVR.
You should read pins from PINx
You should set pins in PORTx
Set DDRx to 1 for OUTPUT and to 0 for INPUT
^ This is fun because PIC/Microchip MCU's use 1 for input and 0 for output.
See code below:
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>

#define set_bit(Y,bit_x) (Y|=(1<<bit_x))
#define clear_bit(Y,bit_x) (Y&=~(1<<bit_x))
#define isset_bit(Y,bit_x) (Y&(1<<bit_x))
#define toggle_bit(Y,bit_x) (Y^=(1<<bit_x))

int main( ){
    DDRB = 0xFF;
    DDRD = 0x00;

    while(1){
        if((PIND&(1<<PD5))){
            set_bit(PORTB,PB5);
        }else{
            clear_bit(PORTB,PB5);
        }
    }
}

This is interesting, what pins are you reading and writing? And how would you take an analog reading?

@user2497 The microcontrollers use registers that you can read/write to/from. Arduino is an environment and a wrapper around this, to make it easier and more understandable. You should check the datasheet, to find which registers hold what. The registers are 1 byte (I bits), so you'll have to do some bit manipulation/arethmic and write it to the correct registers.


text:
Best Header for Arduino Nano
I would like to be able to create permanent projects with my arduino Nano but be able to remove the nano in order to use it in other projects. The arduino Nano has 30 pins so I would be looking for some kind of female 30 pin header. Most of the headers that I found like that are too narrow because they are for IC's. Any ideas?

@Dwayne's answer is useful. The key seems to be looking at "board to board connectors which 'expect' a larger pin insert. At Digikey a good solution MAY be CES 50 way 1 row

Typically, dual row connectors with some space between them are referred to as "sockets" for "Dual Inline Package" (DIP) IC's, and other things having similar form factors.   Connectors intended for wiring harnesses and board stacking are typically the ones called "headers".  For an odd spacing, you simply buy two single row ones, and place them on your board appropriately.

The Nano boards that I have used all have pins on 0.1" (2.54mm) spacing.  There are single-row female connectors that are designed to accept 0.025" square pins.  One example is Samtec 32 position female header but there are many others.
Note that these female headers are available to accept either 0.018" round or 0.025" square pins.  My great preference is for the 0.018" round pins but those are less common in hobby circles.
The really huge advantage of the smaller round pins is that you can safely insert them into solderless breadboards without damaging the contacts in the breadboard.  But you would want to standardize on one style or the other.

I use the female headers from the original Nano manufacturer: http://gravitech.us/2015feheanas.html

You've already got a lot of really good answers here but I thought I would offer another product suggestion.  I purchased some of the 12 pin versions of these https://www.pololu.com/product/1031 for some recent projects.


text:
Arduino error in code
i'm making a project and i came across the follwing error.
Whan i'm trying to compile and upload the code i'm getting those errors:
ShiftRegisterTest1.ino:In function 'int* return_pins(int)'
displays.ino:9: error: expected primary-expression before '{' token
displays.ino:9: error: expected `;' before '{' token
displays.ino:12: error: expected primary-expression before '{' token
displays.ino:12: error: expected `;' before '{' token
displays.ino:15: error: expected primary-expression before '{' token
displays.ino:15: error: expected `;' before '{' token
displays.ino:18: error: expected primary-expression before '{' token
displays.ino:18: error: expected `;' before '{' token
displays.ino:21: error: expected primary-expression before '{' token
displays.ino:21: error: expected `;' before '{' token
displays.ino:24: error: expected primary-expression before '{' token
displays.ino:24: error: expected `;' before '{' token
displays.ino:27: error: expected primary-expression before '{' token
displays.ino:27: error: expected `;' before '{' token
displays.ino:30: error: expected primary-expression before '{' token
displays.ino:30: error: expected `;' before '{' token
displays.ino:33: error: expected primary-expression before '{' token
displays.ino:33: error: expected `;' before '{' token
displays.ino:36: error: expected primary-expression before '{' token
displays.ino:36: error: expected `;' before '{' token
displays.ino:39: error: expected primary-expression before '{' token
displays.ino:39: error: expected `;' before '{' token
displays.ino:42: error: expected primary-expression before '{' token
displays.ino:42: error: expected `;' before '{' token
displays.ino:45: error: expected primary-expression before '{' token
displays.ino:45: error: expected `;' before '{' token
displays.ino:48: error: expected primary-expression before '{' token
displays.ino:48: error: expected `;' before '{' token
displays.ino:51: error: expected primary-expression before '{' token
displays.ino:51: error: expected `;' before '{' token
displays.ino:56: error: expected primary-expression before '{' token
displays.ino:56: error: expected `;' before '{' token
Error compiling

I don't really understand why since the code (see below) should be working.
int * return_pins(int get_number)
{
static int rp[8];
switch(get_number)
{
            //DP, A, B, C, D, E, F, G
    case 48: //0
        rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};
        break;
    case 49: //1
        rp[8] = {0, 0, 1, 1, 0, 0, 0, 0};
        break;
    case 50: //2
        rp[8] = {0, 1, 1, 0, 1, 1, 0, 1};
        break;
    case 51: //3
        rp[8] = {0, 1, 1, 1, 1, 0, 0, 1};
        break;
    case 52: //4
        rp[8] = {0, 0, 1, 1, 0, 0, 1, 1};
        break;
    case 53: //5
        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};
        break;
    case 54: //6
        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};
        break;
    case 55: //7
        rp[8] = {0, 1, 1, 1, 0, 0, 0, 0};
        break;
    case 56: //8
        rp[8] = {0, 1, 1, 1, 1, 1, 1, 1};
        break;
    case 57: //9
        rp[8] = {0, 1, 1, 1, 1, 0, 1, 1};
        break;
    case 65: //A
        rp[8] = {0, 1, 1, 1, 0, 1, 1, 1};
        break;
    case 70: //F
        rp[8] = {0, 1, 0, 0, 0, 1, 1, 1};
        break;
    case 69: //E
        rp[8] = {0, 1, 0, 0, 1, 1, 1, 1};
        break;
    case 80: //P
        rp[8] = {0, 1, 1, 0, 0, 1, 1, 1};
        break;
    case 72: //H
        rp[8] = {0, 0, 1, 1, 0, 1, 1, 0};
        break;
            //DP, A, B, C, D, E, F, G
    case 45: //-
    default:
    rp[8] = {0, 0, 0, 0, 0, 0, 0, 1};
    break;
}
return rp;
}

What this code does is to basicaly get an int ad input and based on this number it returns an int array. It's a very simple code which is called inside the loop() method which is located on an other file.
Also i'm using Atmel Studio 6 instead of the original Arduino IDE but i dont think it has to do something with the problem :/

As fuenfundachtzig said this cannot be done in this version of C++ Arduino uses. A replacement for this method is to set the number for each place.
For example:
case 48:
    //rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};
    rp[0] = 0;
    rp[1] = 1;
    rp[2] = 1;
    rp[3] = 1;
    rp[4] = 1;
    rp[5] = 1;
    rp[6] = 1;
    rp[7] = 0;
    break;

This works the same however it takes more space but i dont this there is a problem.

What you try here:
rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};

is only valid in C++11. (Before that you can initialize an array like this only upon initialization.)
Besides, as pointed out by Pete Becker, you need to declare rp as an array rather than a single int.

And what if i want to change the values of the array?

This isn't valid at all. rp[8] is an int.

Oh. And that. :)

Have you tried compiling without the "static" keyword. I think the compiler is complaining because it sees multiple statements trying to make an assignment to a static variable. Even if your logic is such that only one of the assignments will ever be executed the compiler doesn't know that.


text:
The IDE says my (brand new) Arduino UNO is on COM 1
I recently bought an Arduino Uno and installed everything necessary. I tried it on both USB ports on my computer. However, the Ports menu only shows COM1. There is a line on the bottom of the IDE which says Arduino Uno on COM1.
Any program I try fails to upload to the board. When I tried the Blink example, the following error message appeared:
Arduino: 1.6.3 (Windows 7), Board: "Arduino Uno"

Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.

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

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x43

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x43

and so on. Until,
This report would have more information with
"Show verbose output during compilation" enabled in File > Preferences.

I have a Windows 7 64 bit desktop.
Any help will be appreciated.

Can you try pressing the reset (hardware on arduino) button directly after pressing the upload button (software in IDE)? - I had this problem on a cheap Nano clone, using the wrong programmer type

It does not seem to be making any difference. Is there something else you think I ought to do?

I read in many places that the Arduino UNO is supposed to be on COM 3 or higher. How do I do that? It always says I'm on COM1. Thanks again.

Can you find the arduino in Windows - Device Manager?

@FuaZe -  No, I cannot.

Could you attach a screenshot of your device manager? There might be an issue with the drivers, might also check the error in google, that's how I fixed mine

its possible that your COM1 device has nothing to do with the arduino and is some other device on your computer, and that your arduino is not being recognized at all. The "Arduino uno on COM*" line reflects your settings, not anything the IDE has detected about the available ports.

@SR1 - which port the Arduino will be on depends entirely on the details of your system.  There is no rule.  On a system with no other serial devices, COM1 is a legitimate possibility.

@SR1 could you indicate what solved your problem, maybe add it yourself as an answer to your question

@Joram - Turns out my USB cable was faulty. While the green light still turned on, the computer did not recognize the Arduino Uno R3. I installed some of the FTDI USB drivers and used a different cable, and it worked!

Here are a few troubleshooting tips:

First check if the board is listed as Arduino Uno in the IDE by going to Tools --> Board
Check this site.
Also, try reinstalling the driver.
Check your cable.
As a last resort you can try re uploading the bootloader.


text:
Uploading/Flashing different programs to two different Arduino uCs, using one USB
I'm designing a custom dual-uC board, where I want there to be two Arduinos both running different programs - kind of dual core arduino. In order to load new programs onto the uCs, yes, I could have two USB ports each connected to one of the uCs (say a ATmega32u4). But I'm trying to work out strategies with just one USB port (and no usb-hub).
Also, I don't need the USB functionality for general use, only for program updates.
Option 1:
Switch access to each USB capable Arduino (e.g. ATmega32U). Program one uC, toggle switch, program other uC
EDIT: this is fine, however I ideally want to use zero additional end-user buttons - I want the end-user to do as little as possible.
Option 2:
The arduino UNO has two devices, ATmega16U2 and a ATmega328. During normal operation the 16U operates as a usb-to-serial. However, I'm aware that there are custom firmwares that allow different functionality (such as USB-Joystick etc) - it is possible to switch firmawares between a custom-firmware and default firmware, to allow the ATmega328 to be programmed normally but also to run the custom program. But it seems that Arduino.h doesn't support the ATmega16U2, so I would have to program this device using the AVR or another framework.
Alternatively, the ATmega32U4 is supported by Arduino.h but there doesn't seem to be Arduino usb-serial 'firmware' for the 32U (only the 8U & 16U)
Option 3:
Can I use a ATmega32u4 with Arduino-ISP programming an ATmega328p?
EDIT: above seems valid:
https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/
Other simple recommended approaches?
EDIT: the firmware update should be physically as hands off as possible, as to be used by end-user, and preference for solutions that require zero additional buttons/etc
UPDATE:
I tried the Arduino as ISP method (option 3), and it works

Since you don't need USB cable for general use, I strongly recommend 1) as it is very simple. But if you do need it after code has been uploaded, then things get complicated........

You should be able to get the ATMega16u2 to work with the IDE relatively simple. I'd suggest option 1, but I'd add some headers for an external  USB-to-Serial adapter. That way you don't require chips with usb support (cheaper). Either add two headers, one for each chip. Or add a triple pole, double throw switch (TX,RX,DTR). Or DPDT if you don't mind both chips resetting (which would actually be a nice feature).

Provided that you are okay with producing a customized PC side tool (which you would probably want anyway for user convenience) automated target selection should be far superior to manual.
You should be able to use one ATmega16u2 with a  minimally customized firmware as a front end to program two distinct ATmega328p's.  This could be as simple as selecting the target based on the baud rate, having it hold the de-selected one in reset the whole time, and using some resistors on the shared TX lines for safety.  Last I checked the stock firmware used a soft serial at some rates, and that can be put on different pins, so it could be another way to de-conflict and select targets.
Your idea of using a 32u4 both as a functional part and as a buddy-programmer for another part is perfectly valid too - you can do that programming to a serial bootloader (it should be a simple matter to port the 16u2 firmware, or find another example), or via the ISP pins.
Now that I think about it, there's been a version of this question here before, as I remember writing about an idea for using two ATmega328p's permanently wired to a stock USB-serial, but with their bootloaders customized to use unique baud rates, and a little logic added so that on reset each would leave its serial TX pin tristated if it didn't detect bootloader traffic at its individually unique baudrate, thus allowing the other to be programmed without interference.

Option 1 using three header pins and a jumper wouldn't take up much board space, is simple to implement, and easy to use. Even easier if the jumper has a handle.

You'd need two set of these. One for D+ and one for D-. I'd suggest a DPDT switch.

Header pins and jumper for what ?

Rx & Tx from the USB->Serail converter, for which two sets will be needed as @Gerben points out, to Rx & Tx of one or the other of the '328s.

this is fine, however I want this to be idiot proof


text:
SMD Voltage Regulator 662k very hot, how to repair it?
I think I made a mistake. Now, the 662k on my Arduino Uno very hot about 90°C.
I test it, it can be programmed and can run blink program normally.
There is a switch for voltage choose. Now, run in 3.3v mode get 2.8v and in 5v mode get 4.8v.
What should I do?
If 662k be replaced, can I use that Arduino normally in the future.

From the picture I guess it is a roboduino. The only voltage regulator is the 662k, it is too small compared to other voltage regulators!!! (have a look at the size and sink of the official arduino), so it is normal that the temperature is high. (arduino uno can get up to 1A and the regulator is bigger)
To reduce temperature just use the lowest input source (for instance, for arduino 5 volts, use 7 volts source, not 12 volts source). The bigger input voltage, the higher temperature in the regulator.
Solutions.

replace the 662K with another 662K one.
use a bigger voltage regulator. Since 66K space is tight (SOT-23) and no sink space I suggest to solder a TO-92 like voltage regulator. Not nice solution, but handy.

I thought you are right. Lucky they just sent me another board.


text:
Global Variable not able to be accessed in function?
I am trying to compile an Arduino program that takes analog input. However, when I declare multiple global variables, it often will not compile and because it throws an error that the variables aren't within scope of the functions within the program. I am not super familiar with Arduino IDE, but this doesn't programmatically make sense to me.
This is the program:
/*
*  By Hannah Perner-Wilson, www.plusea.at
*  Modified 3/30/2012 By Brian E Kaminski, www.AdvancerTechnologies.com
*
*  IMPORTANT!!:
*  Scroll down to set your serial port
*  Scroll down to set your thresholds
*/

import processing.serial.*;

// definition of window size
// you can change the size of the window as you like
// the thresholdGraph will be scaled to fit
// the optimal size for the thresholdGraph is 1000 x 400
int xWidth = 1200;
int yHeight = 750;

// xPos input array, using prefix
int[] xPosArr= {0,0,0,0,0,0};

//
int[] messageArr= {0,0,0,0,0,0};

// Arrays for threshholding
int[] threshMax= {0,0,0,0,0,0};
int[] threshMin= {0,0,0,0,0,0};

// variables for serial connection. portname and baudrate are user specific
Serial port1;

//Set your serial port here (look at list printed when you run the application once)
String V3 = Serial.list()[1];
String portname1 = V3;
int baudrate = 9600;

int prefix = 10001;
boolean myCatch = false;
String serialIN = "";
String serialINPUT = "";
String buffer = "";
int value = 0;

// ThresholdGraph draws grid and poti states
ThresholdGraph in;

void setup(){
  // set size and framerate
  size(xWidth, yHeight);
  frameRate(25);
  background(255);
  strokeWeight(5);
  stroke(0);
  smooth();
  strokeCap(ROUND);

  // establish serial port connection
  port1 = new Serial(this, portname1, baudrate);
  port1.bufferUntil('\n') ;
  println(Serial.list());  // print serial list

  // create DisplayItems object
  in = new ThresholdGraph();

  // THRESHOLD VALUES:
  // using the thresholdGraph you can determine the MIN and MAX values
  // of your sensors. Enter these here. They must lie between 0 and 1000.

    //MIN trashhold
    threshMin[0] = 20;   // one
    threshMin[1] = 20;   // two
    threshMin[2] = 20;   // three
    threshMin[3] = 20;   // four
    threshMin[4] = 20;   // five
    threshMin[5] = 20;   // six

    //MAX trashhold
    threshMax[0] = 600;   // one
    threshMax[1] = 600;   // two
    threshMax[2] = 600;   // three
    threshMax[3] = 600;   // four
    threshMax[4] = 600;   // five
    threshMax[5] = 600;   // six
}//end setup

// draw listens to serial port, draw
void draw(){

  // listen to serial port and trigger serial event
  while(port1.available() > 0){
        serialIN = port1.readStringUntil('\n');
        //println((int)float(serialIN));
        if(serialIN != "")
          serialEvent(serialIN);
        else
          Serial.println("found empty");
        }

  // threshold serial input
  threshHolding();

  // draw serial input
  in.update();
}//end draw()

The error that are being thrown are:
testproject.ino:100:17: error: 'threshHolding' was not declared in this scope
testproject.ino:103:3: error: 'in' was not declared in this scope
Error compiling.

Looks more like a Processing sketch. Where is the threshHolding function defined? (PS threshHolding and in are functions, not variables)

Agreed. It looks like that's a Processing sketch which was written to communicate with an Arduino. Perhaps the wrong code was added to the question?

I thought that "processing.serial" does not need to be imported in a .ino code?

Can anyone answer why that has been written ?

@Gerben , Do you know why?

Or @PeterR.Bloomfield , do you know?

@Mathsman100 It's there because this is a Processing sketch, not Arduino. import is a Java keyword which doesn't exist in C++, so it won't work in the Arduino IDE.

@PeterR.Bloomfield ,   But I thought the sketch is saved as a .ino, so it should work just like one that is written using Arduino IDE?

@Mathsman100 It's not really feasible to convert Java code to C++ automatically for microcontroller programming. The result would probably be very inefficient at best.

The @rsheeler might have done a mistake in that part.

The problem is that this is not an Arduino Sketch, but a processing file which is noted by the initial import statement that is Java based. Because the Arduino IDE is not very sophisticated, it didn't shout out obvious errors such as import type not defined or even ThresholdGraph not defined.
To use this file it is necessary to use the following IDE: https://processing.org/reference/environment/


text:
Signal noise on R/C car channel output
Doing a little project for work and trying to get the Arduino hooked to an RC car to read the throttle channel output and send that via bluetooth to a nearby laptop which will output an animation based on that speed.
Initial test worked very well and signals from my airplane Tx were solid with very little variance. Once the proof of concept worked, we went ahead and purchased a Traxxas car. I have a wire going from pin 5 to the signal wire on the Rx. With the serial monitor up and arduino powered via my usb cable, the #s jump from the 1400 (where its supposed to be) to 6000 and sometimes 11000.  Even more interesting, is when I engaged the throttle via the transmitter, values went down to 30-50...?? I removed the Rx from the car and powered it via the 5v on arduino...#s are solid.
So, it appears the battery or esc is giving a lot of interference. Do I need to use a different kind of wire? If so, what kind of wire? Or ground it somehow?

are you grounded correctly? what sort of filtering (if any) are you doing?

Yes , battery can provide some interference...

New to Arduino, so not sure what you mean by grounded correctly. I currently only have the one wire going from the board the the signal wire on the Rx. Do I need to run another wire from GND on board to GND on Rx?

Old post, but here was my solution. Had to pickup some shielded cable. Pics below should clearly explain how everything was wired up.


text:
Motion sensored speaker with display screen?
I want to create a motion sensored system, if the motion sensor detects motion it will make a speaker play a sound and a screen will record the time. This needs to be a loop that turns on for x number of hours and off for z number of hours.
Also, I need the speaker to loop through different sounds...
I'm new to this sort of programming so any help anyone can give me on how to write this code would be greatly appreciated, thanks.

The scope of this question is far too broad.  Breakdown you questions into the specific tasks.  When you have done that, try submitting questions showing what you have tried and what you need.

Good project idea...This breaks down very nicely into parts that you can build and test individually.
First, I would start with the blink example, this will be helpful when debugging the other parts and it will guarantee that you have everything setup and can program the Arduino with the IDE.
Then there's the actual pieces to get the project working.
*Play a Sound
*Display Information
*Record Time of Day
*Enable and Disable based on Elapsed Time or Time of Day
*Motion Sensing
To play a sound you have a couple of options.  The simplest would be to get a buzzer since you can control these right from an Arduino pin.  If you want to play a specific MP3 or wav file, you will need a slightly more involved setup.  Here is an example for playing a tone with a buzzer.  http://www.arduino.cc/en/tutorial/tone
For the motion sensing you probably want a PIR sensor.  You can find them everywhere (Ebay, Sparkfun, Adafruit, Amazon, etc).  You can also google Arduino PIR Example.  Here is one result. http://playground.arduino.cc/Code/PIRsense
Once you've got those two bits working you can play a tone, when motion is detected.  Next is the display.  Outputting to an LCD is pretty easy.  There's a few ways to do this.  You may want to find a tutorial for the specific LCD screen that you decide to buy.  (While you are looking, check out the OLED screens from Adafruit, they are pretty neat).  Anyway, get the screen working in code by itself, then you can connect it to the rest of your system to print something when you trigger the motion sensor and play the tone.
So, the timing...This is a little more involved.  The Arduino does not have a real time clock (RTC) so it can't tell the time.  You would have to get a separate RTC module and set the time on it.  I haven't worked with those before but...there are a few ways to interact with time.  If motion is triggered, you can check the time and if it is between the times that are valid (which you would define) then trigger the speaker, otherwise don't.
Once you can get the time from the RTC, you can display that information to the screen.
That should get you started.


text:
Arduino Ultimate GPS Logger Issue
I am new to electronics and learning how to play around with arduino. I recently purchased the Arduino ultimate GPS Logger, and despite also buying an external anntenae the GPS data shows that it does not fix at all. Despite leaving the unit powered for more than 5 minutes. Please advise on what could be wrong. Is it normal to take so long to get a GPS fix? This is the Arduino in question. https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield/overview

This style of antenna can be very finicky.  GPS on this module may take 15 or 30 minutes to lock, not just 5.  I would suggest you take this outside away from any walls or buildings and see if it will lock then.  I also suggest that you run it off a battery.  (one of those USB battery packs for charging your phone will work great).  Once you get a lock try changing one variable at a time (power supply / location) and see if you can get it to look again.
The reason this module takes longer to lock than your cellphone is that your cellphone is cheating by doing a warmstart.  The cellphone can get a semi-accurate time/date and also your regional location.  This warm start data improves GPS lock time down to 5 seconds or less sometimes.

Thanks. Is there a place where I can reference locations vis a vis GPS modules available and with high sensitivity for those locations?

If you want the best GPS signal, just go outside with a good wide view of the sky (no trees near or tall buildings)


text:
Debugging modified BlinkWithoutDelay
I have some level of programming background, however never with Arduino's. I've just started hacking at the examples - I'm not even sure what language I'm currently writing. I presume it's C++.
Anyway, I figured I'd try out the pin 13 LED with the BlinkWithoutDelay example. I've got that running fine (which I was very excited about), however I've tried to modify it to blink out SOS in Morse code, but it doesn't appear to be working.
// constants won't change. Used here to set a pin number :
const int ledPin =  13;      // the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
//unsigned long interval = 1000;           // interval at which to blink (milliseconds)

// Number of times to blink
const long blinkMax = 10;
// Counter for number of times blinked
unsigned long blinkCount = 0;

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  int loopCount = 0;
  // S O S
  int values[] = {1000, 1000, 1000, 200, 200, 200, 1000, 1000, 100};
  blink(values[loopCount]);
  loopCount = loopCount + 1;
}

void blink(int interval)
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    digitalWrite(ledPin, ledState);
  }
}

As you can see, I've assigned the time values (1000 for long and 200 for short) to an array and had the loop function call my blink function each time. Every time it loops, it increments and goes to the next value.
I know it's able to pull values from the array fine, as I've tried manually modifying loopCount just before the blink() and it blinks at the specified timeout. I presume the loopCount increment is fine (I also did loopCount++; - no luck).
If someone could point me in the right direction, this would be great. Thanks!

Since it's blink without delay, the next loop will happen immediately. Not after the blink function is don't. So loopCount will increment continuously. You don't limit loopCount to 9, so it will after a few milliseconds try to access, e.g. values[12] which doesn't exist. (see @jfpoilpret's comment)
// constants won't change. Used here to set a pin number :
const int ledPin =  13;      // the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated
int blinkValues[] = {1000, 1000, 1000, 200, 200, 200, 1000, 1000, 100};
int loopCount = 0;

// constants won't change :
//unsigned long interval = 1000;           // interval at which to blink (milliseconds)

// Number of times to blink
const long blinkMax = 10;
// Counter for number of times blinked
unsigned long blinkCount = 0;

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  blink();
}

void blink()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= blinkValues[loopCount]) {
    previousMillis = currentMillis;
    loopCount = (loopCount + 1) % 9;
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    digitalWrite(ledPin, ledState);
  }
}

Also note that the blink function will toggle the led, after the interval. So you need to add intervals, for how long the led should be off between flashes. But I leave that for you to figure out.

Your comment about loopCount is incorrect: it will never increment as it is a simple local variable inside loop().

You're right. I missed that one.


text:
16 bit register addressing through i2c
Note: I'm using just the atmega chip and atmel studio. Not exactly a full arduino.
I have been using the atmega168 with a MAX17040 fuel gauge in a project. The I2C interface between the atmel and the fuel gauge is working fine and I am able to read data from the fuel gauge.
Due to the power requirement of the project, the fuel gauge requires its compensation value to be adjusted. This is a 16 bit register, so according to the manufacturer I have to write 0x1234 across address 0x0C and 0X0D in one go. Otherwise the values are discarded.
All the datasheet and online forums talk about 8-bit I2C addressing (which I have working), but instruction on addressing 16 bit register is limited. I was wondering if anyone can help me on this.
My basic code is pasted below. The I2C_start takes care of TWCR, TWDR, etc. It could be something to do with Repated_Start, but not sure.
uint8_t I2C_write_register(uint8_t device, uint8_t address, uint8_t value)
{
    device <<= 1;

    uint8_t ret = I2C_start(device | TW_WRITE);
    if (ret)
        return 1;

    if (!ret)
        ret = I2C_write(address);
    if (!ret)
        ret = I2C_write(value);
    I2C_stop();

    return ret;
}

uint8_t I2C_start(uint8_t address){
    // reset TWI control register
    TWCR = 0;
    // transmit START condition
    TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
    // wait for end of transmission
    while( !(TWCR & _BV(TWINT)) );

    // check if the start condition was successfully transmitted
    if((TWSR & 0xF8) != TW_START){ return 1; }

    // load slave address into data register
    TWDR = address;
    // start transmission of address
    TWCR = _BV(TWINT) | _BV(TWEN)|_BV(TWEA); //|_BV(TWEA) added
    // wait for end of transmission
    while( !(TWCR & _BV(TWINT)) );

    // check if the device has acknowledged the READ / WRITE mode
    uint8_t twst = TW_STATUS & 0xF8;
    if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;

    return 0;
}

How does Wire not handle this already?

I should add, i'm not using a full arduino, just  the atmega168 chip. And i'm using twi.h library from atmel studio.

So... then I don't understand why you asked this here.

Arduino and the atmega168 are essentially the same core. If the arduino can address 16-bit word over I2C, the atmega can do it too.

But why ask in the community where they use Wire, when your needs would be better served by a wider audience?

@IgnacioVazquez-Abrams you don't have to use Wire on Arduino, since as tsf144 pointed out, they are both using pretty much the same core. There doesn't happen to be a stack exchange site dedicated to AVR or even just microcontrollers, so this is probably not a bad place to ask.

Ahh, was just able to solve it. Essentially, do not use TW_REPEATED_START. Just keep sending data 8 bit at a time. 1 bit at the beginning of each 8 bit will be lost, so make sure you shift them first.
Wire library uses a very similar concept for use with arduino.
uint8_t I2C_write_register(uint8_t device, uint8_t address, uint8_t value, uint8_t value)
{
    device <<= 1;

    uint8_t ret = I2C_start(device | TW_WRITE);
    if (ret)
        return 1;

    if (!ret)
        ret = I2C_write(address);
    if (!ret)
        ret = I2C_write(value);
    if (!ret)
        ret = I2C_write(value2);
    I2C_stop();

    return ret;
}


text:
Exceed AREF voltage
Let's say that I use a 5V Arduino board, and I set AREF to 3V, thus 0-3V equals to 0-1023 of the analog inputs.
If I exceed the AREF voltage, powering an analog pin with 4V, could that damage the analog input pin? If not, what would be the reading?
Thank you.

The reading would saturate at 1023 when the voltage on the input pin exceeds AREF.
The datasheet (for the ATmega328P) states as absolute maximum rating for the "Voltage on any Pin except -RESET with respect to Ground" VCC + 0.5 V. So applying 4 V to AREF for a 5 V Arduino board should not (necessarily) damage the ATmega. (But you also won't be able to extend the 10-bit resolution range, if that is what you're after...)
In short, choose the reference voltage above the maximum expected voltage.

... should not (necessarily) damage the ATmega. Could you clarify the "necessarily" statement?

Yes: I don't think it would do damage, but I won't give you a guarantee :) When you apply 4 V you are well inside the absolute maximum rating (which would be 5.5 V) but also quite a bit above the max value given under ADC Characteristics (which is VREF, i.e. 3 V).


text:
Arduino Watchdog Timer
I want to work with interrupts and heard that the watchdog timer is effective way to deal with them.  I haven't been able to find a good tutorial on them though and was wondering if someone could head me in the right direction or give me a couple tips and an example.

Which part of the datasheet are you having trouble with?

Watchdogtimer is NOT a recommended way of dealing with interrupts. It is dedicated to restarting the system on timeout. Most or all other timers are able to do this much more flexibly.

Look at the TimerOne library.

For the Uno, you can set an interrupt on digital pins 2 and 3.  Check out http://www.arduino.cc/en/Reference/attachInterrupt for more details.
Here is the example code from that page:
int pin = 13;
volatile int state = LOW;

void setup()
{
  pinMode(pin, OUTPUT);
  attachInterrupt(0, blink, CHANGE);
}

void loop()
{
  digitalWrite(pin, state);
}

void blink()
{
  state = !state;
}

In this case, blink() will be called anytime pin 0 changes state.  If you only want the rising or falling edge, change the call to attachInterrupt to say RISING or FALLING instead of CHANGE.

I know that but I don't understand how to integrate the code and the offical site is not helping me.

There is an example on that page -- if you take the blink function and replace it with your code, it will be called anytime pin 0 changes state.  You can also change the interrupt to only be called on the rising or falling edge as well in the attachInterrupt call.  I'll add the example to my answer as well.

Since you talk about the watchdog I presume you want timer interrupts. (There are also I/O interrupts, for instance when the level of a pin changes state.)
Like Russell McMahon says the watchdog is not a good source. The ATmega has several timers (8-bit and 16-bit) which serve your exact purpose. Let's view some example code:
// timer interrupts
// adapted from code by Amanda Ghassaei
// June 2012
// http://www.instructables.com/id/Arduino-Timer-Interrupts/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
*/

// timer setup for timer0, timer1, and timer2.
// For arduino uno or any board with ATMEL 328/168.. diecimila,
// duemilanove, lilypad, nano, mini...

// this code will enable all three arduino timer interrupts.
// timer0 will interrupt at 2kHz
// timer1 will interrupt at 1Hz
// timer2 will interrupt at 10kHz

// storage variables
boolean toggle0 = 0;
boolean toggle1 = 0;
boolean toggle2 = 0;

void setup() {

  // set pins as outputs
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(13, OUTPUT);

  cli(); // stop interrupts

  // set timer0 interrupt at 2kHz
  TCCR0A = 0; // set entire TCCR2A register to 0
  TCCR0B = 0; // same for TCCR2B
  TCNT0  = 0; // initialize counter value to 0
  // set compare match register for 2khz increments
  OCR0A = 124; // = (16*10^6) / (2000*64) - 1 (must be <256)
  // turn on CTC mode
  TCCR0A |= (1 << WGM01);
  // Set CS01 and CS00 bits for 64 prescaler
  TCCR0B |= (1 << CS01) | (1 << CS00);
  // enable timer compare interrupt
  TIMSK0 |= (1 << OCIE0A);

  // set timer1 interrupt at 1Hz
  TCCR1A = 0; // set entire TCCR1A register to 0
  TCCR1B = 0; // same for TCCR1B
  TCNT1  = 0; // initialize counter value to 0
  // set compare match register for 1hz increments
  OCR1A = 15624; // = (16*10^6) / (1*1024) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS12 and CS10 bits for 1024 prescaler
  TCCR1B |= (1 << CS12) | (1 << CS10);
  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);

  // set timer2 interrupt at 10kHz
  TCCR2A = 0; // set entire TCCR2A register to 0
  TCCR2B = 0; // same for TCCR2B
  TCNT2  = 0; // initialize counter value to 0
  // set compare match register for 8khz increments
  OCR2A = 199;// = (16*10^6) / (10000*8) - 1 (must be <256)
  // turn on CTC mode
  TCCR2A |= (1 << WGM21);
  // Set CS21 bit for 8 prescaler
  TCCR2B |= (1 << CS21);
  // enable timer compare interrupt
  TIMSK2 |= (1 << OCIE2A);

  sei(); // enable interrupts

} // end setup

ISR(TIMER0_COMPA_vect){ // timer0 interrupt 2kHz toggles pin 8
  // generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles
  // for full wave- toggle high then toggle low)
  toggle0 = HIGH - toggle0;
  digitalWrite(8, toggle0);
}

ISR(TIMER1_COMPA_vect) { // timer1 interrupt 1Hz toggles pin 13 (LED)
  // generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles
  // for full wave- toggle high then toggle low)
  toggle1 = HIGH - toggle1;
  digitalWrite(13, toggle1);
}

ISR(TIMER2_COMPA_vect) { // timer1 interrupt 10kHz toggles pin 9
  // generates pulse wave of frequency 10kHz/2 = 5kHz (takes two cycles
  // for full wave- toggle high then toggle low)
  toggle2 = HIGH - toggle2;
  digitalWrite(9, toggle2);
}

void loop() {
  // do other things here
}

This sets up 3 different timers: one at 500 µs, one at 1 s, one at 100 µs. For the details about each timer, look up the registers in the datasheet.
With each timer goes a timer interrupt service routine (ISR). These perform the action required when an interrupt occurs. It's a good practice to exit an ISR as quickly as possible. Only do the things which are really time-critical, but for the rest set a flag to indicate that the interrupt occurred. Then in the main loop you continuously check that flag, and when it is set, perform the necessary actions. Don't forget to clear the flag when you're done.

I appreciate the code here but I want to do hardware interrupts. I wasn't able to make it clear because I didn't know but I want to make the robot stop when it senses the edge of a table. Therefore I believe that would be a hardware intterupt with a rising edge or something.

@EinsteinJr.: then could you please remove reference to the watchdog timer in your question? It's misleading to say the least.


text:
cc3000 WiFi distrupting DS18b20 temp measurements
I am trying to post temperature measurements from DS18b20 thermal sensors to an online repository using a cc3000 WiFi shield on an Arduino Mega.  It works great, once.  All the temperatures get read fine. Then I post the data. Then the temperatures all return -127 error values.
If I fix the temperatures to const values, I can send any amount of data over wifi. If I don't send the data over wifi, I can pull temperatures indefinitely.
I can't imagine anyone is set up to test this or has a good way to debug it, so I am open to wild speculation- Any guesses what is going wrong? Any suggestions on how to debug it?
Here is my code:
#include <OneWire.h>
#include <DallasTemperature.h>

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>

#define temppin 53

#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5  // any pin
#define ADAFRUIT_CC3000_CS    10  // any pin
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                     SPI_CLOCK_DIVIDER); // you can change this clock speed but DI

#define WLAN_SSID       "MyNetwork"        // cannot be longer than 32 characters!
#define WLAN_PASS       "mypassword"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
uint32_t dweetioIp = 0;
char c;
unsigned long lastpost = 15000L;

OneWire oneWire(temppin);
DallasTemperature sensors(&oneWire);  // Pass our oneWire reference to Dallas Temperature.

DeviceAddress TS1 = {0x28, 0xFF, 0xB4, 0x5E, 0x68, 0x14, 0x03, 0x60};  // serial numbers
DeviceAddress TS2 = {0x28, 0xFF, 0xFE, 0x4F, 0x68, 0x14, 0x02, 0xDD};  // for DS18b20's
DeviceAddress TS3 = {0x28, 0xFF, 0x3D, 0x5C, 0x68, 0x14, 0x03, 0x5F};
DeviceAddress TS4 = {0x28, 0xFF, 0x16, 0x5C, 0x68, 0x14, 0x03, 0xD7};
DeviceAddress TS5 = {0x28, 0xFF, 0xA3, 0x62, 0x51, 0x14, 0x04, 0xC4};
DeviceAddress TS6 = {0x28, 0xFF, 0xA9, 0x61, 0x68, 0x14, 0x03, 0x22};
DeviceAddress TS7 = {0x28, 0xFF, 0x2A, 0x72, 0x68, 0x14, 0x03, 0x17};
DeviceAddress TS8 = {0x28, 0xFF, 0xD2, 0x61, 0x68, 0x14, 0x03, 0x3F};
DeviceAddress TS9 = {0x28, 0xFF, 0xFA, 0x43, 0x68, 0x14, 0x02, 0xD0};
DeviceAddress TS10 = {0x28, 0xFF, 0x0B, 0x63, 0x68, 0x14, 0x02, 0xCB};
DeviceAddress TS11 = {0x28, 0xFF, 0x97, 0x41, 0x68, 0x14, 0x02, 0x2A};
DeviceAddress TS12 = {0x28, 0xFF, 0x47, 0x7E, 0x68, 0x14, 0x03, 0xF8};

DeviceAddress TS16 = {0x28, 0xC8, 0x47, 0x15, 0x06, 0x00, 0x00, 0xF0};

float t1;
float t2;
float t3;
float t4;
float t5;
float t6;
float t7;
float t8;
float t9;
float t10;
float t11;
float t12;
float t13;

String command = "";
boolean stringComplete = false;

void setup() {
  Serial.begin(115200);
  sensors.begin();

  pinMode(temppin, INPUT);

  // Initialize wifi shield
  if (!cc3000.begin()) {
    Serial.println(F("\n\nFailed to initialize WiFi shield."));
  }
  Serial.println(F("\n\nInitialized WiFi shield"));

  // Connect to wifi network
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed to connect to WiFi network"));
  }
  Serial.print(F("Connected to "));
  Serial.println(F(WLAN_SSID));

  // Wait for DHCP to complete (get an IP address)
  while (!cc3000.checkDHCP()) {
    delay(1000);
    Serial.println(F("Waiting to get IP address"));
  }
  Serial.println(F("Got an IP address\n"));

  // Connect to dweet.io
  while (dweetioIp == 0) {
    if (! cc3000.getHostByName("dweet.io", &dweetioIp)) {
      Serial.println(F("Failed to resolve dweetio website"));
    }
    delay(500);
    Serial.println(F("Resolving dweetio website"));
  }
  Serial.print("Accessed dweetio website at IP address: ");
  cc3000.printIPdotsRev(dweetioIp);
  Serial.println();
}

void loop() {
  // Get temperatures
  sensors.requestTemperatures();
  delay(1000);
  t1 = sensors.getTempC(TS1);
  t2 = sensors.getTempC(TS2);
  t3 = sensors.getTempC(TS3);
  t4 = sensors.getTempC(TS4);
  t5 = sensors.getTempC(TS5);
  t6 = sensors.getTempC(TS6);
  t7 = sensors.getTempC(TS7);
  t8 = sensors.getTempC(TS8);
  t9 = sensors.getTempC(TS9);
  t10 = sensors.getTempC(TS10);
  t11 = sensors.getTempC(TS11);
  t12 = sensors.getTempC(TS12);
  t13 = sensors.getTempC(TS16);

  Serial.println(t1);
  Serial.println(t2);
  Serial.println(t3);
  Serial.println(t4);
  Serial.println(t5);
  Serial.println(t6);
  Serial.println(t7);
  Serial.println(t8);
  Serial.println(t9);
  Serial.println(t10);
  Serial.println(t11);
  Serial.println(t12);
  Serial.println(t13);

  long curmillis = millis();
  if (curmillis - lastpost > 1000*15L) {
    // Post data to dweetio
    char data[125];
    sprintf(data, "?t1=%i&t2=%i&t3=%i&t4=%i&t5=%i&t6=%i&t7=%i&t8=%i&t9=%i&t10=%i&t11=%i&t12=%i&t13=%i",
            (int)(t1*10.),(int)(t2*10.),(int)(t3*10.),(int)(t4*10.),(int)(t5*10.),
            (int)(t6*10.),(int)(t7*10.),(int)(t8*10.),(int)(t9*10.),(int)(t10*10.),
            (int)(t11*10.),(int)(t12*10.),(int)(t13*10.));
    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);
    if (client.connected()) {
      client.fastrprint(F("GET "));
      client.fastrprint(F("/dweet/for/testdweets"));
      client.fastrprint(data);
      client.fastrprint(F(" HTTP/1.1\r\n"));
      client.fastrprint(F("Host: https://www.dweet.io\r\n"));
      client.fastrprint(F("\r\n\r\n"));
      // client.println();
      Serial.println(F("Sent dweet\n"));
    } else {
      Serial.println(F("Sending dweet failed"));
      return;
    }

    /* Read data until either the connection is closed, or the idle timeout is reached. */
    unsigned long lastRead = millis();
    while (client.connected() && (millis() - lastRead < 1000)) {
      while (client.available()) {
        char c = client.read();
        Serial.print(c);
        lastRead = millis();
      }
    }

    client.close();
    Serial.println("Connection to dweet.io closed");

    lastpost = millis();
  }
}


text:
Problem programming Mini Pro via Arduino as ISP
I just picked up a pair of Arduino Mini Pro 5v clone boards (Inland, sold at Microcenter, currently $4 USD) and I wanted to use my Uno as an ISP like I've done with ATmega328 and ATtiny85 chips before.  I've programmed the Uno with the instructions at the ArduinoISP tutorial page and I've connected up the Uno to the Mini Pro using the instructions at this page.  I cannot get the Arduino IDE or avrdude from the command line to successfully program these boards no matter what I try.  Except that I can use the Arduino IDE to burn a new bootloader to the Mini Pro.
I've connected up the status LEDs as well (pins 7, 8 and 9), and I can see that the programmer has an error condition (pin 8) when I attempt to program anything besides the bootloader.
Here is my avrdude command line where I tried to set the fuses on the Mini Pro:
avrdude -P /dev/tty.usbmodema0121 -b 57600 -c avrisp -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xdb:m -U efuse:w:0xfd:m

I get the following back from avrdude:
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c

avrdude done.  Thank you.

I've not had any problems with using pretty much this exact same setup, but with a ATmega328 or ATtiny85 chip on a breadboard with avrdude in the past, so I'm at a loss as to what is happening here.
I've also taken a look at the ArduinoISP code, and I'm not really sure what the resp=0x1c is.  I don't see a 0x1c value defined in the STK Definitions section of the code, so I'm not sure what might be causing this.
Any pointers here would be appreciated. And yes, I do know that I can use the Uno board with the ATmega328 chip pulled to use as a programmer as well.  But I want to be able to overwrite the bootloader area with my own code like I can with a regular ATmega328 chip.
Thanks!

After poking around for a bit more, it turns out my problem was the baud rate.  I could make it work by setting it to 19200, just a little slower.  Alternatively, you can modify the ArduinoISP sketch to enable higher baud rates.  I used this post to enable 115200 baud and I was able to successfully use avrdude at the higher rates.
Not sure how I missed this before, but it's an easy to solve at least.


text:
Mechanical requirements for Arduino compatibility
If I want to design an Arduino-compatible board I guess I'll have to use the same outline, and connector positions to fit existing enclosures. (Beats me why they didn't choose a simple rectangular board, which would have been cheaper.) But I wonder if the ICSP header's position is standardized. Some enclosures have a hole above it, but many don't. Can I move the ICSP header to another position?

(Can somebody add a "compatibility" tag? Thanks. Also, neither "mechanical" nor "board" nor "layout" seem to exist as tags. Feel free to improve my generic tagging.)
The "shield" tag was suggested, but this isn't about shields, it's about the ICSP header.

Ah, I misread the question, I seem unable to remove my "shields" tag.

You can move the ICSP header.
Your board will be compatible with everything that does not use the ICSP header.
The casing will still "work", but you would be unable to reach the ICSP header if the casing is on it.

Look at the Uno board and the Mega board for example. Both seem to have the ISP header at the same position. Some shields require it. The only reason for a fixed location would be shield, so that tag is pretty applicable. Also note that if you move it, it might interfere with components placed on the bottom of some shield.

@Gerben: I find your "seem" interesting :-). Does a hard source for it exist? Not to my knowledge. Is there a drawing with the required clearances for the bottom of shields? I seriously doubt it.

Depends on what you define as "Arduino compatible".
My "Arduino Nano" is 'Compatible' but a whole other design.
Or well, it already separates here.
"Software compatible" working with the Arduino IDE and/or Libraries. In general, any board with ATMega 328P / USB or ICSP / Bootloader could be considered compatible.
But, however, for an "Arduino clone" being "Hardware compatible" you could also look at:

Pin placement (Thus being compatible with shields).
Using the same FTDI chip, thus being directly compatible with arduino
drivers (not sure)
Using "exactly" same electronic specifications.
Size and/or shape or even weight of the board.

Strictly, moving the ICSP header will make it 'incompatible' for some shields.
But, well, for most shields it won't be a problem. For casings that have an opening for the ICSP header it'll mostly just look funny.
By replacing the ICSP header it might touch components of other shields/casings and thus be not compatible with it.

(update)
The website and file below are from the arduino site and could thus be considered to be the 'standard' as it's set by arduino. You can however make your board how you want it and compatible with what you want. But changes will often make it incompatible with (some) shields/adapters.
The arduino website with specifications on the board:
http://www.arduino.cc/en/Main/ArduinoBoardUno
EAGLE files:
http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip

There are several areas of compatibility. I mention mechanical in particular. I know there are different board designs, like the Nano, which are software compatible, but it should be obvious that I'm not asking about mechanical compatibility between Nano and Uno, for instance. The question is: does there exist an official drawing with PCB outline and the positions of mounting holes and connectors/headers? I couldn't find it.

Hmm, not that I know off, though arduino is open source and they do have design documentation on their website https://www.google.nl/url?sa=t&source=web&rct=j&ei=8HM-VbjmE5blao3OgcgI&url=http://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&ved=0CEIQFjAI&usg=AFQjCNGzCio-NUQNITccf4-akL0T_cyi1Q&sig2=OlSWYdqsNnjl8Axk0vD5rQ

Yes, that's an (outdated) schematic, thanks. But have you ever seen an official mechanical drawing?

I have searched on my laptop (which is easier as on my phone) and found the following: http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip , These are the eagle SCHEMATIC and BOARD files. Found on this page: http://www.arduino.cc/en/Main/ArduinoBoardUno
I believe this would be the standard set by arduino, it's from Rev 3 so I think it's quite up to date?

A board file is (probably) a PCB layout. I can't read that because I don't have Eagle. That's not a mechanical documentation file (which preferably should be a PDF). I appreciate that you want to find an answer, but I still don't think it exists. I've also Googled the Internetverse for a long time for it. I found drawings which are the initiative of individuals to fill in the gap in documentation, but those drawings either are incomplete, wrong or contradicting.

I agree, Arduino is made for hobbyists and this does also only have basic documentation in this field. Not to much technical info. You should consider downloading eagle, it's free (I believe) and you can use measurement tools in eagle to get the exact placing/dimensions.

If you get good at it you'll be able to create custom pcb's for specific projects. Like an RFID reader with wireless connection, as 'small' as an arduino. Your arduino copy should basically be as much te same. Unless you have beter ideas, like using a beter chip and double the rows of pins or something!

"you can use measurement tools in eagle to get the exact placing/dimensions." I'm not a mechanical engineer, but I've worked enough with them to know that measuring on a drawing is a cardinal sin. Never measure on a mechanical drawing. All measurements should be there. If some measurements are missing, send the drawing back to the engineer who made it. But again, a PCB layout is not a mechanical drawing. If you want to know what I mean by good mechanical drawing, take a look at the drawings near the end of any electronic component's datasheet.

I actually agree on that. Though I haven't seen an mechanical drawing from arduino yet. You might want to request it at their forums?


text:
GSM shield for Arduino Due
Is there any good quality GSM shield compatible with Arduino Due?
I have searched for gsm shield but it seems all shields have operation voltage 5v.
Any suggestion would be helpful.

Most GSM modules have native I/O at 3.3v or even lower (2.8v is common), so you would be looking for one that either didn't have level shifters, or had level shifters to a configurable voltage.