text:
Is it possible to detect host usb device connected to arduino? and how?
let's say that I've connected an arduino uno to a pc, or to a mobile phone via usb .. how can I detect the device type and the running operation system if it's possible?

You can't, using stock firmware. And with custom firmware it's still very difficult.
The USB communication chip on the Uno has no out-of-band means of telling the main MCU that it is connected to a host. You might be able to rewrite the communication firmware on the R3 to tell the main MCU over serial that it is connected, but the firmware on the main MCU will need to be written in such a manner that it will anticipate this.
If you want this to work then you should consider using one that has a native USB connection, such as the Leonardo. You will then be able to query the USB facility directly to know whether or not you are connected to a host.

No. The arduino sees usb through a USB-> UART converter (typically FTDI). UART doesn't allow you to do anything other than listen on the RX line and throw bits at the TX line.

I did not try to go further, but I know there is some information passing on Serial1 when you plug a device.
void setup() {
  Serial.begin(115200);
  Serial1.begin(250000);
}

void loop() {
  if(!Serial1.available()) {
    Serial.println("OFF");
    delay(500);
  }
  else {
    Serial.println("ON");
    Serial1.end();
    delay(500);
    Serial1.begin(250000);
  }
}

Maybe you can try to see if depending on the device, information is persistent, in which case you should be able to detect a specific device / kinf of device ?
I'll look at it tomorrow, maybe will have more code to show...

Unfortunately this proposal is fundamentally mistaken - the Arduion Uno which is the subject of the question does not have a "Serial1".  Also, even in the context of some hypothetical other board, the question is not about detecting if there is a host, but detecting which type and operating system it is running, something that would require identifying and categorizing differences in behavior.


text:
what ftdi windows driver for arduino nano
at http://www.ftdichip.com/FTDrivers.htm they seem to divide chips into two categories,  FT4222H vs. D2XX driver.
What's the correct for a arduino nano?

The Official Arduino Nano has an FTDI FT232RL.
You want to use the Virtual Com Port(VCP) Driver so the FTDI device appears as a COM port under windows.
See the getting started guide for details.

The nano board purchased was obviously not an official. Peter at http://www.amazon.co.uk/SODIAL-ATmega328-P-20AU-Module-Board-Blue-Black/dp/B00QPUEFNW/ref=sr_1_1?ie=UTF8&qid=1430991247&sr=8-1&keywords=arduino+nano
helps out with driver to the ftdi-chip clone:
http://www.wch.cn/downloads.php?name=pro&proid=65
All working.

source: Stack Exchange

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

sort: votes


text:
Arduino YUN real time control
I have a very specific problem, exactly with real time control. For example I try to write an application where I can edit min or max temperature that after reaching it , I will receive SMS with message. I'm wondering how to edit variables "on-the-fly" because, as I know Arduino IDE use it own libraries not this from C/C++, and I don't know how to get to SD card in Arduino too. Can someone help ?
Thanks

the SD card is at /mnt/sd/ . you should consider reading the yun tutorials here before going further, the ability to send and receive data is at the heart of the yun design.

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


text:
cannot convert error with pointers
I write a code to store patterns for LED blinking, but I got this error:
led_basics:39: error: cannot convert 'char (*)[17][2]' to 'char*' in initialization

led_basics:39: error: cannot convert 'char (*)[16][2]' to 'char*' in initialization

led_basics:39: error: cannot convert 'char (*)[13][2]' to 'char*' in initialization

