Can't use two SPI devices at the same time

The LedControl doesn't use SPI library but it's using shiftOut internally. So you can't use them both at the same pins as the SPI interface takes over them.

Basically SPI.begin() takes over the control on its pins and that means when you use digitalWrite or pinMode on those pins, it'll be ignored (at least on some of them).

If you add SPI.begin() into the second example (LedControl one) it'll stop working. However you can change pins for LedControl to other (free) pins and it should be working again.

And also there are mixed signals between both devices:

HW SPI wiring:
13  CLK    output
12  MISO   input
11  MOSI   output
9   SS     output

and LedControl wiring is:
12  MOSI   output (not really)
11  CLK    output

Something from the datasheet about alternate pin functions:

  SCK/PCINT5 – Port B, Bit 5
  SCK: Master Clock output, Slave Clock input pin for SPI channel. When the SPI is enabled as a
  Slave, this pin is configured as an input regardless of the setting of DDB5. When the SPI is
  enabled as a Master, the data direction of this pin is controlled by DDB5. When the pin is forced
  by the SPI to be an input, the pull-up can still be controlled by the PORTB5 bit.
  PCINT5: Pin Change Interrupt source 5. The PB5 pin can serve as an external interrupt source.
  MISO/PCINT4 – Port B, Bit 4
  MISO: Master Data input, Slave Data output pin for SPI channel. When the SPI is enabled as a
  Master, this pin is configured as an input regardless of the setting of DDB4. When the SPI is
  enabled as a Slave, the data direction of this pin is controlled by DDB4. When the pin is forced
  by the SPI to be an input, the pull-up can still be controlled by the PORTB4 bit.
  PCINT4: Pin Change Interrupt source 4. The PB4 pin can serve as an external interrupt source.
  MOSI/OC2/PCINT3 – Port B, Bit 3
  MOSI: SPI Master Data output, Slave Data input for SPI channel. When the SPI is enabled as a
  Slave, this pin is configured as an input regardless of the setting of DDB3. When the SPI is
  enabled as a Master, the data direction of this pin is controlled by DDB3. When the pin is forced
  by the SPI to be an input, the pull-up can still be controlled by the PORTB3 bit.
  OC2, Output Compare Match Output: The PB3 pin can serve as an external output for the
  Timer/Counter2 Compare Match. The PB3 pin has to be configured as an output (DDB3 set
  (one)) to serve this function. The OC2 pin is also the output pin for the PWM mode timer
  function.
  PCINT3: Pin Change Interrupt source 3. The PB3 pin can serve as an external interrupt source.
  SS/OC1B/PCINT2 – Port B, Bit 2
  SS: Slave Select input. When the SPI is enabled as a Slave, this pin is configured as an input
  regardless of the setting of DDB2. As a Slave, the SPI is activated when this pin is driven low.
  When the SPI is enabled as a Master, the data direction of this pin is controlled by DDB2. When
  the pin is forced by the SPI to be an input, the pull-up can still be controlled by the PORTB2 bit.
  OC1B, Output Compare Match output: The PB2 pin can serve as an external output for the
  Timer/Counter1 Compare Match B. The PB2 pin has to be configured as an output (DDB2 set
  (one)) to serve this function. The OC1B pin is also the output pin for the PWM mode timer
  function.
  PCINT2: Pin Change Interrupt source 2. The PB2 pin can serve as an external interrupt source.


BLE Mate 2 bluetooth module to Arduino Uno without FTDI SmartBasic

So I found out what I was doing wrong, and want to smack myself for it -.-

The answer was to simply hook up the BLK connection (which I guess is also ground) to a GND pin on the Arduino Uno.

Hope this ends up helping someone out.


Serial Communication between ESP8266 and Arduino ( Sofware and Hardware )

Just adding a little flesh to @chrisl's excellent answer with some added technical detail:

B) Some Tutorial mention that using a voltage divider create some communication interference. It is true and/ relevant for use as explained ?

The problem here is that the resistors and the input pin's capacitance form a low-pass filter. Too high a resistance and you deform the nice clean square wave of the serial data. This limits the baud rate you can reliably use. Reduce the resistor values and you increase the frequency of the filtering, thus allowing higher baud rates, but at the cost of increased current draw from the TX pin.

Does SofwareSerial library is recommended (again - reliability ).

The problem of SoftwareSerial is twofold: it's very much a "blocking" system, whereby the MCU can't be doing anything else when a byte is being either received or transmitted, and it's very picky about timing, partly because of that blocking.  There are two factors that affect the maximum speed you can use: how fast the MCU can process the incoming signal to work out what it is, and how fast the MCU can process that decoded signal to get it stored in the buffer.
While it's possible to receive reliably a byte at 115200 baud the problem comes when receiving multiple bytes rapidly. The Arduino is not always able to take that received byte and store it in the RX ringbuffer fast enough before the start bit of the next byte arrives, so it misses it. This causes corruption in the data stream.
For this reason I never recommend more than 9600 baud (or maybe 38400 at a pinch) to give the Arduino more time to process the bytes as they arrive. However that then means that more time is spent doing the sending or receiving, which blocks the rest of your program during that time for longer.
Also SoftwareSerial is strictly half duplex: when you're receiving you can't send, and when you're sending you can't receive. It's only really of any use in a "call-response" style protocol where switching between sending and receiving is predictable.


How to compose an HTTP GET request URL with key/value parameters

Side question: please explain the difference between const char* host and const char *host if there is one

There is no difference; n.b. the arduino IDE uses C++! If you don't know C or C++ you should learn that first.

  "what is the best way to compose the full URL without hard coding the whole thing?"

This is basically the same question as how do you manipulate, i.e. compose, composite, concatenate, C strings. c string functions

here is a quick example, without error checking, etc.:

const char* host = "http://somehost.com/dir/1";
char* app = "123";
char* user = "123456"
char* api_key = "XXXXXXXXXXXXX";

char urlout[255];

// we are going to start here
strcpy(urlout, host);
strcat(urlout, "/?appid=");
strcat(urlout, app);
strcat(urlout, "&userid=");
strcat(urlout, user);
strcat(urlout, "&key=");
strcat(urlout, api_key);

// urlout == "http://somehost.com/dir/1/?appid=123&userid=123456&key=XXXXXXXXXXXXX"


elapsedTime=millis(); sets elapsedTime equal to the current value of millis(), which in the sketch above is the total time since the Uno powered up.  Thus  elapsedTime will exceed 1000 any time after the first second of execution, in which case the while won't do anything.

Instead say elapsedTime=millis() - StartTime; within the loop.  Whenever you want to start the averaging cycle again, say StartTime = millis();.

If your only use of elapsedTime is to control the while loop, get rid of that variable; instead of  while(elapsedTime < 1000), say while(millis()-StartTime < 1000).


How to make a servo sweep from 0 to 180 on press of a button on PS2 controller? (without delay)

If you already have the code, if you have a good understanding of how it works it shouldn't be too difficult to implement, but you would multitasking it by creating several objects that use a central time value. It should all be here, if you follow them and read them they can explain better than I: https://learn.adafruit.com/multi-tasking-the-arduino-part-1/overview


converting an unsigned integer into a const char pointer

CORRECTED ANSWER
I dug back into my code after a comment from  Edgar and figured out some needed adjustments. My original solution was mostly correct, but there were some inaccuracies that I want to correct so I'm not goofing up anyone else in the future that may find this answer useful.

So I was overthinking things a bit. I still don't know that this is the best way of handling it, but it is working on the client side.
So, c-strings are just arrays of 8bit values with a null terminator at the end.
I want to end up my enum values, and my enums are define with byte enum-bases:
enum messageTypeEnum
{
  REGISTER_CLIENT = 0x04,
  CLIENT_REGISTERED,
  UPDATE_CREDENTIALS,
  ADD_BRICK,
  GAME_FRAME,
  ERROR
};

enum clientTypeEnum
{
  GAMEBOARD = 0x01,
  BRICK_CONTROLLER,
  PLAYER_CONTROLLER,
  TOUCH_CONTROLLER
};

So, to send up my bytes, I can just build a character array, set each byte in little endian order, and manually terminate it:
NOTE: this is the original assembly that was incorrect.
I put the null terminator at the beginning of the buffer thinking "oh, it's little endian so the terminator needs to be at the beginning". Classic sleepy brain mistake :|

void registerAsAGameBoard()
{
  char buffer[3] = {0, GAMEBOARD, REGISTER_CLIENT};
client.sendBinary((const char *)buffer, 3);
}

void registerAsAGameBoard()
{
  char data[3] = {GAMEBOARD, REGISTER_CLIENT, 0};

  const char *buffer = data;
  size_t size = strlen(buffer);

  client.sendBinary(buffer, size);
}

Now when I call sendBinary with my byte array and the length of the buffer my esp32 doesn't crash (hurray!) and the server receives the buffer correctly!!

I need to make a couple of adjustments on either the client and/or server side to account for the fact that the ESP32 is little endian and the server is already coded to receive payloads in big endian, but that shouldn't be too much of a lift.


How do I turn off the blinking cursor/caret in the Arduino IDE?

Note: does not work with version 1.6.11. Works with 1.0.6

Open the Arduino IDE
Go to File
Then go to Preferences
At the bottom of the page is the file location you can enter to set additional preferences
Exit the Arduino IDE
Go to the preferences file location then set editor.caret.blink=false
Then save
Then restart the IDE and the caret will not flash


Remotely uploading code to an Arduino board over the internet

You can upload to your Arduino board over Ethernet if you flash it with a special bootloader named Ariadne.

You will need an Ethernet module or shield that uses the W5100, W5200, or W5500 Ethernet controller chip. You can not use the ENC28J60 Ethernet controller with Ariadne.

You will need an ISP programmer to burn the Ariadne bootloader to your Arduino board. If you don't own an ISP programmer, you can use a spare Arduino board as an "Arduino as ISP" programmer. If you're going to purchase an ISP programmer, I recommend the 6 pin USBasp. The USBasp works well with the Arduino IDE and is very reasonably priced. You can buy them on eBay.

A description of how the Ariadne upload over Ethernet process works:

Compile the sketch you want to upload.
Use avr-objcopy to convert the .hex file of the sketch generated from the Arduino IDE compilation into a binary (.bin) file.
Reset the Arduino board to activate the bootloader code. You could do this by pressing the reset button on the board but the need to have physical access to the board negates much of the advantages of uploading over Ethernet. For this reason, the upload will typically be accomplished by sending a command to your Arduino board which triggers the application to reset the microcontroller by activating the watchdog timer and then allowing it to time out. There is a library named EthernetReset bundled with the Ariadne hardware package for this purpose, but you can easily implement your own solution if you have other needs.
Start a TFTP upload of the .bin file to the IP address of your Arduino board within the 10 seconds that the bootloader is activated after the reset. The upload doesn't need to finish within the 10 second window, it only needs to start.

