body:
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

title: nRF24L01+ RF24 library - can send but can't receive

Answers: 3

body:
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 :)

body:
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.

body:
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.


body:
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.<init>(Serial.java:191)  at processing.app.Serial.<init>(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.

title: ttyACM0 no such file or directory On Ubunutu 14.04

Answers: 1

body:
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.


body:
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)?

title: Lithium Polymer/LiPo set to power Arduinos

Answers: 3

body:
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.

body:
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.

body:
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.


body:
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).

title: What are the different types of high-speed serial data transfer protocols, and how do they work (ex: baudrate, synchronous vs asynchronous, etc)?

Answers: 3

body:
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²C

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

body:
Different serial communications protocols use different [signal modulation methods][1] 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.

  [1]: http://en.wikipedia.org/wiki/Modulation#Digital_modulation_methods

body:
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**][1], 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][2]), 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][3]).

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:

1. ##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.

2. ##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][4]).

3. ##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][3]. 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.

4. ##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)

5. ##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][5] 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.

  [1]: https://www.arduino.cc/en/ArduinoCertified/IntelGalileo
  [2]: http://www.orangepi.org/
  [3]: https://arduino.stackexchange.com/questions/296/how-high-of-a-baud-rate-can-i-go-without-errors
  [4]: http://feilipu.me/2013/08/03/wiznet-w5200-arduino-shield/
  [5]: https://en.wikipedia.org/wiki/Bit_banging


body:
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?

title: Simple question about the SPI clock for Intel Edison

Answers: 0


body: 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](https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno) (As this guy has done exactly what I want). As the author of this [repository](https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno) 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.

title: How to use code for OV7670 on Arduino Uno

Answers: 3

body:
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.

body:
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

body:
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][1]

  [1]: http://privateblog.info/arduino-uno-i-kamera-ov7670-primer-ispolzovaniya/


body:
In this [Question](https://arduino.stackexchange.com/questions/4436/send-processing-color-data-into-arduino) how does the code `Processing` work?
Which programming language is it written in? How to run it?

title: Communicating with Arduino

Answers: 1

body:
"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!


body:
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)

title: Can't communicate with arduino using python (Windows)

Answers: 5

body:
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.

body: 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.

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

body: 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.

body:
you must use this code

    >>> import serial
    >>> ser.close()             # close port


body:
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?

title: Why Firmata Test doesn't allow me to choose a port?

Answers: 2

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

body:
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


body:
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"

title: error C1083: Cannot open include file: 'Ethernet.h':

Answers: 0


body:
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?**

title: Arduino Yun not showing up in Windows or Linux [software issue?]

Answers: 0


body:
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][1], 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][2], 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.

  [1]: http://forum.arduino.cc/index.php?topic=120693.0
  [2]: http://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf

title: What is the physical location of the U1A symbol on Arduino Uno?

Answers: 1

body:
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.

![enter image description here][1]

  [1]: https://i.stack.imgur.com/bANvw.jpg


body:
What is the difference between print( ) and println( )?<br>
I see none when I run a code.

title: Difference between print() and println()

Answers: 4

body:
print() prints whatever you send in.<br>
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.

body:
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

body:
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
    _

body:
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


body:
Is there any way to make sounds using an Arduino without using the tone function?<br>
It must be possible via this new method to control frequency of sound.

title: Alternative to Tone( )

Answers: 2

body:
I've used [a somewhat more complex method][1] 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.

  [1]: http://playground.arduino.cc/Code/PCMAudio

body:
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.


body:
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
         }
        }
    }

title: Porting Arduino code to AVR/C++ input not working?

Answers: 1

body:
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);
         }
        }
    }


body: 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?

title: Best Header for Arduino Nano

Answers: 3

body:
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][1] 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.

  [1]: http://www.digikey.ca/product-detail/en/SSA-132-S-G/SAM1121-32-ND/1105752

body: 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.

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