and so on for all pattern.
How can I fix it?
Here is the code:
char nulla[17][2]={{0,127},{8,125},{9,121},{10,113},{12,97},{14,65},{24,67},{27,71},{28,70},{30,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};

char egy[16][2]={{0,0},{9,4},{16,6},{18,2},{21,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};

char ketto[13][2]={{0,98},{7,99},{8,97},{12,113},{14,81},{20,89},{21,88},{24,74},{27,78},{30,70},{32,68},{36,64},{68,0}};

char harom[17][2]={{0,34},{7,35},{8,33},{10,41},{14,9},{17,73},{21,72},{24,74},{27,78},{30,70},{32,68},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};

char negy[17][2]={{0,7},{7,6},{8,4},{9,0},{10,8},{21,9},{24,11},{27,15},{28,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};

char ot[14][2]={{0,39},{8,37},{9,33},{10,41},{14,9},{17,73},{28,72},{30,64},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};

char hat[17][2]={{0,62},{7,63},{8,61},{9,57},{12,41},{14,9},{17,73},{21,72},{24,74},{30,66},{32,64},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};

char het[15][2]={{0,7},{8,5},{9,1},{24,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};

char nyolc[15][2] = {{0,127},{8,125},{9,121},{12,105},{14,73},{24,75},{27,79},{28,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};

char kilenc[13][2] = {{0,79},{8,77},{9,73},{24,75},{27,79},{28,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};

char kettospont[6][2] = {{0,0},{9,4},{12,20},{18,16},{24,0},{68,0}};

char *karakterek[11]={&nulla,&egy,&ketto,&harom,&negy,&ot,&hat,&het,&nyolc,&kilenc,&kettospont};

karakterek is an array of char pointers.  It cannot be used to store pointers to char arrays.
I'm not sure it would be possible to store pointers to your 2 dimensional arrays since they are all of different dimensions.  Someone else might know a way to do that.
Here's how I would do it (using as similar as possible a structure):
char nulla[]={0,127,8,125,9,121,10,113,12,97,14,65,24,67,27,71,28,70,30,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};

char egy[]={0,0,9,4,16,6,18,2,21,3,27,7,28,6,30,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};

char ketto[]={0,98,7,99,8,97,12,113,14,81,20,89,21,88,24,74,27,78,30,70,32,68,36,64,68,0};

char harom[]={0,34,7,35,8,33,10,41,14,9,17,73,21,72,24,74,27,78,30,70,32,68,36,80,42,112,48,96,51,32,56,0,68,0};

char negy[]={0,7,7,6,8,4,9,0,10,8,21,9,24,11,27,15,28,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};

char ot[]={0,39,8,37,9,33,10,41,14,9,17,73,28,72,30,64,36,80,42,112,48,96,51,32,56,0,68,0};

char hat[]={0,62,7,63,8,61,9,57,12,41,14,9,17,73,21,72,24,74,30,66,32,64,36,80,42,112,48,96,51,32,56,0,68,0};

char het[]={0,7,8,5,9,1,24,3,27,7,28,6,30,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};

char nyolc[] = {0,127,8,125,9,121,12,105,14,73,24,75,27,79,28,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};

char kilenc[] = {0,79,8,77,9,73,24,75,27,79,28,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};

char kettospont[] = {0,0,9,4,12,20,18,16,24,0,68,0};

char* karakterek[]={nulla,egy,ketto,harom,negy,ot,hat,het,nyolc,kilenc,kettospont};

For starters, I'd make the char arrays single dimension.  Since the 2nd dimension is always a size of 2, you could index through your values reading index 0 into x0, index 1 to y0, index 2 to x1 and index 3 to y1 (I'm assuming these are x y co-ordinate pairs).
Secondly, I'd lose the hard-coded sizes for the arrays.  If you want to add or remove entries, you don't have to keep updating the sizes.
Finally, I'd lose the '&' from your array of array pointers.  Referring to an array simply by its name gives you a pointer to it.  I think '&' gives you a pointer to the pointer, but I could be wrong.

As the second dimension is always 2, you can do this:
typedef char Tuple[2];

Tuple nulla[17] = {{0,127},{8,125},{9,121},{10,113},{12,97},{14,65},{24,67},{27,71},{28,70},{30,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};
Tuple egy[16]   = {{0,0},{9,4},{16,6},{18,2},{21,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};
Tuple ketto[13] = {{0,98},{7,99},{8,97},{12,113},{14,81},{20,89},{21,88},{24,74},{27,78},{30,70},{32,68},{36,64},{68,0}};
// etc.

Tuple* karakterek[3] = {nulla, egy, ketto}; // etc.

(The typedef makes it easier.)


text:
Hi-speed external ADC
I would like to detect signals in nanosecond scale. For that, an ADC with at least 500 MSPS is required.
My question is if its possible to use an external ADC with 500 MSPS with a 16MHz Arduino Mega? If not, is there any additional hardware like FIFO buffer to overcome this problem?
Please help, thanks!

Not sure what it is you want to achieve, but you might be able the use the comparator inside the ATMega328. E.g. to detect when a voltage goes above a certain threshold. PS 16mHz will mean one clock-cycle every 62.5ns, so you're already in the tens of nanoseconds scale.

Why do you want to do this? Even if you could do 500 million samples per second, where would they go? You only have 2048 bytes of RAM on a Uno.

From the Arduino reference on AnalogRead:
"It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."
500msps is an awfully high rate - my first instinct is, perhaps you need to revisit what you are after, and why.
There are indeed chips that will do this for you. It is still not possible with an Arduino, since the Arduino can't even receive the data this fast, let alone process it. Assuming 8-bit sampling, this would generate a stream of data at 4gigabits/second - I doubt any disk drive could write that fast (SATA3 is 4.8gbit/sec, which is 20% more, I suspect that the 20% would be eaten up by overhead - you can't just send raw data to a drive, you also have to tell it where to put it. That just accounts for getting the data to the drive circuitry, not actually storing it).
Perhaps what you're looking for is an oscilloscope. An oscilloscope takes high speed readings and displays them. Oscilloscopes are often used for testing circuits (e.g. looking at what an Arduino puts out/reads in when it's being programmed). Looking on National Instruments' websites, their cheapest one I could find that does > 500msps is worth about US$8,000 (ballpark). You will still not be able to store this to disk, or process it in any meaningful way, in realtime - a board like this will typically capture data (based on a trigger, sample until the memory is full, then slowly move the data to the PC to process.

I need to measure the round trip time of certain EM wave that travels in speed of light. But I have replaced the Arduino, and is using a high speed oscilloscope (with 5GS/s) for my application. Anyway, thank you for the suggestion!

No, it's certainly not possible to directly sample at 500Msps on an Arduino using an external ADC.  Simple maths:

The Arduino can perform 16 million instructions (best case) per second
The ADC performs 500 million samples per second.
500 / 16 = 31.25

Therefore the ADC would be generating 31.25 samples for every clock of the Arduino, so unless you can build in a time compressor (maybe with a flux capacitor too), it just ain't gonna do it.
So you will have to think creatively instead.  A possible solution would involve:

A high speed flash or pipelined ADC, ideally with parallel output.
A large chunk of memory to act as a buffer.
A high speed clock source to set the timing (500MHz?).
Glue logic and counters to take one sample, store it in the buffer, and increment the buffer address.
More glue logic and interfacing to allow the Arduino access to the buffer memory and to control the operation of the sampling system.

This, to me, sounds like a job for an FPGA, and at 500MHz, quite a fast FPGA.  You should investigate some of the FPGA development boards from Xilinx and Altera.

Sorry for the late reply, but I realized that Arduino is not suitable for my application. I need to measure the round trip time of certain EM wave that travels in speed of light. So I have already replaced the Arduino, and is using a high speed oscilloscope (with 5GS/s) for my application. Thank you for the suggestion!


text:
Stack isn't popping off correct data?
So, I was working on a project where I needed to get a random object from a stack, so to make sure my design was correct, I made a dummy program that does nothing but fill a stack with data, then print it out.

why in the world is nothing coming out of the stack but -1s??
Here's the stack.h file.
http://pastebin.com/vjhNLpNu

Please do not put links to your code or worse, take screenshots of your code; the former makes your question NOT self-contained, the latter makes it extremely difficult to people who would be willing to help to actually try to, as they would have to retype everything from the screenshot!

That's very true, I really should have just put it in tags. Very lazy of me, I apologize and will try to remember that for next time.

You're not telling it how big your stack should be, and it defaults to 0 entries, which means nothing gets stored.
class Stack
{
private:
    int *p;
    int top,length;

public:
    Stack(int = 0);  <<== CONSTRUCTOR - DEFAULT SIZE IS 0
    ~Stack();

    void push(int);
    int pop();
    void display();
};

When you make your Stack object you must give it a size for the number of entries in the stack:
Stack stack(4);

You never allocate space for the stack.
The way it's written, you need to pass the stack size into the constructor, and then it's fixed for the lifetime of the object; i.e. it won't grow automatically when you call push(). You're not passing anything into the Stack constructor, so the parameter is defaulting to 0, meaning it has zero size.
The solution is to declare the stack something like this:
Stack stack(10);

(10 is just an arbitrary size -- use whatever you expect to need.)
Incidentally, there isn't an effective safeguard in your code to handle an empty stack. The result is that you're technically getting undefined behaviour at the moment when you call push() (it's writing to arbitrary memory locations).


text:
This specific code just refuses to compile?
I've been working on some software to do REALLY basic composition of music.
Here's my code so far:
#include "notes_sharps.h"

int notes[] = {NOTE_B0,NOTE_C1,NOTE_D1,NOTE_E1,NOTE_F1,NOTE_G1,NOTE_A1,NOTE_B1,NOTE_C2,NOTE_D2,NOTE_E2,NOTE_F2,NOTE_G2,NOTE_A2,NOTE_B2,NOTE_C3,NOTE_D3,NOTE_E3,NOTE_F3,NOTE_G3,NOTE_A3,NOTE_B3,NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5,NOTE_D5,NOTE_E5,NOTE_F5,NOTE_G5,NOTE_A5,NOTE_B5,NOTE_C6,NOTE_D6,NOTE_E6,NOTE_F6,NOTE_G6,NOTE_A6,NOTE_B6,NOTE_C7,NOTE_D7,NOTE_E7,NOTE_F7,NOTE_G7,NOTE_A7,NOTE_B7,NOTE_C8,NOTE_D8};

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

  for(int i = 0; i < 51; i++){
    Serial.println("%i's sharp is %i",notes[i], notes[i]+(notes[i]*0.05937));
  }
}

void loop(){}

This code just refuses to compile, no error messages, it simply leaves my computer dormant.
Here's the log:
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp -o C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp.o

Are you able to upload other codes to that unit?

That's a new usage of Serial.println... I think you're mixing Serial.println(const char *) and sprintf(char *buf, const char *format, ...)

@Jasmine I can run the example toneMelody without error.

I tried it and I got a very clear error message: "fatal error: notes_sharps.h: No such file or directory". If I create the missing file, another error message, just as clear: "error: no matching function for call to ‘HardwareSerial::println(const char [17], int&, double)’".

here's the actual notes_sharps.h file
http://pastebin.com/KVahvSNx

There's nothing wrong with that file. Seems like you just put it in the wrong place and the compiler can't see it. Very common problem with using libraries - http://www.arduino.cc/en/guide/libraries

It's not actually a library. It's just a file I wrote to make my actual program look cleaner.

That IS a library. It's a trivial library, but you need to install it the same way.

As Majenko stated in the comments, your use of the println function is not valid as there exists no overload that takes char*, int, int as parameters.
You could get your program to work by replacing your println as following:
for(int i = 0; i < 51; i++){
    Serial.print(notes[i]);
    Serial.print("'s sharp is ");
    Serial.println(notes[i]+(notes[i]*0.05937));
}


text:
Can I use Serial.println() in a class?
I'm trying to convert a class header file from another c++ project to arduino, which in my mind involves replacing cout with Serial.println.
When I try to recomplile with all of these changes, I get this error from the compiler:
error: 'Serial' was not declared in this scope
     Serial.print(p[i]);

Can someone explain this to me?

You have to #include <Arduino.h>, or compile with the -include Arduino.h flag. The Arduino IDE normally does that for you, but you have to do it yourself if you are working outside the IDE.
There are a couple of Arduino Makefiles floating around the Web which, just like the IDE, take care of this for you.

I'm actually using the Arduino IDE. :\

Are you compiling a .ino or a .cpp? If it's a .cpp, the IDE is probably not adding the #include. If it's a .ino, it may just have messed your code. In the IDE options, you can ask to see all the compile-time messages. This will show the g++ command-line and tell you if it's compiling your original source or a modified version. You will also see the paths of the temporary cpp files it's creating, check their contents, and see if it has broken something.


text:
It is possible to control brightness of an LED strip (connected using a relay and having a seperate power supply ) using output from an arduino?
The circuit contains a relay interfacing with 12v power supply and LED strip. Can the brightness for this strip of LEDs be controlled using the analogWrite command?
This works perfectly for a single LED, but when i replace the LED with a relayed LED strip with its own adapter, it doesnt produce any perceivable output

Relays are really slow, as they are mechanical. You can't use analog-write on them. Follow something like this tutorial (except with only one color, instead of three)

Tried this tutorial and well it never really fully responds to a tweaked example code from the site. I am powering the board through usb and thats the only difference. Basically haven't connected Vin and adapter connection which is directly supplying 12v to led. Could that be a problem that even anlaogWrite of 0 and 200 are not producing much of a difference, very very mild response

As Gerben said relays are only for on/off control. If you need to fade led you should use transistor.

What kind of transistor?

It depends on power consumption (how many LEDs).

How to connect Arduino, LEDs, transistor?

This is schematics how to connect the strip. As i assume resistors are already on the strip.

And little bit simpler image :)

Most transistors don't have the gain, or ratio between "big current" and "small current" to drive a very hefty LED strip when there's a 2K resistor on the base.  In the situation you have drawn where you also have a series resistor on the LED strip it might work, but some real LED strips of the sort the OP might be controlling with a relay are high current devices that can want a fair fraction of an amp, or more.

Yes @ChrisStratton as i wrote it depends on power consumtion. The drawings are just to get an idea of how it works.

And big current its not 10amp ;)) thats in milliamps ;) but regard mA from MC;)

Yes!
In the simpler image replace R2 with a 10 Ohm resistor and Q1 with a N channel Logic Level FET.  This will allow  you to switch (PWM) amps with R1 removed.
My LED strips pull about 3 amps at 12V. Depending on the FET you use you may have to add a heat sink.  You will need to connect the low side (Ground) on the Arduino power supply to the low side on the power supply for the LED strip.  The Arduino can then operate at 5 volts and the LED at 24V or whatever depends on the rating of the MOSFET.  I would suggest using one of the PWM outputs, they will work fine with this circuit.  This works for motors but additional parts will need to be added.
Enjoy.


text:
How does changing arduino power supply from USB to Adapter change the circuit?
I have a circuit running with capacitive Sensors, that also has an LED strip. everything works fine when using USB power from a laptop (connected to the mains) and 12v 2A adapter powering 1m LED strip.
When the power supply is split and the arduino is also powered from this supply ( using adapter port ) the capacitive sensor begins to give junk values.
What changes in a circuit that would create such a porblem? Could it be a grounding issue? How else to ground this arduino to behave as it would with a usb connection?

Powering using 9V battery or same 12v 2a shared connection in the Vin port produces a different set of problems, where the sensor loses its range. How are the various methods of powering the board changing the behavior so much?

They should share the ground connection. Also, do you have any drawings? Of the working situation and where it goes wrong?

I have run into problems like this before, often it can actually be that the voltage is not steady due to the LEDs sourcing current from it.
You may be able to solve the problem by adding a capacitor inline with the power input (from the +12v to GND). I would probably start with a value of around 10 μF and increase it if the interference continues.
Capacitive sensors and very sensitive to voltage fluctuations, you may even want to put a second capacitor across the VCC and Gnd of the sensor.

Some of the capacitive sensors need a seperate regulated power supply.You can look into the data sheet of the capacitive sensor.Maybe you can try with the same.
I just read the datasheet of At42qt2120 cap sensor.