You can get the Ariadne bootloader, as well as detailed instructions, here:
https://github.com/loathingKernel/ariadne-bootloader


The problem is not that "there is not enough current", but that you can't dissipate enough power.

Let's assume you are powering the board from an external 12V supply. Now, the 5V are obtained from 12V with a resistive regulator: this means that the regulator (see this image if you are interested in knowing what component it is) simply behaves like a variable resistor, dissipating the power in excess. Now, let's assume you want to draw 4A from the 5V rail, since you want to turn on a lot of LEDs and other stuff. Since P=VI, the regulator (that very little component) has to dissipate (12V-5V)*4A = almost 30W. This means that it becomes a little heater and.. Puff! it breaks.

Now, 4A is a really high current, but that regulator can withstand very little power dissipations. According to the datasheet, and estimating a 1cm x 2cm heatsing under it, we can estimate a 25 K/W thermal resistance, which means that each watt you dissipate raises the internal temperature by 25K (=25°C). You can't go beyond 150°C without damaging the component, which means that if your room is at 25°C you can dissipate AT MOST 5W. In practice, never go beyond 3W. Anyway even 5W mean that, at 12V, you can't get more than 5W/7V=0.7A.

By the way, the regulator is rated 0.8A, so you should never go beyond that value in any case.

Now, this was the external regulator. As for the usb, you can't get more than 500mA from that power supply. That's written in the specs. For this reason, a 500mA fuse is on that rail, so going beyond 500mA will blow that one, interrupting your power. Well, that's a self-healing fuse, so after some time (maybe hours?) it will operate again, but.. Don't try that.

In the end, the digital pin current. The atmega datasheet says that

The absolute maximum current per I/O Pin is 40.0mA
The absolute maximum current inside VCC and GND Pins is 200.0mA

This means that from each single pin you can get at most 40mA (but I suggest you never go beyond 20mA), and the sum of all the currents (and the internal peripherals) should never exceed 200mA. So if you need to power 2 leds, you can give each of them 20mA, if you need to power 15 of them you can't (you are limited to, let's say, 10mA). If you need more, use transistors to separate the current paths.


Cannot connect through /dev/ttyACM0 (Ubuntu 18.04)

The board was bad. I just replaced it and it now works.

So, to answer my own question, an Arduino board can show up on lsusb and dmesg and yet be faulty. This is what the dmesg output is for a healthy board:

[10492.388028] usb 1-1.4: new full-speed USB device number 13 using ehci-pci
[10492.500520] usb 1-1.4: New USB device found, idVendor=2341, idProduct=0043
[10492.500526] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[10492.500529] usb 1-1.4: Manufacturer: Arduino (www.arduino.cc)
[10492.500533] usb 1-1.4: SerialNumber: 55736323739351010292
[10492.520354] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device
[10492.520832] usbcore: registered new interface driver cdc_acm
[10492.520835] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

And here is the lsusb output:

Bus 001 Device 013: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)

Judging on the difference with the previous outputs from both commands (when the faulty board was connected), it seems that my board had reverted to the basic Atmel USB interface and that the Arduino specific USB handshake was not working. Can anyone confirm ?


MPU9150 (JEFF LIB) + FIFO_OVERFLOW INTERRUPT + SERIAL PRINT