body:
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 :/**

title: Arduino error in code

Answers: 3

body:
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`.

body:
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.

body: 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.


body:
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.

title: The IDE says my (brand new) Arduino UNO is on COM 1

Answers: 1

body:
Here are a few troubleshooting tips:

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

  [1]: http://redhotengineer.blogspot.com/2014/11/my-fight-with-avrdude-stk500getsync-not.html


body:
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

title: Uploading/Flashing different programs to two different Arduino uCs, using one USB

Answers: 2

body:
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.

![Pins & jumper][1] ![enter image description here][2]

  [1]: https://i.stack.imgur.com/0ZaOg.png
  [2]: https://i.stack.imgur.com/YxwtF.png

body:
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.


body:
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.

![enter image description here][1]

  [1]: https://i.stack.imgur.com/zOAUA.jpg

title: SMD Voltage Regulator 662k very hot, how to repair it?

Answers: 1

body:
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.


body:
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.

title: Global Variable not able to be accessed in function?

Answers: 1

body:
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/


body:
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?

title: Signal noise on R/C car channel output

Answers: 1

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

[![Wiring into Arduino][1]][1]

[![Wiring into reciever][2]][2]

  [1]: https://i.stack.imgur.com/QvScY.jpg
  [2]: https://i.stack.imgur.com/BqEx9.jpg


body:
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.

title: Motion sensored speaker with display screen?

Answers: 1

body:
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.


body: 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

title: Arduino Ultimate GPS Logger Issue

Answers: 1

body:
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.


body:
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!

title: Debugging modified BlinkWithoutDelay

Answers: 1

body:
<strike>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.</strike> (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.


body:
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;
    }

title: 16 bit register addressing through i2c

Answers: 1

body:
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;
    }


body:
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.

title: Exceed AREF voltage

Answers: 1

body:
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.


body: 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.

title: Arduino Watchdog Timer

Answers: 2

body:
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.

body:
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.


body:
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();
      }
    }

title: cc3000 WiFi distrupting DS18b20 temp measurements

Answers: 0


body:
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][1] and I've connected up the Uno to the Mini Pro using the instructions at [this page][2].  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!

  [1]: http://www.arduino.cc/en/Tutorial/ArduinoISP
  [2]: http://www.arduino.cc/en/Hacking/MiniBootloader

title: Problem programming Mini Pro via Arduino as ISP

Answers: 1

body:
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][1] 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.

  [1]: http://forum.arduino.cc/index.php?topic=48784.5


body:
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?

<br />

----
(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.

title: Mechanical requirements for Arduino compatibility

Answers: 1

body:
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


body:
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.

title: GSM shield for Arduino Due

Answers: 0


body:
I have build a simple voltage divider with a light resistor and a 5.6k resistor. I am reading the input on A0 on my arduino board but it is almost always at 1023, independent of light. If I cover it it might go down to 1020 but not more than that.

Do I have to use a greater resistor than 5.6k to achieve more difference in the sensor?

The light sensor is similar to this: http://www.ebay.com/itm/20x-5549CDS-Photo-Light-Dependent-Sensitive-Resistor-Photoresistor-LDR-Photocell-/281425650814?pt=LH_DefaultDomain_0&hash=item418646a47e

I think that the resistance is pending between 1k-10k.

The circuit is like this image:

 ![Voltage divider][1]

  [1]: https://i.stack.imgur.com/AXZiT.png

Where Vin is 5V from the arduino. R1 is the light sensor, R2 is 5.6k and Vout is connected to A0.

title: Light sensor always getting max value

Answers: 2

body:
What have you selected as the analog reference? And if 'external', what is connected to the Vref pin?

For the LDR resistances of 10K and 1K, you  Vout should be ~ 1.8v at 10K, and ~ 4.2v at 1K, and giving A/D readings of somewhere around 370 counts and 860 counts, respectively, *with a 5v analog reference*.

If your analog reference selected to the 1.1v internal reference, either LDR resistance should give you the max reading, but an LDR = 20K could give just over a volt and pretty close to the reading you're getting.

body:
Judging by a datasheet (that I found on the web) that has a resistance of:

* 100 k to 200 k in the light
* 1 M in the dark

Given that Vout =  Vin * R2 / (R1 + R2) we can work out:

Light:

    Vout = 5 * 200000 / (200000 + 5600) = 4.86 V

Dark:

    Vout = 5 * 1000000 / (1000000 + 5600) = 4.97 V

> Do I have to use a greater resistor than 5.6k to achieve more difference in the sensor?

Yes, I would measure the resistance in the light, and choose a similar resistor for the other side of the voltage divider. So if you measure 100 k on the sensor, another 100 k will at least divide the voltage in two nicely.


body:
The error shown is

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

![Error snapshot][1]

  [1]: https://i.stack.imgur.com/uydI1.png

Why is this happening?

The code is:

    #include <IRremote.h>

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

    IRrecv irrecv(RECV_PIN);

    decode_results results;

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

    }

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

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

      }

      delay(20);
    }

title: Error in Compiling

Answers: 2

body:
As the error message says you have multiple definitions of __vector_7 which is defined in: IRemote.cpp:361 and Tone.cpp:536

Tone.cpp is arduino standart lib. If IRemote is a lib of yours then you should edit the cpp file and change the symbol to sth else.

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

 - You could. I don't think it's the best solution, but go to Tone.cpp and comment the `ISR(TIMER5_COMPA_vect) {` like `/*ISR(TIMER5_COMPA_vect)*/void XunusedX(void) {`. And be sure to never use any function from <Tone.h>...

 - You could also try to find a way on how not to invoke Tone.h with core.a. `include <Tone.h>` could be replaced with `//include <Tone.h>`

 - You could use another timer in `IRRemote.h`


body:
I have a few potentiometers connected to analog inputs in an Arduino UNO. These are then processed and then the servo motors start moving to move the bot.
I would like to keep the motors with the uno and send signals from the pots to the uno. I do not want to use a laptop or another arduino as the remote control. However.. XBEE and other related stuff will do... Thanks

Edit- The wireless solution has to cover a long range preferrably 1 mile.(I dont think I will get any that will cover a mile but I'll give it a try.)

Edit 2- I have 8 servos and 4 potentiometer. I don't necessarily need an xbee. However it may be used.

title: How to control Arduino robot wirelessly?

Answers: 3

body:
A 13 year old programming an embedded device? Good luck to you, if you conquer it you will be years ahead of your age group.

What you need to understand are the fundamentals; how can you transmit a 'pot' over an XBee? That is an electronics question, start there. You will find that another arduino or laptop is probably required. The XBee itself requires some sort of host adapter, and it might as well be another Arduino since something has to electronically read the 'pots'.

Then you need to develop your own protocol for signals sent between the 2 Arduino (over XBee or on a serial wire , it is the same).  There are many already out there, but they assume you know the basics before you use them (eg firmata). This is the basics.

The fact that your google results showed nothing similar is probably a good indication it can not be done as you had hoped.

update: I like @gerben comment, but even as an advanced person, I would find it challenging.

body:
You need to find a way to do this without having individual wireless communication from each pot. There are boards that can communicate wirelessly that are small, however, most of these are around the size of a quarter developed by an electrical engineer. This presents two problems, first the wireless modules will be too big, second, you will need to do a lot of work before you have the experience necessary  to build something like this. I recommend changing a design decision.

Thus, in order to help you further we will need to know more information about your setup.

body:
You can use so many methods to achieve it,as you are a newbie.i would prefer bluetooth and an android app.use bluetooth hc-05 module and use an android app to control.use this app and send string and control arduino.
https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO&hl=en


body:
I am trying to program a digital resistor and set it's wiper resistance. The general circuit looks a little like this where "pot" represents the [Maxim DS1801 digital resistor][1] and DUE is, of-course the 3.3v Arduino DUE.

    POT       DUE
    CLk ----> SCK
    D    ----> MOSI
    RST ----> CS (ChipSelect) (PIN10)

Now so far, I have sucessfully been able to interface with the DS1801, but I am having issues determining how to properly set the wiper resistance values. The DS1801 datasheet says the it accepts a 16bit input and from application example online it looks like the values range from 0 to 64. Here is my code:

    // include the SPI library:
    #include <SPI.h>

    // set pin 10 as the slave select for the digital pot:
    const int slaveSelectPin = 10;
    int mute = 64;
    int loud = 63;
    int soft = 0;

    void setup() {
      // set the slaveSelectPin as an output:
      pinMode (slaveSelectPin, OUTPUT);
      // initialize SPI:
      SPI.setBitOrder(LSBFIRST);
      SPI.setDataMode(SPI_MODE0);
      SPI.setClockDivider(slaveSelectPin,SPI_CLOCK_DIV8);
      SPI.begin();
      delay(10);
       digitalPotWrite(mute, mute);
    }

    void loop() {

      // Raise the volume from off to loud
    for(int i = 0; i <= 63; i++){
      digitalPotWrite(i, i);
      delay(5);
        }
      }

    void digitalPotWrite(int left, int right) {
      // take the SS pin low to select the chip:
      digitalWrite(slaveSelectPin, HIGH);
      //  send in the address and value via SPI:
      SPI.transfer(left);
      SPI.transfer(right);
      // take the SS pin high to de-select the chip:
      digitalWrite(slaveSelectPin, LOW);
    }

I THINK my issue lies with setting the clock rate for the DS1801. The data sheet say the chip runs at 10MHz which is why I wrote

    SPI.setClockDivider(slaveSelectPin,SPI_CLOCK_DIV8);

to divide the 84MHz default speed down to 10MHz.

Anyone have suggestions on why my code is not working??? At the moment, I have LED's connected to chip with series resistors to limit current below 2mA. The resistors just blink randomly with the code posted above.

![enter image description here][2]

![enter image description here][3]

  [1]: http://datasheets.maximintegrated.com/en/ds/DS1801.pdf
  [2]: https://i.stack.imgur.com/K8HKw.jpg
  [3]: https://i.stack.imgur.com/4S4LY.jpg

title: How to interface DS1801 digital resistor with Arduino DUE SPI interface? What clock rate so use?

Answers: 2

body: There is ***no way in hell*** you're going to get a 10MHz signal down that line. Shorten it to 3 inches total *maximum* and reduce the clock rate to 2MHz or lower. It is possible to get a 10MHz signal through, but you'd need to switch to twisted pair wiring and proper termination to even begin to have a chance to get it to work.

body:
Well, it turns out that apparently my issue was not having the AGND pin hooked up. In addition to that, I was trying to switch the wiper resistance value too quickly. By putting at least a 10ms delay between calls, it works much better.

Also, it does seem to work even at 10MHz just fine...