text:
How to effectively modify a library to be able to function with Mozzi Library?
I have sketch that runs almost exactly as I would want it to. Now I am trying to add sound to it using the Mozzi Library instead of just using the tone function. This way I can avoid having to put a memory card slot and a memory card with the Arduino, considering Mozzi produces some good sound. The problem is that Mozzi takes over the timers and a lot of other things. The analogread and the delaymicroseconds have been replaced by Mozzi functions mozzi analog read and mozziMicros etc. I rewrote my sketch adding mozzi relted stuff, but it stops functioning like it should, but it does compile. SO I am assuming I would need to change the Library to replace original functions with mozzi functions like mozzianalogread. On doing this, several errors about arguments and declaration for these functions pop up. Is editing the other library a necessary step? If yes, then what should be things to look out for to prevent such errors.

Without knowing what Mozzi is (an Australian mosquito?), I'd say that your problem is that you need to include the Mozzi library in this "other" library so it knows what these mozzi* functions are.

http://sensorium.github.io/Mozzi/examples/#08.Samples
I did do that and added all the commands and the header to the QTouchADC library.


text:
Could an `analogWrite` command and its variable output values be used to power multiple leds with same intensity?
I seem to be getting the right response on single LED but with multiple LEDS or a relay connected LED strip the voltage outputs seem to be insuffiecient.
What kind of analogWrite values does an LED respond to?

How are you driving your LED's electrically?  With multiples (in parallel) the current requirement will rapidly exceed what one micro can handle, so you probably need a transistor, FET, or driver IC to help out.  But you can still use the information from the PWM "analog out" pin.

replaced the bulb in this image with an LED strip.
http://www.instructables.com/file/FXOD7OOHTVICRIN
and the pin 7 analogWrite values are perfect for single LED but dont produce results for this strip

You need to provide details of the strip.  They come in many forms, some requirung particular signals to drive.

Single LEDs like the standard 5mm leds work from low voltages such as 1.7 - 2.1v, so can be directly driven via an Arduino pin (through a resistor to prevent excess current draw which would damage the pin).
LED strips such as automotive LED strips (12v) require the use of a relay if you are simply switching the LEDs on and off. You can't run the relay directly from an Arduino pin, you will need to use a transistor to act as a buffer between the relay and the Arduino to prevent damaging the Arduino. Instead of the motor and diode in the below diagram, you connect your 12v led strip.

If you want to control intensity, you will need to use a transistor, or a mosfet (mosfets are easier). You can then use AnalogWrite to control the intensity of the LEDs via the MOSFET. You will need to connect the control pin for the MOSFET to one of the PWM-capable pins on the Arduino (the pins which have the ~ mark next to them), otherwise you will only be able to switch the MOSFET on and off, similar to the Relay. This site has a good guide on how to do this with a MOSFET. It also has a guide on how to use a transistor, but I can't include the link yet due to not enough reputation points. It shows both the code needed, and how to connect the components to the Arduino.

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


text:
Ethernet shield and sd card not working togather on arduino mega
I am making a web-client with an Arduino mega and Ethernet Shield. I am trying to receive data from a web-server running a php script and saving that data to the SD card located in the Arduino Ethernet shield. I have separately tested to read and write to SD and to Get data from the the php script using the Ethernet. But when i tried to merge those two code into one, i found that Ethernet is unable to connect to the web-server(php Script).But the Ethernet connects fine when i remove the SD Card from its slot. During my research i found that Arduino mega has different SPI pin configuration that the uno. And the libraries are supposed to handle the SPI data-line independently. But i still tried to manually controlled the SPI bus, but it did not work. As far as i know, i am now unable to change the SPI bus using the D4 pin for SD card and D10 pin for Ethernet.
I am using native Ethernet library and SDFat library.(I Even used the native SD library but the result is the same).
#include <Ethernet.h>
#include <SPI.h>
#include <SdFat.h>
#define Ethernet_ss_pin 53
#define Sd_ss_pin 4

// On the Ethernet Shield, CS is pin 4. SdFat handles setting SS
/////////////////////////////////////////////////////////////////////////////////
////////SD Config
/////////////////////////////////////////////////////////////////////////////////

SdFat sd;
SdFile myFile;
//const int chipSelect = 4;
const char* fileName="database.txt";

/////////////////////////////////////////////////////////////////////////////////
////////Ethernet Config
/////////////////////////////////////////////////////////////////////////////////
//String server = "rfid.unisec-bd.org"; //ip Address of the server you will connect to

//The location to go to on the server
//make sure to keep HTTP/1.0 at the end, this is telling it what type of file it is
String location = "/getData.php HTTP/1.0";

// if need to change the MAC address (Very Rare)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
////////////////////////////////////////////////////////////////////////

EthernetClient client;

char inString[3200]; // string for incoming serial data
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?