When I've gotten into a bind with data being generated faster than I can dump it, or the process cannot tolerate the printing delays, I've made a memory buffer to store as much raw data as I can and print it after the test-run. If you're not using a debugger (which can print memory contents), you'll still need to have serial print code in your sketch but it can execute after the you run the code under test. Store the minimum size raw data (to maximize the amount you can store) and do the formatting on your PC.
If you need to be able see what happened prior to an unusual event your code can detect, use a ring buffer (FIFO) in memory and let it wrap around (don't even bother to detect wrap-around). As soon as your code detects the event, print the ring-buffer contents.
It's not continuous capture but often, it's enough.


Is an atmega 2560 board compatible with the Adafruit Trellis?

MIDI comes in many different arrangements.

The two most important ones for you are "MIDI Over USB" and "Traditional Serial MIDI".

The former encapsulates MIDI messages and sends them over USB to the computer. This is what you normally get when you plug in a USB-based MIDI instrument, or a USB to MIDI adapter cable.

The latter is a simple serial port running at a specific baud rate. It's generally opto-isolated as well.

On the Leonardo you can do either of those methods (you haven't mentioned which you use), but on the ATMega2560 you can only do the latter (that is, connect the board to a USB to MIDI adaptor cable).  However the Arduino Mega2560 (Note: this is a board, what you talk about is a bare chip) has a USB interface chip that can be re-programmed to look like MIDI.  That will bridge between the "traditional serial MIDI" to the "MIDI over USB". However doing so may impare your ability to program the board.

Another option is to use some PC-based Serial-To-MIDI bridge software which reads normal Serial data as provided by the Arduino and converts it into MIDI signals within your computer.

A third option is to step away from Arduino and choose a board that has both a native USB interface (with MIDI support in software) and more analog inputs.  A board such as one of the Teensy 3.x range would probably suit you well.


Why does this method return an unprintable character, how do I convert it to display correctly?

Because “h17” is an unprintable character, namely ASCII ETB. The 'h' in “h17” stands for “hexadecimal”, like the 0x usually used in C.

You should convert the value to an ASCII number if you want to print it, using for example Serial.print(payload.crc, 16); or – if you are not using Arduino core – (s)printf().

Edit: here is an implementation of my comment “sprintf() into a
buffer and dump the buffer to UDR0 one byte at a time”:

#include <stdio.h>

void print_byte_in_hex(uint8_t byte)
{
    // Print the byte in ASCII into an internal buffer.
    char buffer[8];
    sprintf(buffer, "%02x\r\n", byte);

    // Send it one byte at a time through the USART.
    for (char * p = buffer; *p; p++) {
        loop_until_bit_is_set(UCSR0A, UDRE0);
        UDR0 = *p;
    }
}


Really stop Arduino is possible, it's called sleep mode, but the UNO is designed so badly with respect to power consumption that you may as well keep it running.

To have it done something at a specific time you could connect a real time clock (RTC) breakout board (SparkFun has a couple). Use a 1 second timer interrupt to read the clock and compare it with (a table of) times where you want things done. A table could hold the time, an output (e.g. for a relay) and the new status (on or off). If you have just a couple of those you can store them in the RTC's battery-backed up RAM.

edit
You can use your PC's time, all the hardware you need is the USB cable. On the PC you run a program that sends the current time to the Arduino. (There are Processing examples of how to communicate with the Arduino on the Net.)

Note that without an RTC your PC will have to be on all the time and connected to the Arduino. You could use the PC just to sync the Arduino's clock and keep time yourself, but the clock of the Arduino is not very accurate.

Getting the time from the Internet is also possible, but then you'll need a Wifi or Ethernet shield to make the connection.


One obvious option would be to get a display with SPI interface, since you have it available. Another option is to get a DAC running on SPI, and use the I2C for the display.

If you insist on using one of these 16x2 LCDs, there are SPI adapters for them as well. Example


Arduino DUE samples per second with the DAC

According to the datasheet:

  2-channel 12-bit 1 msps DAC

So it's possible to generate 1 million samples per second. Of course that kind of speed would need DMA to drive it smoothly.

Assuming you want to generate a sinewave at 40KHz you have to first ask yourself what resolution (time-wise) you want from that sinewave, since that's the frequency that you need to generate samples for. For instance, if you want 100 samples in your sine wave you'd need to generate those at 4Msps, which you can't. At 10 samples per cycle you'd have 400Ksps which is more manageable, but the quality of the sinewave would be pretty poor.

Or, if you don't need a sinewave, if a square wave would do, just use a normal digital IO pin. You can generate MHz then.


Significant drop in speed between Arduino IDE and Visual Studio?

I have it set up to constantly monitor the stream by calling that read method every as an event when data is received over the serial.

I suspect that is the issue. Waiting for an incoming "serial data available" event and then processing it, is likely to be slow. I would rework how you get serial data. You haven't shown that bit but maybe you can use a larger buffer.


Handling double (8 byte) in Arduino mega 2560?

In the Arduino there is no such thing as a double. A double is just another name for a float.

So you will have to either:

Manually interpret the double format data and calculate that into a float value, or
Send the value as some other format, such as float (32-bit), ASCII text, or (a selection of) integer values.

Since you can't actually use anything more than float, sending data with a higher resolution is pointless, so you are probably best off just sending it as a float.


That library is part of the ESP8266 core. It's not for the Arduino, but for programming the ESP8266 as a standalone unit without an Arduino connected to it.


Why the bootloader burn on ATmega328 rather than Atmega16U2 in Arduino Uno

The purpose of the bootloader is to get the firmware through the serial
port and burn it into the flash. The 16U2 has no access to the 328's
flash. The job has to be done in the 328 itself.


Use SD-Card module in combination with MKR GSM 1400

You can free choose pins used by SPI master to select slaves, but if possible use the default expected by the library.

With MKR and other SAMD Arduino boards use the same default SPI slave select pins as for AVR boards, because same libraries are used.

Ethernet library has default SS pin 10 and SD library pin 4.


In ESP-12E NodeMCU, what's the pin number of A0?

The numeric value of A0 is 17, as defined here.

But unlike on an Arduino board, you can't use it as a digital pin. It only work for pin numbers 0-16.

If you are using as a parameter for analogRead, the numeric values would be 0 and 17, as seen here.

And as such, these three calls would do the same:

analogRead(A0);
analogRead(17);
analogRead(0);


What's the most direct way to assign Serial.read() bytes to an array?

@DataFiddler suggested something like readBytesUntil.  In fact, you can just use readBytesUntil.  It returns either when timeout happens or when you reach the specified terminator.  It consumes, but does not include the terminator.  The timeout defaults to 1000 milliseconds, and can be modified with the setTimeout() method.
One downside is that you can't differentiate timeout, full buffer, and terminator reached.  This shouldn't be a problem except for serial transmission errors.
If your data is coming in at the NMEA standard 4800 baud, you could reasonably change the timeout to 5 milliseconds and still work.

One thing that might bite you, is the line:
     rf95.send((char *)c, sizeof(c));

It is a mistake to cast the first parameter.  The error you got indicated you should write:
     rf95.send(&c, sizeof(c));

But the sizeof is also wrong.  The return type of Serial::read() is int, in part because there are 257 possible values.  If you declared c as an int, its size would be 2, not 1.
In any case, if you are using readBytesUntil, you pass the same buffer you passed it to rf95.send(), and the return value from the first as the second parameter of the second.


How would the wiring look like? I was unable to find any dumb-proof
  tutorial online.

I found this tutorial to be pretty usefull.

There really isn't much to it, I suggest trying a short range before going full range.
It's a "half duplex bus system" the ends of the bus should have a "end termination resistor", usually 120Ohms, between the A and B signal.
Since it's half duplex, the Pi and Arduino can't talk at the same time.
You'll have to pull the DE and RE pins high when you want to transmit (and keep them low for receiving).

Basic sketch would be something like:

#define TXEnablePin 13

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

void loop(){
  String data = "";
  Unsigned int sensorValue1 = Sensor.getValue();
  Unsigned int sensorValue2 = Sensor.getValue();
  data += str(sensorValue1) + ":" + str(sensorValue2) + ";\r\n";
  send(data);
  delay(10000);
}

void send(String data){
  digitalWrite(TXEnablePin,HIGH);
  delay(1);
  Serial.send(data);
  Serial.flush();//Wait for everything to be transmitted, before disabling transmitter.
  digitalWrite(TXEnablePin,LOW);
}

  I don't know whether or how to use the logic level shifter.

These things are pretty straight forward. You should actually be able to figure it out yourself (given you have the power of the internet).

LV to 3.3V of Pi
GND to GND of Pi
GND to GND of Arduino
HV to 5V of Arduino

Then, whatever 5V signal you want to connect to HVx and whatever 3.3V signal you want to connect to LVx

Example:
Arduino-TX -> HV1
Arduino-RX -> HV2
Pi-TX -> LV2
Pi-RX -> LV1

  If I can read the data over serial port, would it be just a plain text
  (as shown on PC in Arduino ide serial monitor), or has each value its
  address that I could then easily accessing to a variable then being
  used to process the weather data?

It would be ASCII (plain text) if you send strings.
You could make different types of requests.

Like; If you send: "Temperature" to the Arduino, it will respond with: "TEMP:10" or something.

But the easiest thing would be to send all values of all sensors in a combined string every 10 seconds or so. And let the Raspberry Pi unpack that string.

  If I'm completely wrong in something, or there's some completely
  different way how these things are being done by more experienced
  people, I'd love to hear some suggestions.

I think it's pretty good that you actually already know of the existence of RS485 and why you'd want to use it.

But I also feel that you feel a little uncomfortable with the project as it is.
It's important to handle problems one by one, to avoid getting overrun by problems.
Try to make it working over (short) USB first. Then try a short RS485 link and eventually try a long RS485 link. You can then more easily spot where the problem is. Use facts from multiple tutorials, to boost the confidence you have in the system ;). It may just work if you wire it as said. If it doesn't work, you can always post a question.

If possible, it may also be worthwhile to follow some tutorials on Arduino (get a starter kit and book with tutorial projects?). Within these tutorials they give examples of problems and show what there is to solve them. Without throwing yourself into a dark pit of a project.


WiFi problem on Mega + WiFi R3 ATmega2560 + ESP8266

I had this problem. On Robotdyn D1 mini the esp8266 flash erase did help. On Robotdyn D1 R2 only the flashing of the AT firmware with Espressif Flash Download Tool restored the esp8266. After then the sketches from IDE had working WiFi.

There are some settings of the Espressif basic esp8266 libraries (SDK) saved on flash and there is some incompatibility between SDK versions. The Flash Download Tool creates right esp settings binary and flashes it to right address on flash.


What it sounds like you want is an Arduino Due footprint prototyping shield.

Arduino make one, although it is out of stock, but it gives you an idea of what you are looking for. There are plenty of other designs out there for purchase of varying degrees of complexity.

You solder the pins in place and mount it on top of your Due just like any shield, and solder your wires and components in where you want them.

An alternative option, of course, is to step away from Arduino and investigate some of the many other chips from other manufacturers out there that are considerably more powerful than the 8-bit ATMegas used on the low-end Arduinos, and yet are still available in a DIP footprint - chips like the PIC32MX1xx/2xx series from Microchip - 28 pin DIP (just like the 328P) yet 50MHz, 32-bit power.  Yes, it will be a bit of a learning curve, but there are helpful options out there that can assist you, like the chipKIT system including the handy DP32 board from Digilent.


Personally I don't think Nick advised to do command line pattern parsing with a state machine. His example is about changing a state machine based on command line input.
I have written some command line parsers and I never used a state machine to do so. I would not advice to use a state machine to do so.
Simple string parsing is far easier.

Edit To answer the remark below:
I would not advice to go byte by byte. I'd advice to go the line by line way.
I have written a library to do read line by line and an article on how that one works. http://blog.baeyens.it/#post16
Here a link to the lib https://github.com/jantje/libraries/tree/master/SerialCommunicator.
Here is a parcing code example. It is not so interesting for you as I have it done in a stage by stage way in a very high level way of coding.
https://github.com/jantje/libraries/blob/master/SerialBridgeCommunicator/SerialBridgeCommunicator.cpp#L21

Basically the algorithm is=
1 Take the first word;
2 identify the word.
3 If the command is complete ->do it
 else Send the rest of the string to a specialized piece of code. (which has the same algorithm)


Computer shutting down is often an indication that excess power is being drawn.
If you measure  between +5 and Gnd on the unpowered board with a meter set for resistance, do you get a reading in the 5Kohm range? Or something much lower? Much lower would be bad.


How to send data from a smartphone to Arduino

I have been using a bluetooth module - they can be had for just a few dollars (depending on which country you're in). I've got an HC-06 which works great : http://www.dx.com/s/hc-05

It has 4 pins: VCC (connect to +5V on Arduino), GND, RX and TX (connected to RX and TX, digital pins 0 and 1 on the Arduino).

You will probably not be able to use Bluetooth and USB at the same time - both will be sending to the Arduino at the same time, and the communications will get garbled.

I have an app called "Bluetooth Serial Controller", which lets me send commands over bluetooth.

If using this, think carefully about what will happen if your phone goes out of range of your arduino.


Is this circuit properly made?

No.
A lot of the problem is that you don't have a well-drawn schematic. I think that what you have is a couple of voltage dividers to interface a 5V arduino with a higher voltage device. I suspect a voltage divider isn't the best solution but presumably it works for someone else. So what you need is ...

simulate this circuit – Schematic created using CircuitLab
If I were you I'd pull your existing wiring apart completely and start again, arranging the components and wires so that they match this schematic as closely as possible in terms of position and orientation. Then trace the connections through carefully to make sure everything matches.


It's explain in the datasheet.

  A VCC1 terminal, separate from VCC2, is provided for the logic inputs to minimize device power dissipation. (pg. 2)

VCC1 is for the logic and VCC2 is for the motor supply.

The four grounds are all tied together internally and act as a heatsink for the chip. (pg. 11)


Arduino: Record value of the encoder only once at the instant the PS2 joystick reads 128 (when at rest)

If you only want to catch this event once - when it first hits 128, you just need a global variable to flag when you've seen it:

boolean g_bSeen128 = false;

void setup()
{
    // ... whatever
}

void loop()
{
    // ... your existing code

    // catch first time we see 128
    if (!g_bSeen128 && Y_axis == 128)
    {
        // ... do whatever you need here. e.g.
        Setpoint = encoder0Pos;
        myPID.Compute();
        analogWrite(pwm, Output);

        // stop the event being caught next time
        g_bSeen128 = true;
    }

    // from comments below - to just ignore consecutive 128's, add this:
    if (Y_axis != 128) g_bSeen128 = false;

    // ... your existing code

}

If you only want to do something if the input changes, no matter what it is, you can keep track of the last input:

int g_nLastInput = -1;

void setup()
{
    // ... whatever
}

void loop()
{
    // get input
    int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);

    // if input has changed ...
    if (Y_axis != g_nLastInput)
    {
        // ... save latest input
        g_nLastInput = Y_axis;

        // now process the change, e.g.
        if (Y_axis == 128)
        {
            // ... do something special for 128
        }
        else
        {
            // ... do something else for other inputs
        }
    }
}

I'm not sure what you're trying to do with the PWM when you get inputs either side of 128, it seems to me that you might want to go in one direction if the input is less than 128 and go in the other direction if it's greater than 128. In either case, the magnitude of your PWM speed should just reflect how far you are from 128 in either direction. So subtracting 128 from your input will give a delta that is +/- 128 and we can scale its absolute value to 0..255 for the PWM setting.

If that's correct, an alternative way of coding your original logic might be like this:

void loop()
{
    // get input
    int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);

    Input = encoder0Pos;

    // if input has changed ...
    if (Y_axis != g_nLastInput)
    {
        // ... save latest input
        g_nLastInput = Y_axis;

        // now process the change
        int nDelta = Y_axis - 128;

        if (nDelta == 0)
        {
            // i.e. Y_axis is 128
            Setpoint = encoder0Pos;
            myPID.Compute();
            analogWrite(pwm, Output);
        }
        else
        {
            // choose direction
            digitalWrite(dir, (nDelta > 0) ? HIGH : LOW);

            // set PWM speed scaled to 0..255
            analogWrite(pwm, abs(nDelta) * 2);
        }
    }
}


How to connect an industrial sensor to Arduino Uno?

That uses the industry standard 4-20mA current loop system. For that you really need a special chip to interface it.

You can buy shields that interface to 4-20mA current loops.


Check my project: "Esp 2 Python"

https://github.com/KebabLord/esp_to_python

The theori is you can create a localhost and get the sensor data or manage the module through arduino requests or urllib modules with a simple local mDNS server. This project allows you to control and read ESP.


I see you are using an Arduino Uno.

An Arduino Uno cannot act as a USB keyboard - therefore the Keyboard library doesn't exist for it (the file Keyboard.h is seen as being empty).

You can only use Keyboard.h on boards where using Keyboard.h makes any kind of sense, such as the Leonardo.


How to properly handle the Arduino String

+1 to @majenko's comments. I tend to avoid the String class, as I like to know what is actually going on, and I stick to char * and char [] in general (and the stdlib functions like sprintf, strlen, etc).
Couple of notes on your question:

"foo/bar" is fine. Some characters have special meanings in the C language itself, so you need to escape them with the \. For example if " was part of your literal string, you'd write "foo\"bar\""

I tend to use ArduinoJSON to parse. If my app is just sending JSON payloads, I just build it with sprintf or print which results in smaller programs. But, I guess it is a matter of choice. It is a great library.


The fonts are the little bitmaps starting at line 50. Each 16 bit value is 1 column of the letter to be printed. There are 10 columns of pixels per character (the rowsPerChar value). The least significant bit is the bottom row.

So to change the font all you need to do is change those bitmaps.


ESP8266MOD programing using Arduino uno?

When you use the Uno for its UART only, i.e. grounding RST pin, its Rx pin 0 becomes Tx, and Tx pin 1 becomes Rx -- because that's what pins on the UART you are connecting to. AppMonk didn't say what specific breakout/ chip mount he's using, there are many, or say how he's managing level-shifting from the Uno to the ESP if needed. The Tx pin on Uno (0, labeled Rx) is putting out 5v and the ESP would prefer 3.3, so level shifting w/ simple voltage divider is recommended. You don't need to level shift the Tx signal from ESP to Arduino's Rx (pin 1).


The ESP8266 only has one ADC pin. You can:

Use an analog MUX to switch that pin between different signals
Connect an external I2C ADC chip
Connect an external SPI ADC chip
Connect the ESP8266 to another MCU (such as an Arduino) and get that to do analog readings.


Some solutions that have worked for me:

Reserved IP - use the router's DHCP reservation to give the same ESP the same IP each time.
Static IP - Set the ESP to use the same IP each time, bypassing the DHCP feature altogether. This also boots the ESP slightly faster. WiFi.config(ip, gateway, subnet);
Dump the IP address to Serial on boot, so that you can at least see what's assigned: Serial.println(WiFi.localIP());
Give the STA a unique name that you can find in the router's DCHP clients page: WiFi.hostname("look_here");
use mDNS to assign a domain-like local URL to the device: MDNS.begin("esp8266");// default to "http://esp8266.local/"


How to connect Sparkfun M6E Nano UHF Rfid reader and ESP8266 NodeMCU 0.1

The interface of Sparkfun M6E Nano UHF Rfid reader is Serial TTL. So you should connect it to Serial pins of the NodeMcu. Don't use USB then, because it is connect to Serial too.


LCD displays bad character while counting rotation

I suspect you get electrical noise on the leads from the optocoupler. A few test to help find cause:
1) Does the counter work if you rotate it by hand?
2) Does the LCD go funnny if you just have the optocoupler approximatly in the same position, but not count anything.


ESP8266 + Arduino Uno: Can't send AT Commands

Tx and Rx should be crossed; meaning connect Arduino Tx to ESP Rx and vice versa.

Your second (and first) attempts are correct. Use 1uF capacitor between Vcc and Gnd. This will provide a more
robust connection since the ESP can draw too much current which might cause it to reset.

When using external power supply, hook together the Arduino Gnd to the PS Gnd.

If you get "Programmer is not responding" - disconnect and reconnect the Arduino USB. Also, you shouldn't get this at all since you are not trying to program the Arduino, just use its FTDI as proxy to the ESP. Any serial terminal application can do it (you don't have to use the built-in terminal in Arduino IDE).


Arduino Mega not recognized on Raspberry Pi 3b+

The newer Arduinos, like the Uno or Mega 2560, have a different way of managing the Serial ↔ USB translation, compared with the older Duemilianove. From the Linux side, you shouldn't see much difference, except that the device is now /dev/ttyACM0 instead of /dev/ttyUSB0.


The boards in your link look funny.  Typical boards like this include the "bluetooth circuit" which piggy-backs onto that board, and is soldered at all those little pads.

Have a look at say, the HC-05 board ~  https://www.google.com.au/search?q=hc05+bluetooth+module&tbm=isch

It's easy to see the part that's missing from the one in your link.

For these HC-05 boards, it's possible to pair two together.  They need to be configured as "Master" and "Slave" though.  Some bluetooth boards can do slave-mode only, so be careful before you purchase.


Ok, first, char varAT[12] indicates an array of 12 characters.

Second, quotes indicate literals - 'A' means, literally, the character 'A'. Variables and constants are without quotes (same way you use  i).

I think you mean:

char *varAT[12]={A,B....};

Also, your constant B is invalid - I think you meant for it to end in \r", not \".


Reading a string from Firebase and storing it as a CString

In returning a String object the Firebase first generates that String object and copies the C string data into it.
If you want to get at the raw C string data you will have to look at adding a new "getter" to the library to return the pointer to that C string data:
I'd write it for you, but since you posted a screenshot of the Firebase function, and the change from that code to the new code is very minor (just change the function name and the return type), I can't copy-and-paste it. And I'm not going to peer at that little image and type it all in again.
Incidentally, internally the Firebase library actually uses std::string, which is a better implementation of the same thing that String does. String was created because the Arduino compiler has no STL, and hence no std::string. Either way they both use dynamic allocation.


How do I recover a beetle where I loaded a program that was too large and overwrote the bootloader?