void setup() {
  Serial.begin(9600);
  pinMode(53,OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(10,OUTPUT);
  ChipSelect(0);
  Ethernet.begin(mac);
  String pageValue;
  pageValue=connectAndRead(); //connect to the server and read the output
  Serial.println(pageValue); //print out the findings.
  ChipSelect(1);
  // Initialize SdFat or print a detailed error message and halt
  // Use half speed like the native library.
  // change to SPI_FULL_SPEED for more performance.
  if (!sd.begin(Sd_ss_pin, SPI_HALF_SPEED)) {
    sd.initErrorHalt("Sd initialization failed");
  }else{
    Serial.println("Sd card Initialized");
  }
  ChipSelect(0);

}

void loop() {
  Serial.println("Type any character to start");
  while (Serial.read() <= 0) {}
  delay(1000);  // catch Due reset problem
  ChipSelect(2);
  String pageValue = connectAndRead(); //connect to the server and read the output
  Serial.println(pageValue); //print out the findings.
  ChipSelect(1);
  writeSd(pageValue);
  readSd();
  ChipSelect(0);
}
void readSd(){
  //const char path=(const char)fileName;
  if (!myFile.open(fileName, O_READ)) {
    sd.errorHalt("file read error");
  }
  Serial.println(fileName);
  // read from the file until there's nothing else in it:
  char data;
  int c=0;
  while ((data = myFile.read()) >= 0) {
    data=char(data);
    Serial.print(data);
    //Serial.println(c);
    c++;
  }
  // close the file:
  myFile.close();
}

void writeSd(String storeData){
  // open the file for write at end like the Native SD library
  if (!myFile.open(fileName, O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening database.txt for write failed");
  }
  // if the file opened okay, write to it:
  Serial.print("Writing to database.txt...");
  myFile.println(storeData);

  // close the file:
  myFile.close();
  Serial.println("done.");
}

String connectAndRead(){
   ///////// Pin 10,11,12,13 are used as SPI Bus of the ethernet Shield
/// MOSI-         pin 11
/// MISO-         pin 12
/// CLK-          pin 13
/// CS for sdCard-pin 4
/// ss-           pin 10
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
        //digitalWrite(Sd_ss_pin,HIGH); //SD is not active

 /*       USE THIS CODE FOR PROXY SERVER IN BRAC UNIVERSITY
        // if you get a connection, report back via serial:
  if (client.connect("192.168.1.5", 8080)) {  // This is connecting to the proxy
    Serial.println("connected");
    // Make a HTTP request through proxy:
    client.println("GET rfid.unisec-bd.org/getData.php HTTP/1.0");
    client.println();
  }
*/
  //connect to the server
  Serial.println("connecting...");
  while(!client){;}
  //port 80 is typical of a www page
  if (client.connect("rfid.unisec-bd.org", 80)) {
    Serial.println("connected");
    client.print("GET ");
    client.println(location);
    client.println("Host: rfid.unisec-bd.org"); // SERVER ADDRESS HERE TOO
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println();
    //Connected - Read the page
    return readPage(); //go and read the output
  }else{
    return "connection failed";
  }
}

String readPage(){
  //read the page, and capture & return everything between '<' and '>'
  stringPos = 0;
  memset( &inString, 0, 3200 ); //clear inString memory
  while(true){
    if (client.available()) {
      char c = client.read();
      if (c == '!' ) { //'!' is our begining character
        startRead = true; //Ready to start reading the part
      }else if(startRead){
        if(c != '@'){ //'@' is our ending character
          inString[stringPos] = c;
          stringPos ++;
        }else{
          //got what we need here! We can disconnect now
          startRead = false;
          client.stop();
          client.flush();
          Serial.println("disconnecting.");
          return inString;
        }
      }
    }
  }
}
void ChipSelect(int s){
  if(s=0){                              //Both Device is off
    //digitalWrite(53,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(4,HIGH);
  }else if(s=1){                        //Only SD is active
    //digitalWrite(53,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(4,LOW);
  }else if(s=2){                        //Only Ethernet is Active
    //digitalWrite(53,HIGH);
    digitalWrite(10,LOW);
    digitalWrite(4,HIGH);
  }
  Serial.print("Ethernet SS:");
  Serial.println(digitalRead(10));
  Serial.print("SD SS:");
  Serial.println(digitalRead(4));
}

I suppose you have seen this one: http://electronics.stackexchange.com/a/67214/140185

You have to switch off and then on pin 2 (connected to Vcc on SD reader) using digitalWrite
https://stackoverflow.com/questions/41277010/how-to-connect-rc522-rfid-module-and-sd-card-adapter-to-one-arduino-board/46797716#46797716

`//HEADER FILES##################################
#include <SPI.h>
#include <MFRC522.h>
#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <SD.h>
//ARDUINO MEGA
//MISO 50
//MOSI 51
//SCK 52
//ON/OFF SD CARD READER 2
//SD Card DEfinitions###########################
File root;
const int chipSelect = 4;
const int chipONOFF = 2;
//RF_ID Definitions#############################
#define SS_PIN 7
#define RST_PIN 6
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup()
{
Serial.begin(9600);
SPI.begin();
pinMode(chipONOFF,OUTPUT);
digitalWrite(chipONOFF, LOW);
tc_03_rfIDbasicTest();
digitalWrite(chipONOFF, HIGH);
tc_02_SDcardConnectTest();
digitalWrite(chipONOFF, LOW);
tc_03_rfIDbasicTest();
}

void loop()
{ }

void tc_02_SDcardConnectTest()
{
Serial.println("");
Serial.println("");
Serial.println("-----TEST 2: FUNCIONAMIENTO BASICO DE SD-----");
Serial.println("");
if (!SD.begin(chipSelect))
{
Serial.println("Falla en comunicacion, asegurate que la uSD esté insertada e intenta de nuevo");
Serial.println("FAIL");
}
else
{
Serial.println("Tarjeta uSD Detectada");
Serial.println("PASS");
root = SD.open("/");
printDirectory(root, 0);
}
}

int tc_03_rfIDbasicTest()
{
Serial.println("-----TEST 3: FUNCIONAMIENTO BASICO DE RFid-----");
mfrc522.PCD_Init(); // Init MFRC522 chip again per each write attemp
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details

if ( ! mfrc522.PICC_IsNewCardPresent())
    Serial.println("Targeta fuera de alcance");
else
    Serial.println("Targeta dentro de alcance");
if ( ! mfrc522.PICC_ReadCardSerial())
    Serial.println("Falla en lectura de tarjeta");
else
{
    Serial.println("RFid OK :) !");
    Serial.println("PASS");
    String nuid="";
    for (byte i = 0; i < 4; i++)
        nuid+=mfrc522.uid.uidByte[i];
    mfrc522.PICC_HaltA();
    mfrc522.PCD_StopCrypto1();
    Serial.println(nuid);
}
}

void printDirectory(File dir, int numTabs)
{
while (true)
{
File entry = dir.openNextFile();
if (! entry)
break;
for (uint8_t i = 0; i < numTabs; i++)
{
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory())
{
Serial.println("/");
printDirectory(entry, numTabs + 1);
}
else
{
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}`

and this what you get on serial monitor.
`-----TEST 3: FUNCIONAMIENTO BASICO DE RFid-----
Firmware Version: 0x92 = v2.0
Targeta dentro de alcance
RFid OK :) !
PASS
215103959

-----TEST 2: FUNCIONAMIENTO BASICO DE SD-----

Tarjeta uSD Detectada
PASS
BIO/
D70A273B.DB 44
ENROLADO.DB 57
F683B22D.DB 40
A6DE1E49.DB 38
080732DC.DB 38
08D1EF01.DB 38
08267788.DB 38
XWIFI.DB    47
CP0101.DB   26
XFEC.DB 4
CP0102.DB   26
CP0201.DB   26
SYSTEM1/
WPSETT1.DAT 12
INDEXE~1    76
CP0301.DB   26
GP01.DB 33
GP02.DB 33
GP03.DB 33
GP04.DB 32
GP05.DB 32
GS06.DB 35
GS07.DB 37
GS08.DB 36
GS09.DB 36
GS10.DB 36
GE03.DB 24
GE02.DB 20
GE01.DB 23
GS11.DB 38
AP010101.DB 69
AP010102.DB 83

-----TEST 3: FUNCIONAMIENTO BASICO DE RFid-----
Firmware Version: 0x92 = v2.0
Targeta dentro de alcance
RFid OK :) !
PASS
215103959`

Please hablo english.


text:
To what extent is Javascript used in robots?
I originally discouraged my friend against the use of Javascript in his robot project because I didn't know any use for Javascript outside of web developement but then I saw this book on amazon. Since I wouldn't want to mislead him could someone help me develop a better understanding of how often Javascript is used when making robots with an Arduino?

JavaScript isn't usually used to program Arduino so this site isn't really a good place to ask. You might get better answers on another Stack Exchange site, such as Robotics or Electronics.

@PeterR.Bloomfield can the question be transfered

The question is currently rather broad so it might just get closed at the other sites (which would mean it just gets sent back here). I would recommend investigating what kind of questions the Robotics site will accept, and posting a new question there accordingly.

It wouldn't be my first choice for programming of robotics, but it's certainly doable.
Thanks to NodeJS, JavaScript (or ECMAScript as it is properly known) has broken free of the browser and is now a general programming language.
Thanks to the BeagleBone Black (and others), which runs most of its systems by default through NodeJS, including its web-based IDE, you can program the whole board with ECMAScript.
So yes, you can do robotics with ECMAScript, and there are platforms which do allow you to do robotics with ECMAScript.
Would you want to do it in a real industrial environment?
As I said - it wouldn't be my first choice.

The Arduino caveat was added after this answer was written. Check the edit history. Before then it didn't specify any hardware, which is why it got closed - nothing to do with Arduino.

"You think by posting on an Arduino SO it was about something else?" It often is, yes. You'd be surprised by the amount of stuff about the Pi we get here - and stuff not even remotely related to Arduino.  Just because the site is Arduino doesn't mean that everyone has the intelligence to only ask about Arduino things here...

But I still stand by my answer. It may be used in the industry, but I certainly wouldn't have it as my first choice of language.  Python is used lots these days too - and that is even lower down on my list of languages...


text:
What options are available for connecting to a CDMA network?
I am looking specifically to connect to a CDMA carrier from an Arduino. In doing research, I came across a CDMA shield option (requires getting a CDMA module that you drop into a shield), but that ends up being quite expensive - the CDMA module alone is $140, as opposed to a GSM shield which runs $30-$60. I've also tried looking for other CDMA modules, but haven't been able to find much.
Even if it's not sold as a proper Arduino shield, does anyone know of a CDMA module for hobby projects?

There are no CDMA (more correctly known as CDMA2000) modules for hobby projects. There are a lot of reasons for this, which I won't get into, but suffice it to say, it is the way it is.
EDIT
Okay, I'll bite (just a little).

I think the most important reason is CDMA is actually kind of USA-centric technology. While there are now a few other countries that have CDMA networks deployed, it pales in comparison to the number GSM networks globally.
So in the cellular services world there is a service offering called machine to machine (M2M). What this is is a service to allow various machines (think parking meters, vending machines, ATMs, etc.) to have a data connection for control and status messages. These services are usually bought in bulk at rates much lower than equivalent consumer services would cost.
The rest from here on out is just economies of scale. If I am making an ATM machine, would I rather be limited to a handful of countries, or be able to sell in almost all countries. The obvious choice is the latter, so these manufacturers use GSM.
The reason a hobbyist can get anything cheap is because some other industry is using a lot of them. For example accelerometers used to be crazy expensive, that was until millions of cell phones started shipping with them every year, and now you can get them for pretty cheap. GSM modules are relatively cheap because there are lot of devices being made with them for the above mentioned reasons. CDMA modules are not so cheap because there are not a lot of devices using them.

I'm actually really curious why this is.

@JamesKingsbery there you go.

Take a look at this link, you should get the impression that CDMA envelopes a lot more then Cell Phones.
http://www.slideshare.net/mnsh01987/bluetooth-technology?next_slideshow=1
Since you did not state CDMA2000 and I was involved in the automotive industry I took that approach because you can use CAN, RS485 and many other adapters to implement it with the Arduino, to my knowledge a complete CDMA2000 package is not yet available to the Arduino users.  Initially we tested the CDMA theory with open collector transistors on a wire transmission line then we tested CSMANDA with the same hardware. From that point custom chips were designed and implemented. This was in the early 90's.

I assume when you state "CDMA" it is Carrier Detect Multiple Access.  There are several that are not very expensive and can go thousands of feet such as a RS485 network.  The premium would be CAN, it will give your CSMA-NDA (Carrier Detect, Multiple Access, Non Destructive Arbitration). A non-destructive bit-wise arbitration is used to control access to the bus. There are many more but these seem to be very popular.  Of course you can always go to an Ethernet Network, that is not that expensive and is typically a star network where the others are point to point. This is not a  complete answer but it should get you going down the correct path.  CAN will not run with one node, it needs a remote node to acknowledge the transmission. Try this link for a better description: "http://bitstream24.com/controller-area-network-can-bus-arbitration-principle/' Check the people that support this forearm, they sell the modules with instructions and of course eBay.
Good Luck,
Gil

The OP was referring to CDMA2000, as in the cellular communication, not CDMA the channel access method (which is used by CDMA2000).

I am looking at NimbeLink's Arduino baseboard which works with a CDMA modem. Never tried it, but thinking of ordering one. http://nimbelink.com/skywire-arduino-cellular-shield/. Not sure if you'd put this as 'affordable' since it is $40 for baseplate + $130 for modem.
Also this Arduino WCDMA 3G. http://linksprite.com/wiki/index.php5?title=3G_%2B_GPS_Shield_for_Arduino
Frustrating to have all this cheap awesome GSM technology, but only CDMA network in my region.


text:
SoftwareSerial problems
Hi we are using an Arduino Micro and working with a Bluetooth device and a Rfid Scanner from Sparkfun(ID-20 LA). For that we implemented 2 SoftwareSerial objects and the Serial port for the Serial Monitor. If we use one SoftwareSerial object and the normal Serial everything works fine. For example we can send and receive things over Bluetooth. But when adding another SoftwareSerial object( Rfid then ) One of them doesn't work.
Starting with the Rfid SoftwareSerial ends up to the same result.
We've also already tried to change the ports and so one.
Every help is appreciated.
Thanks in advance.
The Code ( this is already the third programm nothing has changed )
#include <SoftwareSerial.h>

SoftwareSerial rf(11, 12);
SoftwareSerial bt(8,9);

void setup() {
  Serial.begin(9600);
  rf.begin(9600);
  bt.begin(9600);

}

void loop() {
  if(Serial.available())
  {
   while(Serial.available())
     Serial.write(Serial.read());

   Serial.println("");
  }

  if(rf.available())
  {
   while(rf.available())
     Serial.write(rf.read());

   Serial.println("");
  }

  if(bt.available())
  {
   while(bt.available())
     Serial.write(bt.read());

   Serial.println("");
  }
}

I would suggest you to use RX on interupt pins and TX will be used by arduino anyway. That would be my suggestion. Also check this answer http://stackoverflow.com/a/16067060/3604360

Taken from http://www.arduino.cc/en/Reference/SoftwareSerial:
Limitations
The library has the following known limitations:
If using multiple software serial ports, only one can receive data at a time.

If your project requires simultaneous data flows, see Paul Stoffregen's AltSoftSerial library. AltSoftSerial overcomes a number of other issues with the core SoftwareSerial, but has it's own limitations. Refer to the AltSoftSerial site for more information.
If you look at SoftwareSerial's code, you'll understand the limitation:
/* static */
inline void SoftwareSerial::handle_interrupt()
{
  if (active_object)
  {
    active_object->recv();
  }
}

Basically, the code waits for an interrupt to detect state changes on the pin, and directs it to the "active" serial object.
Hope this helps.

Under the known limitations in the SoftwareSerial documentation:

If using multiple software serial ports, only one can receive data at a time.

It's still possible to use multiple instances of SoftwareSerial. However, when you want to use a specific one, you need to call the listen() member function. This will allow it to receive data until you call that function on a different instance.
One very important thing to understand is that data is not queued in the background. If information arrives while a SoftwareSerial port is not listening, it simply gets discarded.
There may be alternative software serial libraries which suit your needs, depending on how they use interrupts. Alternatively, you could use a different Arduino which has multiple hardware serial ports (such as the Mega).


text:
2.8" TFT Touchscreen Prohibits Access to Unused Pins
This is probably a beginner question. You've been warned.
I recently purchased a touchscreen (http://www.adafruit.com/products/1651#tutorials) specifically because it left so many pins open to work with and I needed to hook up one, possibly two more items to my Arduino. However the touchscreen fits over the Arduino and covers all the pins.
How do I access the pins that the LCD isn't using?
To be specific, I will be adding a Galvanic Skin Sensor on two analog pins.

The standard shield to processor extender pins/sokets are made to solder through a shield, with pins extending down into processor sockets and socket end up for a shield above. If you plug unsoldered ones of these onto the shield pins that are used by the LCD and plug them into the processor, the other processor pins will be accessible.

Dupont jumper cables are your friend. The most useful ones are male-to-female:

You can end up with a bit of a tangled mess though when you have a number of shields all side by side.  Not a lot you can do about it though.

Several options:

Use wires to connect it rather than sticking it directly onto the Arduino.
Use a header extension to lift the display away from the other headers.
Use right-angle headers on the other pins.

Would right-angle headers even be applicable in this situation? I'm not soldering anything. Thanks.

Just press-fit them into the existing headers.

Really I'm just posting to have participated in the forum. Actually I'm new to arduino, and don't even know how many pins the screen actually uses. My version of the screen is a Pixnor screen made by someone who does not really provide technical description, examples, etc.,, and some of the pins are different, or perhaps the entire chip driving the shield is different, so none of the adafruit sketches work. I haven't figured out anything more than how to hook up the touch to an x,y coordinate serial read,, there's an example somewhere that leaves all of the pins unplugged, with the exception of the touchpad data wires, and lets you play on a dark screen with the coordinate plane.
but anyway, my first thought was, really the touchscreen should plug into a protoshield, which would allow you to have a pin-layout which runs to a protoshield, and then your screen would be fixed over that layout, when would then plop onto your arduino, or back off again without disassembling your sensor/input layout. (which means you can still rig up some experiment with the arduino without having to rerig up your screen and sensors.) ,, So I think I'm going to go about getting more proto-shields.

get a Protoshield, a good one and put it between the arduino and the shield

Please can you format/edit your images, and expand upon your answer and explain why a Protoshield would help?


text:
Does Arduino Tian/LininoOS support Python 3?
I'm using an Arduino Yun running OpenWRT and it only runs Python 2.7.
I need to find a microcontroller+processor+WiFi board that supports Python 3. Does the Arduino Tian work for this, or are there any others?

OpenWRT supports Python 3.3; is OpenWRT on the Yun less capable than elsewhere?  Also see Installing Python3 section in Python page at openwrt.org

it is different. its based on a selfmade kind of openWRT. it does not have ./scripts/ and the path for opkg is: http://downloads.arduino.cc/openwrtyun/1/packages/Packages.gz
im searching for python3+

Linkit Smart 7688 Duo Yun compatible board has support for python3.4 with openWRT 15.05.1. But it lacks some of the nice Arduino stuf like REST API with YunServer/Bridge

Yes, run the following
opkg update
opkg install python3-base_3.4.3-2_ar71xx.ipk

this does not work on Yun v1 nor on Arduino Industrial 101 im still searching for a greater version then 2.7 on one of those boards...


text:
Change arduino.local server address
I have a Yun and I'm trying to change the URL I type in to access the Web UI.
I've successfully changed its hostname in /etc/config/system, which now lets me SSH in using the new name. However:

Going to newname.local doesn't work (no response at all).
Going to arduino.local pulls up the green page 'Wait a moment or click here...', after which no page is rendered.

How can I access my Yun by typing in newname.local in my browser?

That should be working fine.
I just logged into my Yún and changed its name by editing that file.  I then restarted avahi-daemon since that is what broadcasts its name (faster to restart the daemon that reboot the whole Yún).
Browsing to the new name worked fine.
matt@dell:~$ ssh root@arduino.local
root@Arduino:~# vi /etc/config/system
(edit the config file)
root@Arduino:~# hostname skybridge
(manually changing the hostname so I don't have to reboot)
root@skybridge:~# /etc/init.d/avahi-daemon restart
(restart the avahi daemon)

Browsing to skybridge.local now shows me the Arduino login as it should.
As a further test I have just rebooted my Yún so it runs everything from scratch and it still works fine.
There are a number of caches involved in the system, any of which may be getting in the way.  It could be that the browser has cached incorrect or out of date information about the FQDN (fully qualified domain name) for the name you have given your Yún, in which case just closing and re-opening your browser may help.  It may be that the mDNS lookup system on your computer (you haven't mentioned which operating system you are using, which is a big factor) has cached old or out-dated information for the FQDN, in which case flushing that cache may help (how you do that depends on your OS), or just rebooting your computer.
Incidentally, if you are on Linux (Windows lacks these basic networking facilities along with many other basic tools), you can query the network for your Arduino Yún with the avahi-browse and avahi-resolve commands.  OS X has similar tools, but I don't know off hand what the commands are:
matt@dell:~$ avahi-browse _arduino._tcp
+  wlan0 IPv4 skybridge                                     _arduino._tcp        local
^CGot SIGINT, quitting.
matt@dell:~$ avahi-resolve -n skybridge.local
skybridge.local 192.168.0.252

Thank you very much for your answer - I'm going to test it and get back to you.

It turned out that the method did work. For some reason it didn't respond consistently right away, but a day or so later. Thank you!

@sscirrus Probably a cache that needed to expire then.  They can be pesky sometimes...


text:
How does Yun identify itself to Windows?
When I plug in my Yun, Windows pops up a box saying Windows needs to install driver software for your Arduino Yun.
What does Windows use to identify my device as an Arduino Yun? Is it written in a file somewhere, so I could for example, remove that driver prompt, or change it to Windows needs to install driver software for your Foo Bar?

It is written in what is called the USB String Descriptor.  I don't have my Yun to hand right now (it's acting as a wireless bridge temporarily), but all USB devices have these USB String Descriptors.  Here's an example for the Leonardo (which you can easily inspect on Linux):
$ sudo lsusb -v -d 2341:0036

Bus 001 Device 015: ID 2341:0036 Arduino SA
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x2341 Arduino SA
  idProduct          0x0036
  bcdDevice            0.01
  iManufacturer           2 Arduino LLC      <<== String descriptor ID 2
  iProduct                1 Arduino Leonardo <<== String descriptor ID 1
  iSerial                 0
  ... etc ...

Internally the strings are stored as an indexed table - there's two there, ID 1 and ID 2.  The Device Descriptor then has a couple of bytes in it that says "The manufacturer is string ID 2, and the product name is string ID 1".  The operating system then requests those string descriptors so it can display the friendly message for you.
If you want to change that name you basically have to both re-program the bootloader (which has the USB descriptors when in program upload mode) and the Arduino core (that has the string descriptors programmed into it).

authors: Дима Перильман


text:
Compatibility between Particle Photon and Arduino
Is it possible to run Arduino on a Particle Photon?
I want complete software control over the device so I can connect it to the internet and do stuff without going through Particle's cloud, logins, etc.

I found several F1 cores, but no F2 cores yet.

Hi @IgnacioVazquez-Abrams - I'm very new to this stuff overall. I'm not looking to do any custom electronics (soldering/breadboards/shields) work, just software development. What are these cores and what do they mean in regards to whether I can run Arduino or not?

A core is a shim between the Arduino libraries and the underlying hardware. Without one you won't be able to use the IDE or any of the Arduino libraries with the board.

@IgnacioVazquez-Abrams OK, so how good/bad is it that you've found 'several' F1 cores but no F2 cores?

It means that it may be possible to create a F2 core, but that it has not been done.

You can use the new particle dev platform to do this https://www.particle.io/dev


text:
How to copy files from local computer to Yun with scp?
I need to transfer files from my local machine to my Arduino Yun.
I have tried:
scp /Users/SSCirrus/Documents/index.html root@arduino.local:/root
scp ~/Users/SSCirrus/Documents/index.html root@arduino.local:/root
# No such file or directory (referring to my desktop)

I have confirmed that the filepath is accurate. What's wrong here?

Try ~/Documents/index.html

Try ~/Documents/index.html
The ~ represents the current user's home directory, so ~/Documents is the Documents folder for the current user.  It means you don't have to make sure you have spelled the user's home directory exactly right.
Other options are:

$HOME/Documents/index.html
Documents/index.html (if you are in your home directory)
cd ~/Documents then just use index.html

... the list goes on ...


text:
Transmitting sketches to Yun with Autobahn - a byte at a time?
I am using this tutorial to connect an Arduino Yun with a browser using Autobahn.
In the python file in the above repo, there is this code:
def controlLed(self, turnOn):
    if turnOn:
        payload = b'1'
    else:
        payload = b'0'
    self.transport.write(payload)

Here's the thing - I need to send whole sketches to my Yun, not just '1' or '0'. I tried sending more to the payload (like payload = b'this is part or all of a sketch') but that doesn't work. I experimented with some other data types but at the moment these are shots in the dark.
How can I send some proper data (like 100 lines of Arduino sketch) with this mechanism? The end goal is that my existing sketch receives the new sketch commands via serial and runs them.
if (port->available()) {
  int commands = port->read();
  // Run commands here
}

I would be hugely appreciative of any help. Thank you!

Partial answer: to send more information than just a single byte, it is possible to run:
# python
payload = "Here is a longer string"

# arduino
String commands = port->readString();           // Reads the whole thing
String commands = port->readStringUntil('\n');  // Reads until the given separator


text:
Yun availability
I am starting a project that may need a lot of Arduino Yuns in the future, but today I found that they are not available on the official Arduino store.
What's the story on the Yun? Is it being replaced by something newer? Also, how can I evaluate the longer-term availability of this board?
In case it's helpful, I need the dual-processor setup, wifi capability, and extra storage of the Yun.

If you need a lot of them, the Yun, or frankly anything branded Arduino, is probably not the best choice.  For anything production oriented, define the specific characteristics you actually need, and then look at the range of platforms providing them.  There are lots of wifi/IoT type boards on the market, of both embedded linux and bare metal varieties.  You will be most secure if you can distinguish the generic parts of your system from the layers needed to tailor it to a particular board, as that gives you the future option of changing out the board based on market conditions.

In short: Who knows?!
With all the in-fighting between the two Arduino factions (Arduino.cc and Arduino.org) it's anyone's guess what boards are going to be available this time next year, and of those that are available which of the two factions will be producing and distributing them.


text:
Perfect copy of Yun with Micro SD
My Yun has a micro SD card with shared file system using ExpandingYunDiskSpace.
I would like to copy my Yun/SD card data perfectly onto my backup Yun/SD card. Because I have made many changes to the filesystem, just re-running the whole process manually would take a long time.
What methods can I use to transfer my Yun's data onto my other Yun?
My other Yun is brand new (never plugged in), and I have a brand new SD card in there. If I can do a 'bit-perfect' transfer for Yun and Micro SD in one shot that would be ideal.

Copying an SD card (cloning) is easy enough to do.  On Windows you can use Win32DiskImager.  On Linux and OS X you can either use dd from the command line:
(read)
$ dd if=/dev/sdb of=MySD.img bs=32k

(write)
$ dd id=MySD.img of=/dev/sdb bs=32k

For OS X the device names will be different, also in Linux you need to check which /dev/sd?? it is.
Also in Linux and OS X there are GUI applications that can do it for you - the Disk Manager in OS X, and "Gnome Disks" in Linux.
That is only good for the actual SD card contents though.  If you need to clone the actual Yún itself then it becomes more tricky.
Fortunately there are tools available to help you.
Details on how to create and restore a backup of an OpenWRT system (which is what the Yún is) can be found on the OpenWRT Wiki: http://wiki.openwrt.org/doc/howto/generic.backup
Note that again it requires a Linux or OS X (preferably the former) system to do it since it relies on the standard Unix scripting tools and commands that are lacking on a Windows system.
You may be able to do all the above on a Windows system if you make it look like a Linux system by installing Cygwin.


text:
Possible to live-control an Arduino microcontroller from any Linux IoT board?
I'm working on a home project that centers around a non-Arduino Ubuntu IoT board but I'd like to add an ATmega32U4 chip for USB HID.
I'm thinking about using an Arduino Micro.
The signals to the Micro would have to come from my other board (maybe a Python script), but I haven't found instructions on how to send instructions in real-time from Other Board to Arduino Micro so they go straight through the Micro to the computer it's attached to.
How can one do this?

Am I right that your structure is Ubuntuboard --> Micro --> PC? Why do you need the Micro to communicate with the PC? What do you try to achieve?

@chrisl The Ubuntu board doesn't have a microcontroller and it doesn't work as a HID (mouse). That's what I need the Micro for.

@Juraj I don't understand what you mean by that comment.

can you just use a usb2serial adapter and the micros tx/rx?

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


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

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

avrdude done.  Thank you.

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

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


text:
Cannot access SD card on Yun
I have a brand new 8GB micro SD card freshly formatted as FAT in my Yun.
When I run df -h, I don't see the card's capacity included.
When I enter cd /mnt/sda1, it says can't cd to /mnt/sda1.
When I SSH into the Yun with ssh root@arduino.local and run dmesg, I see confirmation that the SD card is recognized:
[   11.510000] sd 0:0:0:0: [sda] 15431680 512-byte logical blocks: (7.90 GB/7.35 GiB)
[   11.510000] sd 0:0:0:0: [sda] Write Protect is off
[   11.510000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[   11.510000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.510000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.520000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.520000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.530000]  sda: sda1
[   11.530000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.530000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.540000] sd 0:0:0:0: [sda] Attached SCSI removable disk

How can I access my SD card and include it in the Yun's recognized storage space?

I take it you've mounted the SD card, with mkdir -p /mnt/sda1 and then mount  /dev/sda1 /mnt/sda1 ...?

I ended up resetting my Yun and following the Arduino tutorial to expand disk space. But, thank you for that comment - as funny as it sounds, I didn't know to do that!


text:
Help to understand multiple PWM working together
I'm very new to arduino related stuff so this question might be really easy to answer.
I don't understand how multiple PWM outputs are supposed to work. Look at the pic.

In the first(1) case we are using short signal width which would be close to motor staying still. In this case, as can be seen, short pulses follow each other, so does the code.
motor1.writeMicroseconds(shortWidth);
motor2.writeMicroseconds(shortWidth);
motor3.writeMicroseconds(shortWidth);
motor4.writeMicroseconds(shortWidth);

when motor4 ended it's output, motor1 starts it's pulse again causing non-problem consequent pulses.
In the second(2) case pulse is wider which corresponds to setting motor speed close to maximum. After motor1 finishes generating width, it's time for motor2 to generate one. But when it does, motor1's period comes to end and it has to start generate width again, but arduino is busy generating pulse of motor2.
How does PWMs work in this case?

are you trying to understand how the servo library manages multiple ppm/pwm signals at once? Those writeMicroseconds calls don't directly relate to any change in the output state of a pin. They just reconfigure the servo lib's signal generator that uses interrupts to change the pin when a certain amount of time has passed.

Thanks, that actually clears some things up. Still it's interesting to dig a little deeper and to know how same timer manages to make a pwm signal at once.

The timer interrupts routine get called every X microseconds. This routine increments an counter. Loops through all servos and sees if the PWM value for that servo is greater of less than the counter value. If less, write a HIGH to the pin associated with that servo, otherwise write a LOW. The actual code is a bit more difficult, but that is the gist of it.


text:
Weird Arduino timer behaviour
I am trying to output something every one second with the following code.
volatile uint64_t timerCounts = 0;
double timenow,pretime;
void setup()
  {
     Serial.begin(19600);
     noInterrupts();
     TCCR2A = TCCR2B = 0;
     TCNT2 = 0;
     OCR2A = 124; //Zero Relative 125
     TCCR2B = B00001101;  //prescaler = 1024
     TIMSK2 |= (1 << OCIE1A);
     interrupts();

     Serial.print("Begin... \n");
  }

  //**********************************************************************
  //  Timer2 Interrupt Service is invoked by hardware Timer 2 every 0.008s
  //  16Mhz / 125 / 1024 = 125 Hz    0.008s

  ISR(TIMER2_COMPA_vect)
  {
     timerCounts++;
     if (timerCounts == 125){
        Serial.print("1s");
        timerCounts = 0;
     }
  }  // end of TIMER2_COMPA_vect

  void loop()
  {

  }

In the above code, I have set the OCR2A(output compare register) to 124``, which is well below 256(2^8). A user defined counter is also used.
However, when I execute the programme, the interval between consecutive outputs is less than 1 second.
When I change it to timer 1, the interval becomes roughly 1 second.
When I change it to timer 0, the interval becomes longer than 1 second.
Anyone knows why?
Thanks.

OCR2A doesn't do anything because the timer is in 'normal' mode. In normal mode the timer will just count to 256, not 125. Which would mean the you get a serial.print every 2.05s.
You need to use CTC mode. Do this by setting the WGM21 bit to 1.
TCCR2A = _BV(WGM21);


text:
Variable current switch by human touch
Two goals:

Make an LED turn on when a person touches two conductive pads (e.g. two square of aluminum foil)
Make the RGB LED change color depending on how hard the pads are squeezed. I will figure out the color algorithm later. For now I just need to be able to sense variable conductivity/capacitance/current (one of those?).

I have an Arduino LilyPad. I know this can be done because I've seen it before (just don't remember the code or circuit). Example image:

I know the human body is conductive, so I'm not quite sure why the LED won't go on when I contact the conductive pads. My only hypothesis is that the resistance is too high, but that must mean some current is going through, no?
Thanks.

Okay; to start with, the Arduino Playground has a how-to guide, the components are commonplace - either recycle a high-resistance resistor from junk or buy one from eg Maplin at 38p.
This works as follows:
You charge the capacitor with one output, through a resistor. This charges the capacitor in RxC seconds - C is very small, typically 10^-11 or so, so a decent sized resistor helps make it slow, in computer terms. Ensure this is held on for long enough to charge fully. You can use one charge pin for many touch sensors.
You then drop the charge pin to 0, and see how fast the sense voltage drops; this will be affected by fingers etc, giving a time value reflecting the degree of contact; normally this is used as a threshold on/off, but does allow for some pressure sensitivity. You need one R/C/sense-pin per switch.

I am going to make this answer as simple as I can, the body is not THAT conductive, you gotta use something like a touch sensor.

+1; most touch switches use capacitance; a firmer press will put more of your finger against the pad, the increase in area increases the capacitance (& slows the discharge time, which you measure)

I'd downvote this but I can't yet on this SE.  He's asking how to create this.  Not asking how conductive the body is, we all know there are touch sensors that do work.  What the OP wants to know is how to make this work, not how conductive the body is, followed by "use a touch sensor" which is what he's asking how to do to begin with (most likely home built)... he just didn't use those words.

@Tyson Yes, right. I need a capacitance sensor, so how. It looks like there's an Arduino library for this, and I see an Instructable for using it. I don't have a standalone resistor, though—just LEDs with resistors built in. How can I work around that?


text:
Mac Big Sur don't recognize generic Wemos D1 MINI PRO based ESP-8266EX
I bought one of theses cheaps & generic Wemos D1 MINI PRO with ESP-8266 to make a system to connect my lamp with google home etc.
But the problem is to upload the code into wemos. The Arduino IDE do not recognize the USB port that is connected.

When I connect to my Mac the board flashes the blue LED, so I suppose that it's not dead or something.
I've tried 5 different cables e nothing. I've read some articles about drivers to install but is only for Sierra or High Sierra.
Also, uninstalled and installed the arduino IDE.
I installed the ESP8266 Boards in the Boards Manager.
I tested it out with an Arduino UNO board and it recognized normally.
I have no idea what to do. I don't have a windows PC in my house to test it out, as well.
Here the pics of the board:

Make sure you are using a proper USB cable, charging cables don't have the data pair wires

You need the CP210x drivers from here.

Just installed and didn't work. :( Rebooted the mac and checked for "systemextensionsctl list | grep -E '(silabs|cp210x)'" on terminal, it says that is activated enabled and the arduino IDE doesnt show the connected port.

@capanema, Do any new devices show up under /dev when it's plugged in?

@timemage yes, i have 1 arduino uno and 1 nano and both show up!

@capanema, so they show up under /dev but not in the Tools/Port menu?

@capanema Uno and Nano use a different interface chip. Does the D1 show up in /dev?

I'm wondering specifically what dev name is showing up.  In the past, at least, the IDE has been selective about what names it recognises as valid ports.


text:
Real range of long range transceptor LORA RA-02 SX1278 with Arduino UNO
I'm working in a project where I have to send data from long distances (about 1 km) between 2 Arduinos UNO which are powered by computer's USB ports. The place is a small city with no large buildings. I have bought two transceptors LORA RA-02 SX1278 at 433 MHz with an antenna for this frequency, like this:

The results are dissapointing. I can reach 300-350 meters with a stable communication (1 data send every 5 seconds). I was only able to, only one time, receive a data from a 1.4 km distance, but the message was corrupt, like this:

I have tried:

Different programs and libraries (Now, i'm working with this library)
Frequencies from 410 MHz to 525 MHz, according to the range inscriptions on the module

But the distance is still far away from 1 km for a stable communication. I have seen some people reaching 2-3 km with this module and some documents say that it is possible to reach 10 km.
The question is, what am I doing wrong or what I should change to improve the results?
Any help or related experience is very useful!

how are the radios powered?

more over with what @jsotola asked, are you sure the voltage is not dropping when it transmits?

Rather than using that stubby antenna, which is compact but non-directional, you might consider a gain antenna (i.e. a directional one) instead.

If you haven't already, you should probably make use of setTxPower.  I doubt it will make the difference you're looking for, but it won't hurt.  The selectable bandwidth might also have an effect on range.

@chad-g The voltage is not dropping, also I have tried with a difference source of power and it works ok.

I think it could be something related with the antenna, as @jwh20 commented, but i should try first

@timemage thanks, I will try it


text:
Confusion about Oscope reading of Arduino Software Serial
I am trying to troubleshoot a Software Uart Connection from my Arduino Nano, and I do not understand this output. The setup is simple, I have a Software Serial connection on pins 2 and 3. I send 170, which I expect to be 10101010 of course with a low start bit and high stop bit.
I hook up to the TX line with my Oscope and check the waveform, but its not as I expect.... I only see 101010
#include <Arduino.h>
#include <SoftwareSerial.h>

#define SW_RX 2
#define SW_TX 3
#define SW_BAUD 9600

SoftwareSerial Serial2(SW_RX,SW_TX);

void setup(){
  Serial2.begin(SW_BAUD);
  delay(1000);
}

void loop(){
  Serial2.write(170);
  delay(100);
}

Can someone help me to understand this output?

it is helpful if you start thinking in hex because the conversion to binary is direct, without any math ... you sent 0xAA ... try 0x55 ... 0x40 ... 0x02 ... what do these values reveal about the problem you are trying to solve?

It is working exactly as expected. The scope trace shows 10010101011:

1: idle state of the serial port
0: start bit
0: first data bit
1010101: other data bits
1: stop bit.

Keep in mind that the data bits are sent least-significant first.

thank you so much that makes sense


text:
ADXL345 to detect sudden and large changes in acceleration
I am working on school project to develop, basically, a shock sensor when the object containing the ADXL345 is thrown to the ground.
I have used the Adafruit ADXL345 sensortest from the library but I am not sure how to code it such that the reading will only appear when there is a sudden and large change in in acceleration in either the x/y/z direction.
Any tips on how to do so?

same way that you would code it so that a reading only appears when you press a button

Build an enclosure for the Arduino and the sensor in such a way that you
can keep connected the USB cable that links the Arduino to the computer.
Then run the sensortest sketch provided as an example with the
library, and look at (or better yet, record) the acceleration data.
Now turn the enclosure around, shake it, hit it, drop it to the
ground... all while monitoring the sensor's output. I recommend that you
plot the acceleration curves: it should make things clearer. What do you
see? Can you tell the difference between the enclosure being dropped to
the floor and other forms of shaking just by looking at the output data?
How do you tell the difference? Is it the magnitude of the acceleration
or is it the rate of change? If you think the rate of change is more
relevant, then modify the sketch in order to also print this rate of
change. In either case, can you find a threshold of magnitude (or rate
of change) of acceleration that could be used to discriminate between a
drop and other forms of movement? If so, write it down.
I am asking all the questions above to show you the path to solving your
problem. The purpose is not only to have you do all the work: I do not
have the answers to those questions, and you will really have to do all
this work yourself.
You should be able to come up with a criterion of the form: the object
has been dropped if such function of the measured acceleration is higher
than such threshold. The function would likely be either the Euclidean
norm of the acceleration or the Euclidean norm of its time derivative (I
cannot tell which is better). Now code the function in your sketch, then
you can write something like:
if (computed_criterion >= drop_threshold) {
    signal_that_the_object_has_been_dropped();
}


text:
generate x item long list for gyverportal drop-down selection
I am trying to make a drop down selection with gyverportal. The issue is that I don't know how many items there are so the list cannot be hard coded. Here is an example from github:
GP.SELECT("sel", "val 1,val 2,val 3", valSelect);
//where sel is the name of the field and valselect is the currently selected item.

I am very confused with the different types of text (char, char*, const char, const char*, String, char array[10]...just to name a few) and the operations with them seem a nightmare.
I think gyverportal expects a "char*" for the list.
for context:
The items are loaded from EEPROM and the number is stored in Length.
what I need is:
for 0 items: "none"
for 5 items: "1,2,3,4,5,none"
for 10 items: "1,2,3,4,5,6,7,8,9,10,none"
int Length=5; //I have five items to select from
char* dropdownoptions= "";
  if (Length<1){
    dropdownoptions="none";
  }else{
    char Answ[60]="1,";
    for (int i=1; i<=Length; i++){
      char part[3];
      String str=String(i+1);
      str.toCharArray(part, 3);
      strcat(Answ,part);
      strcat(Answ,",");
    }
    strcpy(dropdownoptions,Answ);
    strcat(dropdownoptions,"none");
  }
  Serial.println (dropdownoptions);

This code has been rewritten like 30 times and compiles, but crashes the board (esp8266) aka boot-looping
Ideally this is what I would like to do
dropdownoptions= "";
    for (int i=1; i<=Length; i++){
      dropdownoptions+=i;
      dropdownoptions+=",";
    }
    dropdownoptions+="none";

Use stncpy() and strncat() to guard against overflowing character arrays. Google them. dropdownoptions is two bytes long and you're copying longer strings into it. It needs to be large enough to store the longest string you're copying into it.

@romkey This is a bit misleading. dropdownoptions is two bytes long, since its a pointer and not a character array. It is not meant to hold a string, so it wouldn't be a solution to just make it bigger.

@chrisl I agree :)

As explained by chrisl in his answer, you have to declare
dropdownoptions as an array of char large enough to hold the whole
string, including the terminating '\0'. If you know beforehand the
maximum value of Length, you could size the array accordingly.
Otherwise, you may compute the required size as a function of Length:
int str_length;  // size of the string, including the final '\0'
if (Length < 10)
    str_length = 2 * Length + 5;
else
    str_length = 3 * Length - 4;  // assume Length < 100
char dropdownoptions[str_length];

Then you have to write the contents into this array. One way to do it
would be to write each individual piece into a temporary array, then
copy it to the array dropdownoptions by using string concatenation. My
preferred way of filling the array, however, is the “zero-copy” method
consisting of writing the pieces straight into the right place of the
final array. This requires some pointer manipulation. If you are too
uncomfortable with pointers, you may skip this answer. But if you want
to learn and get some practice, please read on.
Let p be a pointer to the current array position where you want to
write. You can pass this pointer to sprintf() in order to write a
piece of data into the buffer at the right place. sprintf() returns
the number of bytes written, not counting the terminating '\0', and
you can then advance the pointer p by this exact amount in order to
know where to write the next piece. In code:
char *p = dropdownoptions;  // current write position
for (int i = 1; i <= Length; i++) {
    p += sprintf(p, "%d,", i);
}
sprintf(p, "none");

There is one drawback to using sprintf() though: if you get the size
of the array wrong and too short, you will end up writing past its end
and corrupting your memory. If you want to be defensive, you should keep
track of the amount of available space remaining, and use the function
snprintf() instead. This function takes, as a second parameter,
the number of bytes available in the buffer, and it will never overflow
that buffer. I find that the easiest way of keeping track of the
remaining space is to initialize a pointer to the end of the array
(technically, “one past the end” of the array), and compute the
available space as end-p:
char *p = dropdownoptions;  // current write position
const char *end = dropdownoptions + str_length;  // end of the array
for (int i = 1; i <= Length; i++) {
    int count = snprintf(p, end - p, "%d,", i);
    p += min(count, end - p);
}
snprintf(p, end - p, "none");

The reason of min() being used here is that snprintf() may return a
number larger than the available space: if the buffer is too small, this
function returns the number of characters that would had been written
(not counting the terminating '\0') had the buffer been large enough.

Thanks for the detailed introduction to pointers, I have a lot more to learn.
The EEPROM has 20 items that I store so now the code works with char dropdownoptions[60];
I do not expect to ever overflow it (there are many checks in place) so I used sprintf.

The reason why your code crashes is, that you are trying to write to a non-valid pointer.
With the line
char* dropdownoptions= "";

you are declaring a pointer to a character (meaning a 2 bytes big memory address) and let it point to a string literal. All string literals are placed in the read-only section of the RAM by the compiler and cannot be changed. Thus with this line you only have a pointer (memory address), but not a buffer/memory space to write to. Later you are trying
strcpy(dropdownoptions,Answ);

which wants to write to the memory location/address, where dropdownoptions points to. But it is in the read-only section, it cannot be written, so your code crashes. And its better, that it crashes than writing data to some random memory location, where something important might be placed.
Doing
dropdownoptions="none"

is ok, since the literal string "none" is also placed in the read-only section. So in this case only the pointer changes, not the underlying data.

If you want to write to dropdownoptions, you need to declare it as a character array:
char dropdownoptions[70] = "";

Make it big enough, that it can hold the biggest string, that you expect. The rest of your code should then work like it is. Though the conversion from the integer i to a string can be done shorter:
char part[3];
itoa(i+1, part, 10);

Then part contains the number as null-terminated string, thus you can use the strX functions on it.


text:
Mega 2560 with Adafruit Music Maker and TFT - Pin reroute
I'm building a custom headunit for my motorcycle using the Arduino platform. I wanted to try it as the modular nature of the board and shields looked very versatile. While there does seem to be plenty of documentation on how to use a single shield on a board, there seems to be very scant documentation on how to use multiple shields on a single board.
I tested the Adafruit Music Maker and the TFT separately. My code for each works as expected. However, when I stack them, I run into the issue of how to call each shield to perform it's task.
The issue is the shield pinouts. The MM uses the ICSP to communicate with the board so all I need are:

MCS pin - set to pin D7
DCS pin - set to pin D6
CCS pin - set to pin D4
DREQ pin - set to pin D3 (also a Mega interrupt pin)

By itself, the MM shield works correctly using these pins, but in order for the TFT to work, the TFT needs pins D2 to D9 to send LCD data. That means I need to reroute D3,4,6, & 7 for the MM so the signals to the TFT are not interfering on those pins.
I noticed those pins have corresponding hole-throughs on the board.

Can I use these hole-throughs to redirect the pins to other digital pins on the Mega?

Yes, you can. However you will need to isolate them from the existing pins.
If you flip the shield over you should see a set of bridged solder jumpers:

You will need to take a small, sharp, craft knife (or something similar) and cut the little track that joins the pads together. If the time ever comes that you want to "undo" that cutting you can just bridge the pads with solder.

Excellent! Let me try that...

That worked! Now I can print to the TFT while the MM is playing. Thanks Majenko!


text:
Push button restarts the arduino
I have linked an external push red colored button to my arduino but when I press it, instead of giving me HIGH or LOW, it resets the arduino. I am a beginner to this stuff so could someone help?

It is odd that you omitted your code and a schematic or image or even description of your wiring but made sure to let us know that the button is red =)

Yes. Change it to a green button and all will be well :P

Why don’t you show (or at least describe) how you’ve connected the button so we don’t have to guess? There are very many ways to connect an external red button to an Arduino.

If your button creates a short circuit between 5V and GND pins... it will certainly act like a RESET.  Let's try to make sure you are not creating a dead short on an Arduino pin so you avoid prematurely killing your controller.

Thank you. Changing it to 3.3 V also does the trick

@SiddharthAgrawal please fix the real issue. Creating a short on 3.3V maybe doesn't reset the Arduino, but in general, shorts are to be avoided. Unless you like fire, sparks,  and/or broken electronics.

Ok I'll add the resistance. Thanks


text:
How do I set up bluetooth to wirelessly control servo's connected to an arduino from my PC?
I have been working on a project that includes two servos, one is on X axis the other is Y, the Arduino takes my cursor's X,Y coordinates over a Visual C# program and translates them through the Arduino and to the two servos in order to effectively control both servo's via my mouse. The problem is that I want this to be a wireless connection from the PC to the Arduino, I've been having so many issues with it, the Arduino has a wireless signal and will connect to my PC, but once I connect the output port to the Arduino serial monitor, tera term, or any other program used in similar ways; the Arduino doesn't receive any output commands from the terminal.
Here's the source code without any bluetooth:
#include<Servo.h>

Servo serX;
Servo serY;

String serialData;

void setup() {

  serX.attach(11);
  serY.attach(10);
  Serial.begin(9600);
  Serial.setTimeout(10);
}

void loop() {
}

void serialEvent() {
  serialData = Serial.readString();
  serX.write(parseDataX(serialData));
  serY.write(parseDataY(serialData));
}

int parseDataX(String data){
  data.remove(data.indexOf("Y"));
  data.remove(data.indexOf("X"), 1);
  return data.toInt();
}

int parseDataY(String data){
  data.remove(0,data.indexOf("Y") + 1);
  return data.toInt();
}

I've tried so many different source codes to set up bluetooth, I'm not sure which one I should put on here. I feel like it could be something with the visual C# application, I don't know if it is properly communicating with the Arduino either.

Does the program you added to the question, work well? I mean, does it works without bluetooth? If yes C# wouldn't be the problem. 2. What Bluetoth device do you use with the Arduino and what with the PC? Show us at least one code where you attempt to use bluetoth. And what are the error coming up with that code? How can we help, when you say "I've tried so many ways, but none of them worked"? We have no glue what happend. 3. The method String::remove() needs a count at the second argument; not a position. I don't think this code works at all.

The program I added does work pretty well, it could be faster but it works without bluetooth. I used a basic HC-05 bluetooth module, I don't have any of the full source codes where I tried bluetooth with this code saved. I tried to simply get my computer to light up an LED through bluetooth with 0 and 1 console commands and that didn't work either, I just need help with setting it up so that my PC can communicate with my Arduino, I'm okay with using something other than bluetooth if thats possible, I don't know what I should do in this kind of situation. Also the code works in practice so idk.

If your PC supports bluetooth, and the distance of the PC and the arduino wouldn't be more than - let's say - 3 meters, then bluetooth is a viable solution. This forum is not meant to provide a solution for you. You have to try youself, or search the internet for solutions. If you have tried something and there are errors, then post here what you've done, what you expect from it and what is not working. Then we could help. This is not a programming service. Tip: If  the serial connection is too slow, it might help if you use a higher baud rate (115200) should work.


text:
Part of Board exploded when Peltier Plate was wired t(o Board
Photos and Screenshots: https://i.sstatic.net/NazA6.jpg
By the way, I used a screenshot that was originally from this post: Have I bricked my Arduino Uno? Problems with uploading to board
Hey guys,
I was trying to wire two TEC1-12706 Peltier plates to my breadboard, and I saw that using the USB connection for power was not enough for both plates. So, I found a 19v--3.9A DC/AC adapter/computer charger and plugged it in to my Uno via the Power Jack port. The Peltier plates were not wired to the board when I plugged it in and everything looked fine, all the normal LEDs on the UNO lit up, etc. Then, I wired a peltier plate to my breadboard. As soon as I did, a part exploded, and grey smoke come out of the "L" light area. I unplugged it immediately. The next day, I plugged the adapter back into the Power Jack port and a screenshot is attached of some observations I made by touching the board. Photos of my Uno are also attached. As you can see, the "Slightly less hot but still burning part" is pretty much destroyed. The "L" light will not light up and as of right now I can't upload any code to it. Might be an unrelated issue so I will continue troubleshooting that, but it is still another observation. The test LED I wired is lit up, so I guess the board can still kinda function? I'm high school student and obviously a complete beginner. Will continue to do research on this. I really want to know what happened. Please help?  Thanks everyone.

Certainly you've blown your 3.3V regulator - probably by blowing the 5V regulator and pumping 19V straight into the 5V section of the board. It's toast.

You did a pretty good job of nuking your board. Gratz.
Basically what has happened: you connected 19V to the input of the 5V regulator (rated at 800mA max) and connected a 12V 50W device to the output.
I have no idea what a peltier will do when under powered, but at 12V it's going to want about 4A. That's 20x more than the 5V regulator can provide (also exacerbated by the massive amount of heat needed to be dissipated to drop 14V) - so it went pop.
In going pop it short circuited. That meant that 19V (or just short of) ended up going into the rest of your Arduino. The 3.3V regulator didn't like that (the bit that looks toasted), and neither will any of the rest of the components on the board.
In short: probably almost every component on the board has been nuked.
The moral of this story: don't connect high powered 12V devices direct to the Arduino. Things like peltier devices need their own dedicated power supply which can be controlled (as you would a motor or relay) through a power MOSFET.

Thanks so much man! This makes alot of sense. You think there's any way of salvaging the board? Appreciate your response.

There is no financial benefit to trying to fix it. The only benefit would be that you know how to fix it. If you fancy learning about component level diagnostics and testing then this could be a fun project. If you just want a working Arduino as cheap and easily as you can, then buy a new one.

Definately will be a Spring Break project for me when I'm finished school. Again, thanks man!

Quick question- if the regulator can supply 800mA and the peltier needed 4A, wouldn't the peltier just been underpowered and nothing happens?

Not with 19v going into the regulator. Yes it would be under powered for a while, until the regulator melted...

The regulator on your Arduino board is Linear regulator. Meaning it translates "excessive voltage" into heat. The analogy is, you need 5v out of 19v, you waste 17v. Even at 800mA, the amount of energy turned into heat is pretty much 17v * 800mA = 13.6w. Imagine how hot it would be if you compare that same amount of energy you pump into the core of 12v - 10w halogen light bulb. Yep so hot that metal wire turns into bright yellow light.