I don't know the Sloeber toolset, but it seems very unlikely, that it really has overwritten the bootloader. When programming via USB, it is actually the bootloader, which writes the program into the flash memory. So that would mean, that the bootloader had overwritten itself, only because a too large program. Not sure, if this is even possible.
Anyway, you can utilize an ICSP/ISP programmer (or another Arduino, if you don't have one) to burn the bootloader onto the chip again. Google for Arduino ISP to get instructions for it, there are plenty of tutorials.
You need to connect the correct pins on the Beetle with the ISP programmer. According to this site, you should find the ICSP pads at the back of the board (the group of 6 pins in 2 rows). Through these pins you can burn the bootloader.
If that doesn't work either, the problem lies somewhere else. As I already stated, overwriting the bootloader because a program is too big for the MCU should not happen and it is highly unlikely, that this is really your problem. You might have damaged something on your board, though we cannot tell that from the description. So you could just try to burn the bootloader and see what happens.


In the SIM900 is an AT command that let you do a factory reset, your module will restart to the default values. It must be an AT command very similar to the SIM800.

The AT commando that (perhaps) will work for you is the ATZ, in the SIM900 works for me.

You can look over here to see what command is. Look over page 33. And be carefull, the link that I send to you is the AT command list for the SIM900, not the SIM800.

Hope you can find an answer.


Use an Arduino Mega in a incubator (high humidity)

"-40 °C to 85 °C" for the processor, yes, for the other parts, who knows?

The board doesn't get that hot unless you are powering from like a 12V source, and then it's just the regulator that gets hot.

You could a spray-on conformal coat, Mouser.com carries them. Insert any wires into the headers you will use and cover any headers you may want to use before you spray, if you get coating down into the female headers you may have poor contact later on.

The ziplock bag idea sounds like a good start as a start, put some silicon along the seal to fill the holes where the zipper won't close right next to the wires.


How to connect 10 coin vibration motors to UNO?

I would suggest a pair of ULN2003 chips.  These are 6 darlington transistors in a single chip.   Two chips will give you the ability to connect 12 motors.
Each one needs an IO pin to control it - if you want speed control then you will have to look into adding extra PWM channels. For just ON/OFF control any IO pin will do (even analog ones).
10 motors running at the same time will be up near the limit of the Arduino's 5V pin current supply, so you really should consider a separate external 5V power supply (maybe a USB phone charger) of 1A or more to power everything (connect the power supply to the motors and the 5V pin of the Arduino).


Where is CLKPR located on Ubuntu 16.04 with Arduino 1.8.3

grep is the command you want:

foo@bar:~/arduino-1.8.2$ grep -r CLKPR .
Binary file ./hardware/tools/avr/avr/lib/avr35/crtattiny167.o matches
Binary file ./hardware/tools/avr/avr/lib/avr35/crtat90usb82.o matches
Binary file ./hardware/tools/avr/avr/lib/avr35/crtatmega8u2.o matches
...
Binary file ./hardware/tools/avr/avr/lib/avr5/crtat90pwm161.o matches
Binary file ./hardware/tools/avr/avr/lib/avr5/crtatmega649p.o matches
Binary file ./hardware/tools/avr/avr/lib/avr5/crtatmega168pa.o matches
./hardware/tools/avr/avr/include/avr/io90pwm216.h:#define CLKPR   _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom329.h:#define CLKPR   _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom165p.h:#define CLKPR   _SFR_MEM8(0x61)
...
./hardware/tools/avr/avr/include/avr/iom48p.h:#define CLKPR _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom644pa.h:#define CLKPR _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/ioa6289.h:#define CLKPR _SFR_IO8(0x3C)
./hardware/arduino/avr/bootloaders/caterina-Arduino_Robot/Caterina.h:       #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
./hardware/arduino/avr/bootloaders/caterina-LilyPadUSB/Caterina.h:      #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
./hardware/arduino/avr/bootloaders/caterina/Caterina.h:     #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

So it's defined in the IO header for the chip you are using (hardware/tools/avr/avr/include/avr/io[chip].h). So for the '328p that's hardware/tools/avr/avr/include/avr/iom328p.h.


No, you cannot use one pin (or set of pins) for two functions like that.

To communicate with two serial devices you will need two serial ports. It's possible to (just about) emulate one in software using the SoftwareSerial library. It's not wonderful though - personally I would use a chip that has multiple UARTs in it.


My Arduino Ethernet shield is not working

If your Arduino can not get an IP address, it could be because there is a problem with your code, your shield or your network.

There doesn't seem to be a problem with your code from a quick glance, so let's look at the network.

The cable. Are you using the right sort of cable? You should be using a Cat5e straight through cable. Cat5e is the type of cable for Ethernet, if it is plugged into the router and you didn't make it yourself, it is probably either a CAT5e or CAT6 cable, so it will be OK. There are two types of cable and they are almost impossible to tell apart, the normal sort is a "straight through" cable, which means the Transmit and Receive pins at one end go to the Transmit and Receive pins at the other end. The other sort is a "crossed" cable where the Transmit goes to the Receive, this is for connecting a computer to a computer.  Since you are plugging to a router you should have a straight cable, if in doubt test it with a working device, ie plug it into your PC.
DHCP - I see from your PC output DHCP is enabled on 192.168.1.1 and I guess this is your router. A DHCP server needs to know what addresses it can give out to devices, these addresses are called "the DHCP pool". If you have no more free addresses in the pool then you can't connect anymore devices. It sounds like you haven't restricted your pool, but it might be worth logging onto your router and seeing if you can see what addresses are in the pool or range.
MAC Filtering - For security some routers only allow certain MAC addresses to connect to the router and request a DHCP address. If you have it turned on then add your MAC address to the white list. If you don't have it turned on, don't worry.
Speed - I suspect that your shield has a maximum speed of 10MBs. Most modern networking equipment only supports 100/1000MBs so the shield just won't work with your router. Your router should have the numbers near the wired sockets to confirm or deny this.

If none of that works the you are going to need to see if you can read the data from the shield and see if you can work out what is going wrong. You will need a network snooper like WireShark and a HUB. An Ethernet switch will not work, it must be an Ethernet Hub, because switches don't rebroadcast the data on all ports. If your PC has two network cards you could set it up as a 'bridge' and you can snoop on the data as it passes across the bridge.

Sorry if some of these terms are confusing, but you should be able to Google them and get a better explanation than I can give you in the space here.

One final thought: are you running the Arduino from a battery? If so it might be worth using a mains supply, because the battery might not be able to support the Ethernet transmissions.


Arduino Due - using built in ADC as a DSO causes issues at high frequencies (kHz)

Well, if you have source output impedance about 1k and Sample-And-Hold capacitance is 14pF, then RC time constant is about 14us.

You need something with low output impedance. Non-inverting Voltage Follower would be perfect for this (see source):


I tested with 100 chars string

const char*

Sketch uses 1566 bytes
Global variables use 288 bytes

with F macro

Sketch uses 1594 bytes
Global variables use 188 bytes

progstr <101> ps(...

Sketch uses 1618 bytes
Global variables use 288 bytes

const char* ps = pstr("...

Sketch uses 1502 bytes
Global variables use 188 bytes

the pstr version string has errors at the end, when printed.

sorry, the pstr function works only if previous sketch version put the string into flash memory. it is not in hex file.


Yes, looks good to me. That looks to be identical to the "Application Circuit" on page 2 of the datasheet you link to.


How to program a CLK signal and its inverse with Arduino/AVR

How about this?

void setup()
  {
  // Defining PB1 and PB2 as outputs by setting PORTB1 and PORTB2
  // Setting DDB1 and DDB2
  DDRB |= bit (DDB1) | bit (DDB2);

  // stop timer 1
  TCCR1A = 0;
  TCCR1B = 0;

  TCCR1A = bit (COM1B0) | bit (COM1B1)  // Set OC1B on Compare Match, clear
                                        // OC1B at BOTTOM (inverting mode)
         | bit (COM1A1)                 // Clear OC1A on Compare Match, set
                                        // OC1A at BOTTOM (non-inverting mode)
         | bit (WGM11);                 // Fast PWM, top at ICR1
  TCCR1B = bit (WGM12)  | bit (WGM13)   //       ditto
         | bit (CS11);                  // Start timer, prescaler of 8

  // Initialize OCR1A = 300 (pulse_width = 150us), OCR1B, and ICR1
  ICR1 = 0xFFFF;
  OCR1B = 299;
  OCR1A = ICR1 - OCR1B;

  }  // end of setup

void loop()
  {
  }

Results on a Uno:

Output on Uno pins 9 and 10.

Change the prescalers and counters to your desired frequency.

The screenshot doesn't show one signal exactly the inverse of the other. The pattern is inverted. If you had a 50% duty cycle, it would be an exact inverse.

  It looks good except they overlap (slightly) by 50ns. If I set them to 16 and 8, respectively, they don't overlap but they are slightly asymmetrical

OK, make OCR1A and OCR1B both 7:

  ICR1 = 15;
  OCR1B = 7;
  OCR1A = 7;

Why 7? And why 15?

The counts are zero-relative. So by counting to 15 on a 16 MHz processor we are actually getting 1/16th of the clock, namely 1 MHz. And half of that is 8 (which, zero-relative, is 7). So we are really doing:

Period: 16 ticks of the 16 MHz clock
Duty cycle: 8 ticks of the 16 MHz clock

Now, one cycle:

They change over at the same instant - pulse width exactly 500 ns.

And they change back at the same moment - pulse width also 500 ns.


I hope you resolved your issue by now, but I had the same problem with an Arduino UNO/nRF24l01+ combination and this question was one of the search results.
In my case, the write() call returned false, but the receiver received the message.
As soon as I added one of the ubiquitous Adapter Boards into the mix the write() call started returning true.
My uneducated guess is that the sending and then the switch from transmit to receive and then waiting to receive the ACK used a bit too much power or something like that.
In any case, even though everyone recommends adding a capacitor and I had the adapter boards on hand, I had thought to tough it out without one and see how far I could get.
I kicked myself for the wasted time, but I learned a lot in the process and I'm having a lot of fun with the transceiver boards now. I'm glad that I didn't just shrug and say "well the message got through so who cares?"


int currentLED

You are missing a semicolon there.

void setup();

There should not be a semicolon here.

Do some tutorials on the C or C++ language. They will help you.


Using an ESP8266 with an Arduino Uno - can't get AT command to work

After writing such a long question, hopefully this is useful to someone else: After changing the logic converter channels (not sure why the first two weren't working) I was receiving AT as output - the only thing I needed to do after that was change No line ending to Both NL & CR and I am receiving AT OK now.


use D5 and D6, not 5 and 6. D5 is IO 14, D6 is IO 12. IO 5 is D1 and IO 6 is SDIO_CLK for the flash memory and that is your problem.

the reference


I had this same issue with an ESP8266 NodeMCU-12E using Cayenne in the past. It would drop connection for no apparent reason, but no matter what, most of the time it'd never reconnect until a reset. Here's what I did:

CAYENNE_DISCONNECTED(){
  Serial.println(F("Cayenne disconnected, rebooting..."));
  ESP.restart();
}

I've never used Blynk before, but after a quick look, this may do the same thing (untested):

if (! Blynk.connected){
  Serial.println(F("Blynk disconnected, rebooting..."));
  ESP.restart();
}

It effectively reboots the ESP unit if the connection to Blynk drops for any reason.


Make arduino board controler for watering system with power bank

Is it possible? Yes.
Is it easy? Maybe.

A relay shield or similar would allow you to break the power connection from the solar panel to the power bank input, wait 5 seconds and then connect the power bank output to the pump.
Once you are done with the pump you could disconnect power from it and reconnect the charging power.

That is all fairly straight forward, maybe a dozen lines of code and some very simple wiring.

The issue is where does the arduino get power from? Or more accurately how does the arduino maintain power during the transitions between different power sources. How much of an issue this is depends a lot on how quickly the power pack transitions from charging to outputting and back and how you want the system to behave overnight or other times when there pump is idle but there isn't much sun light.

Also have you done a power budget? How much power does your pump take and how much power does your solar panel output under normal usage? Based on those two how long per day can you run the pump for assuming an ~80% efficient battery pack.


where does access point's IP address come from for sketch AP_SimpleWebServer.ino in Github WiFi101 examples

If you look into that github source code, you can see startAP function and mainly rows with strM2MAPConfig.au8DHCPServerIP:

uint8_t WiFiClass::startAP(const char *ssid, uint8_t u8SecType, const void *pvAuthInfo, uint8_t channel)
{
    tstrM2MAPConfig strM2MAPConfig;

    if (!_init) {
        init();
    }

    if (channel == 0) {
        channel = 1; // channel 1 is the minium channel
    }

    // Enter Access Point mode:
    memset(&strM2MAPConfig, 0x00, sizeof(tstrM2MAPConfig));
    strcpy((char *)&strM2MAPConfig.au8SSID, ssid);
    strM2MAPConfig.u8ListenChannel = channel - 1;
    strM2MAPConfig.u8SecType = u8SecType;
    strM2MAPConfig.au8DHCPServerIP[0] = 0xC0; /* 192 */
    strM2MAPConfig.au8DHCPServerIP[1] = 0xA8; /* 168 */
    strM2MAPConfig.au8DHCPServerIP[2] = 0x01; /* 1 */
    strM2MAPConfig.au8DHCPServerIP[3] = 0x01; /* 1 */

    if (u8SecType == M2M_WIFI_SEC_WEP) {
        tstrM2mWifiWepParams* wep_params = (tstrM2mWifiWepParams*)pvAuthInfo;

        strM2MAPConfig.u8KeyIndx = wep_params->u8KeyIndx;
        strM2MAPConfig.u8KeySz = wep_params->u8KeySz;
        strcpy((char*)strM2MAPConfig.au8WepKey, (char *)wep_params->au8WepKey);
    }

    if (m2m_wifi_enable_ap(&strM2MAPConfig) < 0) {
        _status = WL_CONNECT_FAILED;
        return _status;
    }
    _status = WL_AP_LISTENING;
    _mode = WL_AP_MODE;

    memset(_ssid, 0, M2M_MAX_SSID_LEN);
    memcpy(_ssid, ssid, strlen(ssid));
    m2m_memcpy((uint8 *)&_localip, (uint8 *)&strM2MAPConfig.au8DHCPServerIP[0], 4);
    _submask = 0x00FFFFFF;
    _gateway = _localip;

    // WiFi led ON (rev A then rev B).
    m2m_periph_gpio_set_val(M2M_PERIPH_GPIO15, 0);
    m2m_periph_gpio_set_val(M2M_PERIPH_GPIO4, 0);

    return _status;
}


The problem had to do with data types.  I was using an unsigned int as follows:

unsigned int addr = 0;
EEPROM.write(addr,5);

However, EEPROM.write requires an int, not an unsigned int, and this caused a compiler error.


I am assuming that you want to make a clock. To do that you need to find a gear ratio where 1 revolution of the motor equals 60 seconds, and then make the gear ratios for the minutes and horse from that. Then you can use the RTC to spin the motor by 6 degrees every second. If you are not making a clock, please be more descriptive.


How to directly solder wires to protoshield to connect them to Arduino pins

For the signals, get some AWG30 wire and solder them underneath to the female header pads. For power, get some AWG22 or AWG24 wire and solder them to the top of the male header pads.


Looking for circuit diagram for evaluation of a pulsed signal

I found a user manual at AMPIRE Car Alarm System for High-Speed CAN-Bus.

  N1/9 BROWN/WHITE – 200mA (-) Horn honk output:

  This wire supplies a 200mA (-) output that can be
  used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed
  and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the
  vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used
  to interface with the vehicle’s horn circuit.

  IMPORTANT!
   Never use this wire to drive anything but a relay or a low-current input! This transistorized output can only supply (-) 200mA and connecting directly to a solenoid, motor or other high current device will cause the module to fall

Judging by that this output will sink up to 200 mA. You could conceivably set an Arduino pin to INPUT_PULLUP and let this output drive it low to indicate it is active.

Personally I think I would use an optocoupler, in case there were unexpected voltages on that pin. You would need a series resistor to limit current through the LED in the optocoupler, say 1 k would be about right if you were connecting it to the 12V car system.

Vf = 1.2V (say)
Voltage over resistor = 12 - 1.2 = 10.8 volts
Current through LED = 10 mA
Limiting resistor = 10.8 / 0.01 = 1080 ohms

Now the output of the optocoupler can sink your Arduino pin, which you have configured as input pullup.

Write a test sketch to see what you are getting through it, but a multimeter should probably tell you, if it just flashes it slowly.

Suggested schematic:


Playing Melody with Tone() without using delay()

As others have noted, this can be done using the same method as used in the standard 'BlinkWithoutDelay' example sketch, and combining that with a state-machine type approach. In a simple state machine you'd assume you can be in one of two states: outputting a tone, and not outputting a tone.

Applying these ideas to your code snippet above:

// BEFORE SETUP
const int tonePin = 8;
unsigned long previousMillis = 0;
const long interval = pauseBetweenNotes;
const long interval = noteDuration;
boolean outputTone = false;                // Records current state

// IN LOOP
unsigned long currentMillis = millis();

if (outputTone) {
// We are currently outputting a tone
// Check if it's been long enough and turn off if so
    if (currentMillis - previousMillis >= noteDuration) {
        previousMillis = currentMillis;
        noTone(tonePin);
        outputTone = false;
    }
} else {
// We are currently in a pause
// Check if it's been long enough and turn on if so
    if (currentMillis - previousMillis >= pauseBetweenNotes) {
        previousMillis = currentMillis;
        tone(tonePin, melody[thisNote]);
        outputTone = true;
    }
}


Arduino Uno's RX and TX lights not blinking. Unable to upload sketches!

Pin 13 light blinks thrice before getting stable.

It is supposed to do exactly that. See What happens when code is uploaded using the bootloader?

  RX TX lights are not blinking at all.

That's not so good. See Have I bricked my Arduino Uno? Problems with uploading to board


How to save data in arduino when it's power goes off

Look up EEPROM. it is a memory that saves content even though power is off.

You can write data in EEPROM and when power comes back read it back.

there are safe ways to write in EEPROM without corrupting it.


Arduino MKR GSM 1400 fails to start up without Serial Monitor

while(!Serial) {} will wait for a serial connection and in your program will block execution until it gets one.
Remove it and your program should continue without the serial monitor.


The project that you show as your reference : link in your question,  shows this picture :

Change R1 to 200 K ohms.   The Arduino will receive 4.76 volts when the input is 100 volts.

You will also need to change your program line for float R1 = 100000.0;

CAUTION :  Beware of high voltage.  Also, the Arduino is not isolated from the 100 volts.


Arduino 1 can somehow support 32-bit audio?

First of all,what is the point of this? I'm afraid this is a XY question. You won't get that good of quality with Arduino. If you're hoping to create some sort of an amp, learn electronics and do that directly. Maybe you should just send data via serial.

Anyway, that aside, here's a chart I drew:

(Excuse my poor image alignment, PowerPoint was being a little mean today)

The bottom is all the "channels" the PC can send. The top is all the "channels" the Arduino can recieve. As you can see, there's a huge degradation in quality. Not to mention, I made this that 1 bit = 1 "channel," yet it's very much more than that.

A standard Arduino (Uno, Leonardo, etc.) has a 10 bit ADC that can read values 0-1023. The computer can output 0-4294967295! (It' exponentially grows due to permutations). You can see why I very much simplified my chart! :P

DSP won't really work well, unless you are trying to do some weird alien sounding modifications or a cheesy echo to. You probably will want to add an external 32 bit ADC. I would recommend, additionally, adding a Due or Galileo that can process 32 bit integers without emulating a bigger chip, thus greatly reducing performance and giving you a low framerate.

tl;dr: It'll work fine, but it'll have horrible sound quality. You can't send the same 10 bits until 32, since the computer changes that 32 bits into a voltage (sent to Arduino), and the Arduino translates that voltage into 10 bits.


Perhaps you should look into here
https://github.com/arduino/Arduino/wiki/Build-Process

Arduino uses avr-gcc compiler. Basically, it is a C compiler.

There is an step by step on how to customize this process using an avr-gcc compiler of your own here
http://www.wikihow.com/Write-Arduino-Software-in-C

But I best recommend you downloading the arduino IDE on the official website to get things going. It has all the serial pairing stuff you don't really need to know to get started.

Hope it helps.


AT Commands HM10 BLE Module - Not working

You changed the baud rate that the Bluetooth module uses to communicate with your Arduino but you forgot to change the baud rate that the Arduino uses to communicate with the Bluetooth module. These must match. From consulting the SoftwareSerial library's reference page, you can see that is set by this line of your code:

BTSerial.begin(9600)

That sets the software serial communication rate at 9600 baud. You need to change it to this:

BTSerial.begin(19200)


Arduino IDE Unable to detect ZumoMotor.H ( PIXY PET )

It looks like you need to install the ZumoMotors library.

There's one available at the following link, although I don't know for sure that it's the same one your Pixy Pet requires:

https://github.com/pololu/zumo-shield

That page includes instructions on how to install the libraries. If you get stuck, there's more help in the official Arduino documentation:

http://arduino.cc/en/Guide/Libraries


NodeMCU - use flash button as input in loop()

The Flash button on NodeMCU is connected between io 0 and ground.  You can use it as a button.  Set pinMode(0, INPUT_PULLUP) and you will read io 0 LOW if the button is pressed.

NodeMCU schema

To put the module in flashing mode, first the Flash button must be held and the Reset button pushed, only then should the Flash button be released. Normally, the reset to flashing mode is done automatically by esptool before uploading over USB. This uses the circuit connected to serial RST and DTS lines.


There are many usb to serial converter available on the market but can I make my own?

Yes, but if you need to ask how then you're not ready to undertake the task.

  One more thing is there any other way burn program from arduino ide to microcontroller via usb on bread board without having the arduino board.

Yes. The IDE doesn't care how you connect to the MCU, only that it has the appropriate bootloader for the programming method.

  Or can I burn program to microcontroller on the bread board from arduino board without removing the on board ic.

ArduinoISP will let you use an existing Arduino as an AVR ISP programmer. ISP does not require a bootloader, nor does it require a serial (UART) connection.


There is one basic concept that you are lacking.  At the moment you are looking to see if the button is pressed, not when the button has been pressed.

Instead of just looking to see if it is HIGH you need to look if it was LOW but is now HIGH. It's that transition from LOW to HIGH that you need to use as your trigger for when to set the LED colour, and that means remembering the state of the button the last time you went through the loop.

buttonState = digitalRead(button);
if (buttonState != oldButtonState) {
    oldButtonState = buttonState;
    if(buttonState == H) {
        // Do your stuff
    }
}

oldButtonState is defined the same as buttonState.


On an Arduino Mega (or an Uno with the ATmega328P replaced with an ATmega328PB, but then you'd have to adapt the code slightly), this can be done via the output compare modulator:

void setup() {
  // CTC, OC0A toggle on compare match, prescale 1/8
  TCCR0A = _BV(COM0A0)|_BV(WGM01);
  TCCR0B = _BV(CS01);

  // toggle every 35.5 μs at 16 MHz and 1/8 prescale
  OCR0A = 70;

  // phase and frequency correct PWM, TOP is OCR1A, OC1C clear going up and set going down, no prescale
  TCCR1A = _BV(COM1C1)|_BV(WGM10);
  TCCR1B = _BV(WGM13)|_BV(CS10);

  // period of 2 ms at 16 MHz and no prescale
  OCR1A = 16000;

  // on-time of 1 ms at 16 MHz and no prescale
  OCR1C = 8000;

  // no interrupts from the timers
  TIMSK0 = 0;
  TIMSK1 = 0;

  // only output a 1 when both timers are outputting a 1
  PORTB &= ~_BV(PORTB7);

  // halt the timers and reset the prescaler
  GTCCR |= _BV(TSM);
  GTCCR |= _BV(PSRSYNC);

  // reset both timers
  TCNT0 = 0;
  TCNT1 = 0;

  // enable output
  DDRB |= _BV(DDB7);

  // let the timers run
  GTCCR &= ~_BV(TSM);
}

void loop() {
  // Just adjust the frequencies and duty cycle as required here.
  // Everything is handled by the hardware and takes effect immediately upon writing to the register.
  // OCR1A: the desired period of the slower signal, in 8ths of microseconds. Can be up to 65535.
  // OCR1C: the desired on-time of the slower signal, in 8ths of microseconds. Can be up to 65535.
  // OCR0A: 1 less than the desired period of the faster signal, in microseconds. Can be up to 255.
  // The on-time of the faster signal is always half of the period.
  // If necessary, you can trade precision for more range for any of the above values by adjusting the prescaler.
}

With that sketch, pin 13 on the Mega will have the desired waveform. There's two big advantages to this method. First, it doesn't require any CPU resources at all (no loops or interrupts) once it's set up, so you can dedicate all of loop to reading the potentiometer and adjusting the duty cycle without worrying about glitches in the output. Second, being entirely hardware controlled means its output will be accurate and perfectly consistent (the 500 Hz component is perfect, and the 14 kHz component is approximately 14085 Hz). The one disadvantage, though, is that millis and everything else in the Arduino library that uses timers internally won't work quite right, since we're using the same hardware timers that they depend on.


How does Peggy2 drive rows with 74HC154 Decoder?

If you look into the datasheet of 74HC154, you can see that each output has an Active Low State. Also in the schematic, the leds row part use a pnp transistor (see page two). As so, they will be active if the input is low.

  This means all but one row is "on". Isn't this backwards?

Since they are PNP, the only active row is the one with Low value and the current of that row is sink through the selected column(s) in the STP16CPS05


I ended up ditching HTTPS since it doesnt seem to be implemented all that well (Requires hardcoding of fingerprint).
Changed the architecture of my system so that HTTPS is handled by Python which doesnt require jumping through hoops.


So it's actually the worm gear that is causing your problem, since that can't be reverse driven by the cogs.

The simplest option, I think, would be to have the middle cog normally separated from the worm gear and only re-engage it when you need to drive the mechanism with the servo.  You could maybe use a second servo to move it into the right place, or maybe a solenoid, or something along those lines. Have it slide along a short track or slot with a spring to ensure it disengages when the solenoid is released.


how can i generate square pulse at 50khz frequency to drive two mosfets at a duty ratio .6

This could be achieved either with software (with a timer interrupt or
by polling micros()) or with hardware. The software methods, however,
are prone to a high level of jitter. If you want to have a steady
signal, you should use a hardware solution.

The most straightforward hardware option is to use a timer in PWM mode.
I would avoid fiddling with timer 0, as it is used by the Arduino
timekeeping functions. You are left with either timer 1 or timer 2. The
following program configures timer 2 to output the desired signal:

period = 20 µs = 5 × 64 CPU cycles
signal HIGH for 12 µs = 3 × 64 CPU cycles.

The output goes to pin 3, which is one of the two PWM pins controlled by
timer 2.

void setup()
{
    DDRD |= _BV(PD3);     // OC2B = PD3 = digital 3 as output
    OCR2A  = 5 - 1;       // period = 5 * 64 CPU cycles
    OCR2B  = 3 - 1;       // HIGH for 3 * 64 CPU cycles
    TCCR2A = _BV(COM2B1)  // non-inverting PWM on OC2B
           | _BV(WGM20)   // fast PWM, TOP = OCR2A
           | _BV(WGM21);  // ...ditto
    TCCR2B = _BV(WGM22)   // ...ditto
           | _BV(CS22);   // clock at F_CPU / 64
}

void loop(){}

For some in depth information on how timers work, see
Nick Gammon's tutorial on timers.


I have the same problem,
I believe that the problem is related to the 4.x kernel, since I have already tried another distribution with the kernel mermo and the problem persists. Using a windows virtual machine as guest works, which excludes communications and hardware issues.


Expanding on my previous comments...

The only reliable way to get jitter-free ADC readings is to trigger the
ADC from a timer event. I wrote the following program to demonstrate the
approach on an Arduino Uno, as I don't have a Leonardo. The program
configures the Timer 1 to set it's overflow flag every 250 µs, and
the ADC to start a conversion on every rising edge of that flag. When
the conversion is done (104 µs after it started), the ADC ISR
fires. It's job is to retrieve the conversion result and set the analog
multiplexer for the next channel, switching round-robin through channels
0 – 3.

volatile int adc_readings[4];
volatile bool fresh_readings;

// Used only to clear the interrupt flag.
EMPTY_INTERRUPT(TIMER1_OVF_vect);

ISR(ADC_vect)
{
    static int buffered_readings[3];
    static uint8_t channel;

    if (channel == 3) {

        // "Export" the 4 readings at once.
        adc_readings[0] = buffered_readings[0];
        adc_readings[1] = buffered_readings[1];
        adc_readings[2] = buffered_readings[2];
        adc_readings[3] = ADC;
        fresh_readings = true;
    } else {

        // Buffer the current reading.
        buffered_readings[channel] = ADC;
    }

    // Move to next channel.
    channel = (channel + 1) % 4;
    ADMUX = _BV(REFS0)  // reference = Vcc
          | channel;
}

void setup()
{
    Serial.begin(115200);
    Serial.write("================");

    // Configure the ADC.
    ADMUX  = _BV(REFS0)   // reference = Vcc
           | 0;           // channel = ADC0
    ADCSRA = _BV(ADEN)    // enable
           | _BV(ADSC)    // start first conversion
           | _BV(ADPS0)   // prescaler = 128
           | _BV(ADPS1)   // ...ditto
           | _BV(ADPS2);  // ...ditto
    ADCSRB = _BV(ADTS1)   // trigger source = Timer 1 overflow
           | _BV(ADTS2);  // ...ditto

    // Wait for and discard the first conversion.
    loop_until_bit_is_set(ADCSRA, ADIF);

    // Configure Timer 1 to overflow every 250 us.
    TCCR1A = _BV(WGM11);  // fast PWM mode, TOP = ICR1
    TCCR1B = _BV(WGM12)   // ...ditto
           | _BV(WGM13)   // ...ditto
           | _BV(CS11);   // clock at F_CPU/8
    TIMSK1 = _BV(TOIE1);  // enable overflow interrupt
    ICR1   = 500 - 1;     // period = 500 * 8 CPU cycles

    // Set the ADC to auto-trigger mode.
    ADCSRA |= _BV(ADATE)  // enable auto-trigger
            | _BV(ADIF)   // clear interrupt flag
            | _BV(ADIE);  // enable interrupt
}

void loop()
{
    if (fresh_readings) {
        Serial.write((uint8_t *) adc_readings, sizeof adc_readings);
        fresh_readings = false;
    }
}

A few comments:

The Timer 1 overflow interrupt is used only to clear the timer
interrupt flag. The flag has to be cleared because the ADC is
triggered only on it's rising edges. Alternatively, that flag could be
cleared inside the ADC ISR.
I choose to deliver the readings by batches of 4 (one reading per
channel), thus the buffering inside the ADC ISR. The choice is
arbitrary: you can, if you wish, transmit the readings as they come,
as suggested in jwpat's answer.
The very first ADC reading is manually started and discarded. The only
reason for this is that it takes longer (200 µs instead of 104).
The readings are transmitted in binary form at 115.2 kb/s. The
effective data rate is 80 kb/s. ASCII would not be possible at
this sampling rate.
The loop() function must never take more than 1 ms to execute,
otherwise there is a risk of it reading the adc_readings array while
the ADC ISR is updating it, which would lead to corrupt data.
Protecting the access to adc_readings inside a cli()/sei() pair
would not significantly ease the timing constraint, as a long loop()
execution would still carry the risk of loosing data points.

From a cursory look at the ATmega32u4
datasheet
it would seem it's Timer 1 is identical to the one of the ATmega328P
powering the Uno, save for an extra PWM channel. The ADC, however, is
slightly different, but similar enough to make porting fairly
straightforward. At least the setting of ADMUX would be different.


Converting RGB from color sensor into the Munsell Color System

I have some thoughts on your task. First of all colorimetry is a science on its own. I know people working in this field for decades with equipment costing many millions of €. They all share some basic wise words. One is: "Because we all see colours we think measuring colous is an easy task. The opposite is true. Many of the best colorimetrists are colour blind." One second is: "Without light there is no colour". I will write on this later.

Colorimetry in fact is a complex matter. Between a colored piece of stone and a numerical value normally lie a lot of transformations and convolutions. And inbetween there are also lurking many error sources.

This said, I'm sure it will be possible to produce somewhat acceptable results with your sensor. Provided you do a proper calibration and add a calibratable light source.

Speaking of light source. A piece of stone can only reflect incident light (except some uranium/radium salts, you don't want to deal with). Pigments are basically LTI-systems (aka passive filters). This means they can only reflect wavelengths which are present in the incident light. And the will reflect a well defined and individual proportion of each wavelength regardless the luminous flux of the incident light. This means, if your incident light contains nearly no blue light then the stone or whatever you want to examine will reflect only the fraction of "nearly no light" it typically does reflect of any amount of blue light.

So the remission spectra of all pigments get shaped (multiplied) by the spectrum of the incident light. Your sensor sees only the reflected light and therefore will give totally different results for one and the same object depending on the incident light. Look up the spectra for daylight and incandescent light and think about the results of your sensor.

To make a long story short, you can only yield reproducable measurements if you supply your own light source along with the sensor. This is in fact the way all colour meters work.
The only other way was to measure the full spectrum of the incident light. Reasonable portable spectroradiometers for this purpose cost 5000 €. So it's better to go for a light source :).

As they are rather affordable I recommend using LEDs to make up a light source for examination. But LEDs suffer from several drawbacks. They tend to change their output spectrum with their chip temperature and ageing processes. So you have to supply a proper calibration procedure for your measuring equipment. And you better do the calibration sequence before every measurement.

You then have to design an apparatus which allows the light from your LED fall onto your samples (stones, sediments or so) but prevents other scattered or direct light to enter your sensor. Otherwise all measurements will be crap.

While this is not a direct answer to your question, I think the topic is important enough to write an elaborate pamphlet.

Update

Now some more words more closely related to your problem.

In general loading a huge excel table into your arduino is not necessarily a good idea, even if a big "if"-code array was possible. Storage is scarce on this platform.

If you combine a lookup table with interpolation, you can save much space. You would have to omit 90% of all datapoints and estimate all in between when measuring. Still the table will be rather big, because you have three degrees of freedom.

Another drawback of big tables and LUT with interpolation is, that it makes calibration difficult. Normally, when you calibrate your sensor, you have to adjust the parameters along the calculation. If you rely on a table, you have to exchange the whole table, regardless if it is something like that excel thingy or a condensed lookup table.

If you go for an analytical solution, as suggested in one comment, the number of parameters you have to update after calibration reduces drastically. Effectively you have to adjust some factors and offsets in the equations for this problem. Of course you will have to learn the ropes of the photometric equations, but you will  have to do that anyway, I think.

Some more words on the design of your appartus. Your idea of a cylinder in front of your probe is good. I recommend to fit it with a rim of black foam rubber, so you can seal light coming from outside. And you have to paint the inside of your cylinder as black as you can. See the interiour of a camera objective for reference.

If it is white you will have multiple reflections and multiple filtering which deteriorates your measurement results vastly.


The internal pullup is only activated, if you activate it in your code. To so, you have to write a 1 to the corresponding bit in the PORTB register, while the DDRB register is set for the pin to be an input.

So you the interrupt gets triggered randomly, because the pin was floating.

Since you are currently always write to the whole PORTB, you have to change the last bit to 1 on every PORTB write. Or you can write a 1 to it in setup() and only change the one output bit in PORTB by using

PORTB ^= 0b00010000;

This will toggle only your output pin.


You cannot close a tab in the Arduino IDE.  If a file exists in the sketch then it is there with a tab. Deleting a tab deletes the file.

In the Arduino IDE a tab is a file and a file is a tab. You can't remove one without removing the other.

You might like to check out my IDE, UECIDE, which deals with tabs in a more traditional manner.


Does anyone have a data sheet for MC16-0072

A quick search gave me the impression that MC16-0072 is actually some sort of rebranding. It seems MCM is not the manufacturer, simply a distributor.

Does the hardware itself have any number or serial printed on it?

In any case, when I dug a bit deeper and found this datasheet. However, without an image of your hardware or its serial number, I cannot confirm the datasheet is for your hardware.


How do I add additional compiler switches in Visual Studio

Use the ExtraFlags in the project properties. The flags can be specified for the currently selected configuration or for all builds of the current project.

The feature was released in the 15.06 version of the Visual Micro Arduino plugin for Visual Studio.

This guide shows how to access the project properties


Determine whether a variable is of an arithmetic type

Is there a way to determine whether a variable is of an arithmetic type or not?

no. end of the day, those are just bit pieces and it only makes sense to the computer with the right context. Another way to put it, the same bit pieces can and will mean different things under different situations.


Parsing array of an object in a library constructor

This is a C++, not Arduino question and should be asked on Stack Overflow.

In C/C++ the [] must be on variable name, not on type. WPCommand wp[] (it is the same as WPCommand* wp).

sizeof return size in bytes, not element count. send length as parameter

Dynamic memory allocation in MCU is not a good thing. You can have in WayPointStack

WPCommand _wp[arrSize]


MPU6050 or GY521/HMC5883 chips are burnt for no reason

Fixed the issue with a dedicated 3.3V power supply.  I2C scanner is running for 30 minutes with no issues so far.


What OS are you using?

If you're in Linux (and some OS X installations) you should note that bounce.h and Bounce.h are two completely different files - you need to make sure you have the capitalization the same in your #include directive as the actual file on disk is.


Arduino with DS18b20 and ENC28J60 to thingspeak

But on serial monitor I get msg: [webClient] IP: 192.168.88.252 GW: 192.168.88.1 DNS: 8.8.8.8 DNS failed SRV: 0.0.0.0

The line above shows that you have the Ethernet interface configured to use a private IP address (192.168.X.Y) and that you're trying to reach Google's DNS server at 8.8.8.8. That means that you've got to have a connection to the Internet accessible through your gateway (192.168.88.1). The gateway will have to be doing NAT since your router will not (should) not route traffic from private addresses to the Internet – and even if it did other routers would not be able to route traffic back to you.

The first thing to do is to confirm that you've got an Internet connection and that the address you're trying to reach exists. If you've got another computer on the same network that can reach the Internet try the address you're trying to reach (api.thingspeak.com) and confirm that the name resolves to an IP address. Then confirm that the gateway you're using on that machine matches what you've got configured on the Arduino.

Another good thing to check would be that the Arduino seems to be working on the wire. There are a number of ways that you could confirm this:

Check to see that you can ping it.
Check to see that it shows up in your ARP cache (use the command arp -a in the terminal if you're on Linux or OS X. You're looking to see that the IP address assigned to the Arduino is unique and that you get back the MAC address that you expect.
Try pointing your DNS at your router (assuming it is configured to act as a DNS server). That will let you see if you get a response from inside your network. Before doing this configure that api.thingspeak.com resolves using ping or by going there on another machine. If this works, you should try it pointing another machine at 8.8.8.8 as your DNS server – just to confirm that this works. If it works and the Arduino fails then it is getting more puzzling.

At this point you most likely will have identified the problem. If you haven't it would make sense to spend some time learning a bit about tcpdump or Wire Shark so that you can watch TCP traffic on the network. At the very least you'll want to be able to watch to see the basic DNS transaction. One possibility may be that the Arduino expects the DNS server to be on the local wire and that it is timing out too fast.


This is unfortunately not valid in C++:

"test" + millis()

Rather than concatenating two strings, it's actually doing pointer arithmetic. It's taking the memory address where "test" is stored, and offsetting by the value retrieved from millis(). The result is a totally arbitrary memory location which gets treated like a string.

Generally speaking, it's arguably best to avoid string concatenation on Arduino anyway unless absolutely necessary. The reason is that it can use more memory than you might expect.

A simpler approach would simply be to do the serial output as a sequence of individual operations, e.g.:

Serial.print( "test" );
Serial.println( millis() );

Note the difference between print() and println(). The first one doesn't add a line break at the end, but the second one does.


Input a signal from a sensor to an Arduino Due

This is a tough one. If it was digital IO sensor, a simple level shifter would suffice. However, since it's analog, you have limited options.
The cheapest route (and the easiest) would be to use a voltage divider. They only take two resistors, and they divide linearly. That means 1/2 of 5V would be divided into 1/2 of 3.3V. You can then  use the full range of the Due (be careful not to use 0-1023, as it has a 12 bit ADC: it'll give you weird numbers).
More on voltage dividers. Even more on voltage dividers.
To build one:

From Sparkfun (link at bottom)

That's four different ways to build one. R1 would be 1700 ohms and R2 would be 3300 ohms. Vin would be from the sensor and Vout would be to the Due.


Seeedstudio Wifi shield v1.1 Not working with Arduino Mega 2560

The WiFly library provided at the Seeedstudio wiki uses the software serial to communicate with the WiFi shield. All the example files provided by the WiFly library use pins 2 and 3 as the Rx and Tx of the software serial. Moreover, the Wifi shield only allows pins 0-7 to be chosen as Rx and Tx by using different jumper combinations.
The SoftwareSerial library, on the other hand, has the following limitation for the Arduino Mega

  Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

Thus, as a workaround, I jumped pin 2 of the shiled with pin 10 (Rx of Software Serial) and pin 3 with pin 11 (Tx of Software Serial) using connecting wires and used the jumper setting given on the wiki. Finally I made the following changes in the example code

// Pins' connection
// Arduino       WiFly
//  10    <---->    TX (via connecting pin 2 to 10 on wifi shield)
//  11    <---->    RX (via connecting pin 3 to 11 on wifi shield)

SoftwareSerial uart(10, 11); //change software serial pins for Mega

This allowed the Mega to communicate with the Wifi shield successfully using the WiFly library.


Is there a way to have more than 14 Output pins on arduino?

A common way to expand the set of available output pins on the Arduino is to use shift registers like the 74HC595 IC (link to datasheet).

You need 3 pins to control these chips:

Clock
Latch
Data

In a program, you pass on the data one bit at a time to the shift register using the shiftOut() command, like so:

shiftOut(dataPin, clockPin, data);

With that command, you set each of the 8 outputs on the 595 IC with the 8 bits in the data variable.

With one 595, you gain 5 pins (8 on the IC, but you spend 3 to talk to it). To get more outputs, you can daisy-chain a series of 595 together, by connecting its serial-out pin, to the data pin of the next one. You also must connect together the clock and latch pins of all of the 595 ICs.

The resulting circuit (using one 595) would look like this:

The figure above was taken from this codeproject.com webpage:

Arduino Platform - Working with Shift Registers

The latch pin is used to keep the 595 outputs steady while you are shifting out data into it, like so:

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, data);
digitalWrite(latchPin, HIGH);


How to have multiple digital outputs for the same pin on Arduino Uno and Simulink?

You cannot try and have two things controlling one output in two different ways. It just makes no sense.  Like trying to have two people steer a car and have one go left and the other right.

I don't quite know what you're trying to do, but under normal usage using a motor driver requires 3 pins (for example the common L239D). Two define the direction and a third (the EN pin on the L239D) controls the speed with PWM.


How to install Arduino IDE on Raspberry Pi

Arduino at http://playground.arduino.cc/Linux/Raspbian recommends:

sudo apt-get update && sudo apt-get install arduino

but indeed warns that the version is old:

  Note: This will install an old version of Arduino, and may not support
  some of the newer boards. You can not download a newer version from
  the website, because there is no ARM version. -- Arduino wiki on Raspbian

Looking at the raspbian respository at http://archive.raspbian.org/raspbian/pool/main/a/arduino/ currently lists 1.0.5

There are folks working newer versions of Arduino for ARM at https://github.com/arduino/Arduino/issues/3334 but it isn't finished yet.


Your handling of millis() is wrong. With these two lines:

unsigned long StartMillis = millis();
unsigned long CurrentMillis = millis();

StartMillis will always have the same value as CurrentMillis. (Ok, I guess its possible for millis() to return a value that's increased by 1 the second time it's called, but that is extremely unlikely. The 2 lines takes much less than a millisecond to execute.)

Your

while ((CurrentMillis - StartMillis)==5000)

will never evaluate to true, so the code in the while block will never execute.

This if statement is also wrong:

if (digitalRead(sensor)=0)

You want == (comparison) not = assignment. I'm surprised the compiler even allowed that to compile, since you are trying to set the function digitalRead(sensor) to 0, which doesn't make sense.

Change that code to read:

if (digitalRead(sensor)==0)

(Assuming you want the body of the if statement to execute when your sensor value is 0.)


How do I read from /dev/ttyACM0 in Linux without a terminal emulator?

I have had very similar problems with my yun(shields) and I found the stty command to be very crucial for a good working.
I use following command and it works with mega and due on the yun

stty -F ${PortName}  ${SerialSpeed}  raw -clocal -echo icrnl

Since I call these I can redirect from and to /dev/ttyxxx without problems.
As far as I can see you mis the raw.


Why can I not use pointers instead of array with PROGMEM?

Well, this question has been wisely answered in an answer to Stack Overflow question C: differences between char pointer and array.

Basically, what you're declaring as PROGMEM with,

const prog_char testStringD[] PROGMEM = "JKL";

is both the array and the memory it points to, that is, the elements of the array, both in current's scope stack. Whereas with:

const prog_char* testStringC PROGMEM = "GHI";

you declare a PROGMEM pointer to a constant string that may stay elsewhere in memory, but not declared as a PROGMEM string.

Though I did not test that, but you should try to declare:

const prog_char* testStringC PROGMEM = F("GHI");

to actually allocate the pointed string within the PROGMEM space. I guess it should be working, using Arduino's F() macro, which adds a lot of boilerplate code to actually have the same result as the array declaration.

As said in comments, if not in a global context, the PSTR() macro could be used instead of the F() macro.

Simpler is better: use the array declaration, not the pointer one!

Cf that other answer, the __flash qualifier is a third solution ;-)


I need to build a char array from two integers

Put it in a String and then use the c_str() method to get the associated char*.


Stuck in a small confusion about Infrared leds and receivers?

Element14 has an India based store, and they carry these IR devices.
Here is one for 66 rupees:
http://in.element14.com/vishay-semiconductor/tsop38238/ir-receiver-45m-38khz-th/dp/2395954?MER=MER-BPR-4PPM-SP-VSHY-OD&

You may want to do research into what the carrier frequency of your remote is also. Most are generally around 35 - 40khz, and the receiver I provided a link to is 38khz. It should work, but if you want to be safe I suggest you look it up. Or, if you have an old TV lying around, you can pull one out of that.

Hope this helps.


What does this error mean?? Arduino Due loop warning

MatrixWidth is 36. redarray[] has 3 elements. The compiler has detected that your code will likely blow up on the 4th go through the loop. Make sure your code is accessing the dimensions correctly.


I think he wants to measure the resistance of the soil. I saw many projects (I was a science fair judge) that did it with an ohm meter or variation thereof. They would have several samples of soil and add nutrients to it, generally with water. Salt was the best conductor. Similar tests were performed using Ph as the measurement. An Ohm meter passes a current through the DUT (Device Under Test) and measures the voltage drop to determine resistance, maybe that is where amperage came from. I am guessing this is maybe about a seventh grade project. More information always helps.


HMC5883L - Tilt compensation without Accelerometer

You can always use the normal tilt compensation equations with a fixed value instead of a calculation from the accelerometer; Since you know the rotation beforehand the equations may not be as complex. For example, if the tilt is only on one axis, it's just one rotation matrix multiply (and you don't need to calculate the result z axis) instead of 3 in general.

If the tilt is constant and exactly 90 degrees, You just need to swap which magnetometer axis are put into the magnetic field angle equations. If one axis is pointed towards the center of the earth, you can use the other two axis to calculate the direction of the magnetic field without an explicit rotation transformation.


it is possible to use digispark with NRF24 and USB keyboard without use system that need capacitors as the tree cable solution? I just want to use the digispark as RX


How do I adjust the scale/calibration of a photoresistor?

You can easily scale in Arduino code with the map() function.

e.g.:

const int MIN_LIGHT 100;
const int MAX_LIGHT 700;

int light_reading = analogRead(A0);

// Convert MIN reading (100) -> MAX reading (700) to a range 0->100.
int percentage_bright = map(light_reading, MIN_LIGHT, MAX_LIGHT, 0, 100);

But you may need some calibration of your system to handle different ambient light situations. What reading do you get in direct sunlight for example?

So then I assume you're using PWM (Pulse Width Modulation) to drive the LED.  This requires a value between 0 & 255.  Once again we can use the map() function.

// Convert light-value % (0-100) to PWM speed (0-255)
int led_brightness = map(percentage_bright, 0, 100, 0, 255);
analogWrite(LED_PIN_RED, led_brightness);

Obviously these bits of code can be reduced down to a single line - mapping directly from the reading to the desired result.


Using a toggle switch to run part of a sketch

There are different ways to accomplish the same thing.

The condition is a flag, or a read port.

if(digitalRead(inPin))
     {
     // Your first code here.
     }
else
     {
     // second code
     }

Switch contacts will bounce when opening or closing. You may want to consider that. Usually it is stable within 10 milliseconds. Depending on what you are doing it may or may not be relevant.


This little device is really good and easy to set up.
https://www.dfrobot.com/product-1121.html

You can use a pin and set it to ground with a resistor between to change songs if you don't need something fancy.


Why are begin() functions needed to initialize hardware (if they are)?

It's all to do with the order of execution.

Constructors are executed before normal functions. That includes the main() function which eventually calls setup() and (repeatedly) loop(). One of the other things that main() does is call init() (or some variant of) which configures the hardware.

Since that happens after any global constructors have been run anything that the constructor did to the hardware could potentially be undone.

Thus it is normal to defer any hardware configuration until after main() has done the work of setting things up, and the convention is to use a begin() function to do it.