I change ESP8266 baudrate and now it doesn't work

Have you tried setting the web editor's baud rate to both the old and the new values? I ask because the CIOBAUD command has been obsolete for a while now so, depending on the age of your device, it may have done nothing. The command was replaced by "AT+UART_CUR" and "AT+UART_DEF" which have a different syntax.

See this answer to a similar question.

Update:

Yes, here's an example:

// Declare a serial object to talk to ESP8266
SoftwareSerial EspSerial(WIFITX_PIN, WIFIRX_PIN);  // RX, TX

void setup(void){
   // Init WiFi serial
   EspSerial.begin(9600);
   delay(10);
}

I've used 9600 baud in my example since SoftwareSerial may not work well at faster speeds.

Update 2:

  Is it possible to send AT commands from the code instead of the
  monitor?

Yes, easily. Once the above code has run (and note that I've deleted an unnecessary line since update 1), you can send strings to the ESP with EspSerial.print() and EspSerial.println(). Here's an AT command example:

// Set 9600 baud, standard 8-bit frame, and save as power-on default:
EspSerial.println("AT+UART_DEF=9600,8,1,0,0");


Ethernet shield not have MAC address sticker

According to this documentation, you can just provide your own.

  mac: the MAC (Media access control) address for the device (array of 6 bytes). this is the Ethernet hardware address of your shield. Newer Arduino Ethernet Shields include a sticker with the device's MAC address. For older shields, choose your own.


I can't find issue in your code that I'm convinced is your problem. Without seeing your datasheet for the motor, I would bet your issue is one of two things:

1) A 9V battery is low-current relative to most batteries I've used for powering any decent DC motors. Do you have access to a better current source you could try?

2) Every motor has a trade-off in torque vs max-speed, dictated by the internal gear-ratio. Depending on the motor type, it may not have the torque to accelerate the vehicle to a significant speed.


You should make
byte key = 0b101100001111;

global, i.e. put it BEFORE the setup function and not within it.
Also, a byte only can contain 8 bits, you need 12, so make it an int (thanks to ocrdu, see comment below):
int key = 0b101100001111;

If you need more bits, you can use uint32_t or uint64_t, and count further than the current 12.
Now key is a local variable which is removed after exiting the setup function.
I'm not sure where 'key' comes from in:
switch (bitRead(key, n)) {

Do you get a compiler error, or did you ALSO define a global variable named key ?
Anyway, if you make key global it will fix either way.
A few other remarks:

Try to align your parenthesis, like the 3 }'s at the end, indent them properly, this makes your code much more readable
Instead of the switch/case, you could use an if statement in this case, as the re are only (and always) two possible values (0 and 1):

Thus:
 if(bitRead(key, n) == 0)
 {
     ...
 }
 else // 1
 {
     ...
 }

Try also comments to write in English instead of Greek, you never know when your comments will be read by non Greek readers (like now).

You can make the following fragment shorter and less duplicated:

Original:
digitalWrite(13, HIGH);
delayMicroseconds(1000);
digitalWrite(13, LOW);
delayMicroseconds(1000);

If you wrap this in a function:
void sendSignal(int duration)
{
    digitalWrite(13, HIGH);
    delayMicroseconds(duration);
    digitalWrite(13, LOW);
    delayMicroseconds(duration);
}

Then you can write a 1 by calling:
sendSignal(2000);

and a 0 by calling:
sendSignal(1000);


NodeMCU ESP8266 12E loses code after power is reconnected

D3 (GPIO0) and D4 (GPIO2) both need to be high on startup for the user program to be executed. The relay board connected to those pins are preventing a sufficient high on those pins.

If you need to use those pins then try using a stronger pull-up resistor on those pins. Try 330-470 ohms.

Either that or you will need to add additional circuitry between the port pins and the relay driver. Also please be aware that this will place a high on the relay driver input and will try to turn on the relays. Your powerup conditions may not be what you expect.


Hasn't the ESP8266 got different pin numbering? ie
arduino pin 2 = pin 4 on esp8266,
arduino pin 3 = pin 5 on esp8266,
and arduino pin 4 = pin 2 on esp8266? and pin 4 on esp8266 is the built-in led.
hope it helps.


Right PIN to activate a wireless relay with ESP8266 ESP-01

Looking at better pictures of the PCB on ALIExpress it looks like GPIO0 is used to switch the relay.

What that pin maps to, though, depends on what board you have selected in the IDE.


Let's imagine that you expect to have 1A of current going through your circuit.
Resistor of 0.1 Ohm will give you a voltage drop of 0.1V.
This causes two problems.

Firstly Arduino has a cheap ADC builtin. It's supposed to be easy to use, but not really precise. It has nonlinearities towards lower and higher range. You will get more precise reading when measuring voltages around 2.5V.

Secondly The precision of your measurement is cut by factor of 50. Arduino contains ADC that has resolution of 10 bits. This means that there are only 20 steps between 0V and 0.1V That's not really precise.

Solution? Use an opamp as "differential amplifier". If you multiply the voltage difference by 25 you will get 2.5V on the amplifier output when the resistor has 0.1V of drop on it. This value is much more precise when reading it by analogRead of the Arduino, and even a tiny change in voltage on the resistor will give you 25 times larger change on the amplifier output. This way it's much more precise and accurate.


Link to an project for remotely turning off light switch?

This isn't exactly what you asked for, but may be a better idea.

Light switches are electrically just switches.  Either two points are connected or they are not.  In this case they are meant to be mechanically actuated by humans.

Instead of making a electrically controlled contraption that mechanically activates the existing switch, you could more easily use a electrically-activated switch directly.  Such things are called relays, and are quite common and readily available.  You can easily get a relay that can be actuated from 5 V that can switch 120 or 240 Vac at a few amps.

Put the relay in parallel across the switch if you want the switch to be able to override the light on, and in series if you want the switch to be able to override the light off.

To allow both the relay and the switch to toggle the light on/off independently, each needs to be a SPDT (single pole double throw) switch or relay.  Actually, you'll have a hard time finding a relay that isn't at least SPDT.  Ordinary wall switches aren't, but ones meant for multiple switches to control the same light are, like you often find at the top and bottom of the same set of stairs.


Help with a rather specific implementation of FFT Library?

As Edgar has mentioned you are confusing things slightly.

First there is your sampling frequency. According to the Shannon-Nyquist theorem that is at a minimum of 2x the maximum frequency in your signal. So that is 2x100 = 200Hz. That's the number of samples per second in your sample set.

Secondly is your sample size, which is directly related to the FFT bucket size. For every two samples you can get one bucket. The more samples you have the more buckets you have, and the higher the resolution each bucket is. But for FFT to work you need a power-of-two sized sample set. That means 2, 4, 8, 16 etc samples.  So 256 samples would give you 128 buckets. That would be a little under 1Hz per bucket.

To make things cleaner though you can back-apply the last calculation to the first and get them to match. 256 samples at 256 samples per second will give you 128 buckets covering 0-128Hz so 1Hz per bucket.  Double that to 512 samples and you get 256 buckets at 0.5Hz per bucket. Double it again and you get double the resolution again.

The main speed issue that you will come across is not the time taken to do the FFT, but the time taken to capture your sample set. 256 samples at 256 samples per secod will, of course, take 1 second to capture. 512 samples will be 2 seconds, etc. Far longer than a decent FFT takes to calculate.


What is the Arduino compiler's version of `__unused` for function parameters?

Well, I typed all that question up for posting, then tried one last thing. It worked!

void Fn(__attribute__((unused)) int param) {
} // Fn(param)

So, rather than let a good question go to waste: here's the answer!

Now all we need to do is get the maintainers of all the libraries to put these in... and fix the other warnings...


updating firmware on arduino wifi shield

A "jumper" is a little piece of metal (or a 0-ohm resistor) that connects two pads or pins together. So, create an electrical connection across J3 ("DFU programming jumper" in all the pictures). You will then be able to program the shield via USB.


Your code doesn't seem to be the problem. Contrary to what you are saying I think your problem is most definitely in your hardware setup.

Most likely, your digitalRead doesn't register a HIGH input, so it doesn't get 5V. Instead of digitalRead, go for analogRead(A0). So change your circuit and attach it to pin A0.

Use serial.println(switchstate) to print the results to the serial monitor and then decide what your top value (HIGH) and bottom value (LOW) for detection will be. Perhaps include a pull down resistor as well on the A0 pin.


What's the difference between pow and sqrt in this code?

Converting Gerben's comment into an answer:

pow(x, 2) is the second power, in other words:

sqrt(x) is the square root of x, that is:

A whole circle is 360 degrees or 2π when measuring in radians. So this ratio of 180 / 3.141592 is used to convert an angle in radians to an angle in degrees.


How can I send integer from arduino to another arduino by FS1000A / XY-MK-5V 433Mhz TX/RX Module (WIFI)?

Have a look at the Easy Transfer library.  I haven't used the particular modules you have, however I did successfully use the EasyTransfer library with Ciseco wireless modules.  In essence the EasyTransfer library transmits the data as a structure with the same format on each module.  The structure can contain any data type.


Rc switch library display received values only one times using serial monitor

You can save the previous received value, and only print if it is different from what you just received.
Something like this:
// near the top
const int rightLED = 4;
const int leftLED = 7;
const unsigned long goRight = 5592323;
const unsigned long goLeft = 5592332;

// to hold the state
unsigned long previousValue = 0;

// ...

// loop code
void loop()
{
  if (receiver.available())
  {
    unsigned long receivedValue = receiver.getReceivedValue();
    if (receivedValue != previousValue) {
      // something changed
      if (receivedValue == goRight)
      {
        moveRight();
      }
      if (receivedValue == goLeft)
      {
        moveLeft();
      }
      // remember the current value
      previousValue = receivedValue;
    }
    receiver.resetAvailable();
  }
}


New to Arduino and I have a WIP code for a class. ERROR with LEDs working?

For this, you should be using map(). Instead of int potR = val % 8; try int potR = map(val, [minimum pot value], [maximum pot value], 0, 7). Also, I'm pretty sure you don't need the for loop if all you're doing is led[i]. In that case, you could use led[potR].


avrdude: stk500_recv(): programmer is not responding, arduino pro

The upload procedure needs to reset the ATmega328 by use of DTR. This invokes the bootloader code in the ATmega328. If there is a problem with your DTR connection, you have to instead manually press the RESET button at the appropriate time.
So probably your connection to DTR was faulty or. less likely, there could be a fault in the onboard capacitor between the Pro-Mini's "DTR" header and the ATmega328 RESET pin
https://store.arduino.cc/arduino-pro-mini -> Documentation

Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the Arduino Pro Mini is designed in a way that allows it to be reset by software running on a connected computer. One of the pins on the six-pin header is connected to the reset line of the ATmega328P via a 100 nF capacitor. This pin connects to one of the hardware flow control lines of the USB-to-serial convertor connected to the header: RTS when using an FTDI cable, DTR when using the Sparkfun breakout board. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of the reset line can be well-coordinated with the start of the upload.


I've done just that on a Arduino Pro Mini of mine.

You need to change the fuses to have the chip use the Internal Oscillator, instead of a crystal. After that you just program the 8-MHz version of the bootloader. Like the one used in the Arduino Pro Mini 3.3V.

The only problem is that you need to connect a crystal, to change the fuses to not use the crystal. Though it doesn't need to be 16Mhz. Anything between 1 and 16MHz will do.

But since you need to change both the fuses and the bootloader, there is no advantage to buy chips with the bootloader preinstalled.

I'd just buy some bare chips without the bootloader.

PS $4.66 is on the high side for an ATMega328P-PU.


Continuous push button detection in for Stepper control

I implemented your code here on a UNO using 2 pushbuttons (with the stepper motor functions commented out) and it seems to work fine.  When I press button1 I get a lot of "ok" printouts for as long as the button is held down. When I press button2, the same thing happens except with "ok2" instead of "ok".
Here's the code I used:
/*
    Name:       TwoPushButtonTest.ino
    Created:    9/28/2020 2:36:07 PM
    Author:     FRANKNEWXPS15\Frank
*/

//#include <AccelStepper.h>

const int button1Pin = A2;
const int button2Pin = A1;

int button1State = 0;
int button2State = 0;

boolean flag1 = 0;
boolean flag2 = 0;

//AccelStepper stepper = AccelStepper(1, 8, 9);
void setup()
{
  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);

  Serial.begin(115200);
}

void loop()
{

  //int sensorReading = analogRead(A0);
  //int motorSpeed = map(sensorReading, 0, 1023, 500, 1000);
  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);

  //stepper.setMaxSpeed(2000);
  //stepper.setSpeed(motorSpeed);

  if (button1State == HIGH)
  {

    Serial.print("ok");
    //stepper.setSpeed(motorSpeed);
    //stepper.runSpeed();

  }

  if (button2State == HIGH)
  {

    Serial.print("ok2");
    //stepper.setSpeed(-motorSpeed);
    //stepper.runSpeed();

  }
}

and here's the wiring diagram:

Note the two 10K pull-down resistors.  If these are not present, then the A2/A3 inputs are indeterminate whenever the buttons are in the 'disconnected' state, and anything can happen.


How does the ssd1306 handle different screen sizes?

The SSD1306 does not handle different sizes, it's ever only handling it's maximum size 128x64. But one can decide to only use less pins of the driver for a smaller display.

The SSD1306 has 128 segment pins, which activate the current column, so that the states of the 64 common signal pins will be used by the display for that column. For smaller display sizes there are just some pins of the SSD1306 left unconnected. They get set like all the other pins, but they are not connected to anything, thus the information gets lost.

For accommodating that, the library sets the pixel according to the size by not using every second row (aka common signal) for half size displays. That's why you get horizontal black lines, when using a 128x64 display with the library in 128x32 mode. The library thinks, that every second row is not connected either way and thus sets these pixels to black. The 128x32 display is loosing every second row when used with the library in 128x64 mode, because every second row is not connected.

Note, that nor the library neither the SSD1306 know about how the display is connected. You need to tell the library this, by setting the mode, and it will control the SSD1306 accordingly. So there is no feedback about the display, that you could use.

  Can I expect that, at least if I use the same driver library, that using the wrong screen will always have this behavior?

Yes and no. The library handles it this way, because it is the common way to leave out every second pin for displays of half size. But it comes down to the manufacturer to decide this. We cannot guarantee, that nobody will ever connect the SSD1306 in a different way to a display.

For most manufacturers you will be good. If you simply plan to provide the displays for your user, so that they can change them their selves, you can be sure. If the user should be able to use her/his own display, purchased anywhere else, you might run into problems (though rarely).


IANAL, but my understanding is:

Any LGPL code you modify you need to make available as source.
Using LGPL code in your project doesn't constitute modification of that code unless you actually modify that code (See above).
Any code you write that is not contained within LGPL code (see above) is yours to license as you wish. That means your libraries are your libraries. Your sketch is your sketch.

So in short, things that must be released as LGPL:

Modifications to the core code.
Modifications to other people's libraries

Things that are yours to license as you wish:

Your libraries
Your sketches

Things you should (if you're nice) provide attribution for:

Arduino API
Third party libraries

As far as hardware goes:

  These files are licensed under a Creative Commons Attribution Share-Alike license, which allows for both personal and commercial derivative works, as long as they credit Arduino and release their designs under the same license. The Arduino software is also open-source.

Which means if you use their designs within your own design you should attribute it and make it open source under the CC-BY license. Otherwise, if you just use their hardware verbatim there's nothing to attribute - you haven't used their designs, but a commercial product as a component.


Arduino Uno and ESP8266 serial monitor issue

What you are doing wrong is:

If sending AT commands from PC to ESP and receiving OK ,as you said, works - that means you connected TX output from USB --> RS232 IC on the board to both RX pin of the ATmega328 and RX pin of the ESP8266 - not as in your picture. Similarly, you connected RX input of the USB --> RS232 IC on the board to both ATmega328 TX and ESP8266 TX pin of the ESP8266. If communication between PC and ESP works, then you connected TX Arduino pin with TX ESP pin and RX Arduino pin with RX ESP pin and not as shown in the picture.

When you send AT command from PC both ATmega328 and ESP8266 are getting the signal from USB --> RS232 IC in their RX pins. As your firmware in the first 10 seconds doesn't read the RS232 data, ATmega328 just ignores the packets sent by PC but ESP8266 receives the packets and responds with OK.

Since you shorted RX on ATmega328 and RX on ESP8266 and you shorted TX on ATmega328 and RX on ESP8266, ATmega328 can not send the data to ESP and vice versa so there is no OK.

In the other case, if you connected ATmega328 TX with ESP8266 RX and ATmega328 RX with ESP8266 TX (as shown in the picture) then you would have shorted USB --> RS232 IC's TX with ESP's TX and you would have shorted USB --> RS232 IC's RX with ESP's RX.

In that case ATmega328 might be able to send AT command to both ESP and PC at the same time and ESP would respond but now ESP's TX would be connected to ATmega's RX which is now shorted with USB --> RS232 IC's TX so PC can't receive that packet. However, when ATmega328 responds with OK, the signal now goes from ATmega328 TX to USB --> RS232 IC's RX (as always) and you might see the response in serial terminal.

So, you can't get the ESP to respond directly to PC and to ATmega328 without interchanging the TX/RX wires. Furthermore, as you may know RS232 is designed for communication between two devices, not three - and this is the case where three devices (USB --> RS232 IC, ATmega328 and ESP8266) are connected to the same TX/RX pins at the same time in a rather unusual way. Because, devices are usually connected TX to RX and RX to TX. However, when using the Arduino's onboard USB --> RS232 converter (by removing the microcontroller or holding it under reset) then you have to connect TX to TX and RX to RX. That is because there is one more TX/RX pair in between PC and the RX/TX pins on the board. The output of the USB --> RS232 converter (TX) sends the data to RX pin on ATmega328 (and RX pin on the board) but if you want to send the signal further (to some other device), then the pin marked with RX is going to act as TX.

To summarize:

The schematics does not correspond to what you have written. Such a connection would not allow to send the AT commands from the PC to ESP and to receive response, meaning you connected the TX/RX the other way round.
You can not have both at the same time. You have to decide whether you want to send AT commands from the PC or from microcontroller and then connect the wires accordingly.


AMIS30543 - Library code | Order of pinDirection and pinOut

The library is doing this to make sure, that the pin will never go low during initialization.
Imagine doing it the other way round:
pinMode(ssPin, OUTPUT);
digitalWrite(ssPin, HIGH);

If the corresponding PORT bit is set to zero (LOW) previously (which is also the standard after reset/power cycle), the pin will go LOW for a very short time, until digitalWrite() sets it HIGH again. That LOW time is short, but it might needlessly activate the slave. If you first use digitalWrite(ssPin, HIGH), you activate the internal pullup (as standard mode after reset/power cycle is INPUT) and set the corresponding PORT bit to 1. Thus, when you now change the pin mode, the pin is HIGH immediately, without ever going to LOW in between.
Internally the Arduino uses 3 SFRs (Special Function Registers), which are directly connected to the IO hardware of the pins. The DDR register of each port controls the "pin mode" aka direction of the pin (input or output). The PORT register controls the output value (HIGH or LOW; or turning the pullup resistor on or off in input mode). The PIN register reflects the current state of the pin (for reading it). In this case the double function of the PORT register is important, as it activates the internal pullup resistor, when set while in input mode.


Have you tried something like the following?

#define STEP 50

void loop()
{

  // if the pushbutton is pressed set the linear value
  button1State = digitalRead(button1Pin);
  if (button1State == HIGH) {
    // set the position value
    if (linearValue > 1050)
       linearValue = max(linearValue-STEP,1050) ;

  }

    if (button1State == LOW) {
    // set the position value
    if (linearValue < 2000)
       linearValue = min(linearValue+50,2000) ;
  }

  //use the writeMicroseconds to set the actuator to the new position
  LINEARACTUATOR.writeMicroseconds(linearValue);
  delay(100);
}

By changing the STEP value (or the delay in the next-to-last line) you can change the speed of the servo.


How to prevent ATTiny program from running after I flash it with Arduino?

This means that if I try to flash the program, ATTiny will start to put PWM power into my Arduino. I don't want that to happen.

Why do you think that is a problem? The "PWM power" cannot be any higher than the supply voltage, and that is 5V. The Arduino has no problem with you providing a 5V PWM signal to an input pin.

The only time it could be a problem is if the pin you are sending the PWM to is set to an output, in which case you could risk overloading the pin. To get around that you just need to insert a small resistor between the ATTiny's pin and the Arduino's pin. 330Ω or so should do it. Just enough to limit the current to a safe value (< 20mA) but small enough that it won't interfere with the programming communication.

A well design schematic for an Arduino ICSP programmer would have had these resistors in all the data communication lines anyway.


Why am I receiving this error: “expected unqualified-id before numeric constant”?

You're using an invalid variable name (1cd starts with the number 1).

Variables can consist of both uppercase (A-Z) and lowercase(a-z)
letters.
Variables can contain numbers 0 to 9, but cannot start with a number.
Variables may not have the same names as Arduino language keywords,
e.g. you cannot have a variable named float.
If you try and save a sketch with a space in the file name, the IDE will change the space to an underscore.


Will the arduino power autoselection logic short the regulated 5V and the USB 5V?

If you connect a power supply directly to 5V pin on gpio it bypasses voltage regulator hence your board may be damaged if the power supply generates  spikes. But you can power it using 5V supply directly to 5V pin provided you are using a good quality power supply. If you are supplying the power via Vin or power jack there is additional voltage regulator in path giving extra security. Thus you need more 6.5v so as the output of the regulator is 5v. If you supply 5v to Vin the output is nearly 4v thus the board doesn't get enough power.


How do I change the default LED pin for displaying uploading

The blinking while uploading makes the bootloader. Arduino Mini uses Optiboot. The source codes are on GitHub. You would need to change the pin in pin_defs.h and make the bootloader. Then flash it to the 328p with a programmer over ICSP.

Details what to change are in Greenonline's answer.


NordicRF (the company behind nRF24L01) has released two series of SoC devices that are compatible with nRF24: NRF51 and NRF52. Thanks to the effort by Sandeep Mistry and other contributors, they can be programmed using the Arduino IDE and libraries. Instructions are available here: https://github.com/sandeepmistry/arduino-nRF5

I have tested NRF51822, which is the cheapest variant (costing slightly more than Arduino Pro Mini + NRF24L01+ but in a single small and power-efficient package) and it works great.

The BBC Micro:bit is based on NRF51. More information is available at https://forum.mysensors.org/topic/9722/bbc-micro-bit-and-mysensors-a-great-match

Compared to the Atmega328-based Arduino Pro Mini, NRF51822 has 8x larger flash and 8x larger RAM. It also has Bluetooth 5 and BLE support and a 32-bit ARM Cortex M0 CPU.

There is also this alternative: https://www.ebid.net/eu/for-sale/arduino-ide-compatible-controller-with-the-nordic-nrf24l01-radio-transceiver-156695123.htm

Specifications:

Dimensions 59mm x 18mm
The Nordic nRF24L01+ 2.4 GHz Radio transceiver on board
Supply voltage up to 6.5 Volts
The Digital and Analog pins are 5 volts
ATMega328P frequency is 8 Mhz
4 battery connector pins
FTDI header for programming

Full disclosure: I am member of the MySensors core team. A MySensors user (not affiliated with the core team) created and is selling this board.


To make an informed decision you first need to understand a few basic concepts and some pros and cons of each system.

Firstly there are the concepts of precision and accuracy. These are two very different properties and each is important in their own way. On the face of it they may sound the same, but they aren't.

Precision

This is how close to the real value your measurements are. This is the "±"  value that datasheets list. It's how close a match to the actual temperature the measured temperature is.  So a ±0.5° measurement could be anywhere within half a degree of the actual temperature.

Accuracy

This can also be considered as the resolution of the measurement. It is how fine a difference in temperatures the device is able to measure. For instance you may be able to detect 0.0125° differences.  This is mostly defined by the resolution of the ADC in the device.

And now the pros and cons:

Digital

Pros

These devices can be factory calibrated for a more precise reading. The accuracy is usually pretty good too, but is fixed by the design of the device. Communication is generally reliable and wire length doesn't generally affect the values reported.

Cons

Communication protocols can have some large overheads limiting the number of samples you can take per second (not just on one sensor but across the whole array of sensors). Excess EMI noise (especially from engines) can corrupt the communication signals over long connections unless extra care is taken (such as implementing a balanced line communication medium).

Analog

Pros

Very simple to connect up and samples can be read very rapidly. Accuracy is determined by the ADC you choose to use.

Cons

Wire length can have a detrimental affect on the values read unless special wiring and sensor schemes are used to cancel out the resistance of the wires. Noise induced into the wires is very hard to detect or cancel out and can give spurious results. Requires more complex mathematics to calculate a resistance.

Summary

So in short: Digital can give you more reliable communication of your sampled values over longer distances but at the cost of reduced sampling speeds.


Use SPI and I2C in the same circuit (ATtiny85/84)

In the setup shown, you have 3 pins free, yes? Although hardware i2c may not be directly possible through software, the use of the other GPIO pins can be used for either a logic circuit to switch around the pull up resistor/green wire/whatever OR you can just use software i2c which is a lot easier to do.


If you are going to use an external LED, then using software to make the LED blink when the RX or TX line is busy is a waste of your CPU.

Instead, simply connect the LED to the RX or TX line using a transistor as a buffer to prevent the current draw from messing with the serial signal.

To borrow an image from this answer to a similar question:

You can try omitting the transistor buffer, but the serial waveform will be altered, possibly to the point where data becomes corrupted. The transistor prevents the current draw of the LED and resistor from loading down the RX or TX lines.


Parsing and comparing strings on Arduino: different behaviour from gcc?

Both versions of your code have undefined behavior. On the given input your code will call strtok three times and store its result into the array three times: for the first token, for the second token and, finally, for the null pointer. You store all three (including that null pointer!) into the all_tokens array, which has size 2.

You are obviously aware of the potential array overrun danger: you even wrote this comment in your code

char *all_tokens[2]; //NOTE: the message is composed by 2 tokens: command and value

and yet in the following cycle

int i = 0;

all_tokens[i] = strtok(rcv_msg, "{, }");
while (all_tokens[i] != NULL) {
    all_tokens[++i] = strtok(NULL, "{, }");
}

you still insist on storing more than two values into all_tokens array.

Also, the second version of your code uses completely different message key values (why is it suddenly "motor1_pattern1" instead of "message_1"?), which makes it unclear how you compared the functionality of the second version with the functionality of the first.


I would like to know the ATMEGA wiring to Arduino

Image searching for the term "arduino uno pinout" reveals a better pinout diagram.


What are patterns of bits sent to or read from GPIO pins called?

Here is a simplistic diagram.
Larger than 8 bits is usually referred to as WORD.


Problems With Fading Through Neopixel Colors

There appears to be a number of problems with this code.

The variables only have scope with in this function and are not static.  So they will not survive from call to call.  Every time you call this function it will be like starting over.

Putting returns in the middle of code is not good coding practice.  It is very difficult to follow and hard to debug.  It would be best to arrange your code so that there is only 1 return at the end of the function.

This code (from Adafruit) only controls 1 RGB LED.  If you are to control 40 RGB LEDs all at different stages of color changing you would need 40 copies of this function.  This is not very efficient. Instead use this function to populate one lookup table with R G B data.  Then track 40 variables, one for each RGB LED.  Use the 40 variables to lookup a specific color combination in the lookup table for each of the 40 RGB LEDs.


This is a poor product, look at this: that describes exactly the problems you (and me) are experiencing. Correct me if you've found any solutions so far.
edit
Try looking at description of regster 0x2f in datasheet and to this question.
I think that the first problem you describe can be solved this way, the second behaviour sounds like you fried the device.


How to drive 16 stepper motors with Arduino?

If you need to drive all 16 simultaneously and independently, the Uno may not have enough capability to do it. Consider the worst-case number of motors and highest rate(s) you expect to drive at once, plus anything else you need the Uno doing at the same time. You might try a simple sketch to do all of these things (substituting LEDs for the motor drivers) at once, and use a scope to examine those LED output signals for the right frequency, wave-form, and lack of jitter. Without I/O expanders, you won't get to 16 motors' worth of outputs (unless you already have an I/O expander) but you might try doubling up on the existing output (use non-overlapping motor phases if you can).

If the Uno can manage that with clean outputs, you'll have a better idea whether it can manage the full load. If it doesn't, you may need to reconsider your choice of processor with respect to its clock-speed, both kinds of memory (depending on what you learned), number of outputs, possibly number of available timers and of interrupts.


Make one button print different sentences on LCD

Consider using what is commonly called in programming as a Finite-state machine.  Advance to the next state each time the button is pressed.  Start out with 3 states and advance to the next after pressing the button.  You many need to double the number of states after adding your message to the program.  This is because you will want to press the button and only print the message once then advance to a new state where all you do is wait for the next button press.

Note, a mechanical device such as a button will need to be de-bounced either in hardware or in software.  This is because the processor may see individual makes and breaks as the button is closed and opened causing it to advance to the next state in unexpected ways.


I use Bluetooth to control LED,but LED can not turn off

this may be because of using digitalWrite in 0x03. Try using analogWrite(9, 0); instead.


Does IDLE Mode not power down an ATtiny85?

In IDLE mode the timers still run. Arduino uses timer0 for millis. So when timer0 overflows the ATTiny will wake up and call the ISR.

So the ATTiny will go to 'sleep' but wake up a number of microseconds later.


Due: Write to digital pin when ADC is running

I found the problem: The Arduino had been waiting for the SerialUSB Connection.

The Serial connection has not been established because I was running the Arduino without running the corresponding Python script. That script would have opened the Serial connection.

When running the Python script, the Arduino Due then works as expected.


Similar capability in turns of processing power if you compare back 10 -20 years.

arduino is a micrcontroller not a microprocessor.

A good example is the pdp11 minicomputer and the ti msp430 micro controllers. They share the same instruction set (approx 90%) . Both can (or could) do realtime event handling but pdp11 was more for data processing. Though pdp11 didn't have integrated peripherals

see bottom of this page http://www.cpushack.com/CPU/cpu4.html


You can have multiple I2C devices on the same bus (sharing both SDA and SCL), as long as they have different addresses. The library used to access them should know (or be told, if required) what the address for the device is.

If they are not I2C devices then they cannot both use SDA.

The Aosong device is not an I2C device, but there is no need to connect its "SDA" pin to the Arduino's "SDA" pin; any unused digital pin should work, as long as the library is told which pin to find it on and as long as the electrical requirements of the connection are met.


How to create a simple TCP server with the analogRead value on Wemos D1 mini?

So the problem was that I forgot the following line.
Thanks to @Johnny Mopp for pointing this out.

server.begin()

Correct code:

#include <ESP8266WiFi.h>

//how many clients should be able to telnet to this ESP8266
#define MAX_SRV_CLIENTS 2
const char* ssid = "myWifi";
const char* password = "myPassword";

WiFiServer server(23);
WiFiClient serverClients[MAX_SRV_CLIENTS];

unsigned long previousMillis = 0;
const long interval = 200;
void setup() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
  if (i == 21) {
    Serial.print("Could not connect to"); Serial.println(ssid);
    while (1) delay(500);
  }
  server.begin();
  server.setNoDelay(true);
}

void loop() {
  unsigned long currentMillis = millis();
  uint8_t i;
  //check if there are any new clients
  if (server.hasClient()) {
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      //find free/disconnected spot
      if (!serverClients[i] || !serverClients[i].connected()) {
        if (serverClients[i]) serverClients[i].stop();
        serverClients[i] = server.available();
        continue;
      }
    }
    //no free/disconnected spot so reject
    WiFiClient serverClient = server.available();
    serverClient.stop();
  }

  //do every 200ms
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    int isensorValue = analogRead(A0);
    String sSensorValue = String(isensorValue) + "\n\r";
    size_t len = sSensorValue.length();
    uint8_t sbuf[len];
    sSensorValue.getBytes(sbuf, len);
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      if (serverClients[i] && serverClients[i].connected()) {
        serverClients[i].write(sbuf, len);
        delay(1);
      }
    }

  }
}


Works with gcc, not with Arduino. error: taking address of temporary array

It is quite right, using that kind of syntax is not allowed. It's a bit of a pain, but it's ok since there is an alternative method - kind of a "trick" if you will.

That trick is to use a string, not an array. After all, a string is just an array, it's just handled slightly differently by the compiler.

Instead of using {...} use "..." and use the hexadecimal character escape sequence \xNN, such as:

cpaddr(a, "\x00\x10\xFF\xCA\x00\x00\xA2\x7D");

You could even lose your custom function and use a standard library function - memcpy():

memcpy(a, "\x00\x10\xFF\xCA\x00\x00\xA2\x7D", 8);

On the 8-bit AVRs you can save RAM by using the progmem variant and the F() macro:

memcpy_P(a, F("\x00\x10\xFF\xCA\x00\x00\xA2\x7D"), 8);


Wake Huzzah Feather ESP8266 With Reed Switch

The RST (reset) pin of the ESP works as the reset pin of any other microcontroller. If you pull it to LOW long enough (the threshold is surely listed in the datasheet), the whole microcontroller will reset as if you had cut and reestablished the power supply. So it will not wake it from sleep, but reset it completely.

It is correct, that you can use GPIO16 connected to RST, to let the ESP reset itself from a deep sleep. This seems to be an internal hardware functionality, that is distinct from the normal IO hardware. But you cannot use the same pin for some other functionality at the same time. Your reed switch is closed, if the door is closed. So it gives a LOW level to GPIO16 and RST, holding it in reset state. In this state no code is executed, thus you never get a message, that the door is closed. When you then open the door, the switch opens too. Since the RST pin isn't pulled to LOW anymore, the ESP can boot and execute your code. The door is open, so you get the corresponding message.

So you have to use a different pin for the reed switch.


The answer to "Can an Arduino even handle the processing power" is probably No, but no one can really answer because you have not specified the problem.

Just for starters you have >3k LEDS, if you want to control RGB that means ~10k devices.

To operate at moderate brightness (10mA per LED) you will need at least a 35A power supply. This will require external high power circuitry to switch/control.

Do you need to individually control each LED? To control 10k devices you will need serious external circuitry.

Do you need to control brightness or just switch individual devices on/off?

You could probably achieve a solution, but 15 modules each controlling 15*15 LEDS may be achievable, 32 or 64 is probably more realistic.

Either way soldering by hand would be impractical, you need to design a board for each module.

You could use an Arduino on each module, but a ATMega chip would achieve the same end, without the unnecessary peripheral circuitry.


There are two types of stepper motors: unipolar and bipolar. Bipolars usually have four wires and unipolars have six.

  --http://hobbymilling.com/wp-content/uploads/2011/05/Unipolar-stepper-motor-windings.png

  --https://www.codeproject.com/KB/system/steppermotorcontrol/pic6.jpg

The motor shield is designed to drive a bipolar motor (4 wires) but the motor is unipolar (6 wires). As you can see in the pictures, if you ignore the middle wire of the unipolar motor, it is the exact same as a bipolar stepper motor.


Bridging the wifi networks on nodemcu: how to set the esp8266 as wifi extender, simplest case

The esp8266 will not bridge the networks. You can perhaps bridge the communication from your other ep8266 on the TCP level with WiFiServer and WiFiClient. Send the sensor value to middle esp8266 running AP and it sends the value to Raspberry.

With MQTT you could create some MQTT proxy. Receive the data with WiFiServer and forward it with WiFiClient. without parsing or anything, only copying the chars between servers client and local client in booth directions

something like this (not tested):

void loop() {

  if (!serverClient || !serverClient.connected()) {
    serverClient = server.available();
  }
  if (!serverClient || !serverClient.connected()) {
    if (client.connected()) {
      client.stop();
    }
    return;
  }

  if (!client || !client.connected()) {
    if (!client.connect(raspiIP, MQTT_PORT)) {
      Serial.println("Can't connect to MQTT");
      delay(1000);
      return;
    }
  }

  while (serverClient.available() > 0) {
    client.write(serverClient.read());
  }
  while (client.available() > 0) {
    serverClient.write(client.read());
  }
}


Arduino can't see any library I have installed for nrf905?

The errors you were getting when you compiled was because if the libraries were extracted straight to the Arduino library folder from the .zip, the file path becomes too long for the compiler to find it.

So what you need to do is to create a new folder in the libraries folder for each library.

Note: you cannot do the standard libraryName\src\foo.cpp as this seems to give errors for these libraries (in that it does not find them).

What you need to do is to make a file in the libraries directory; for the zkemble one you can create a main folder called nRF905, then take the files under nRF905/arduino/nRF905 from github and place them in the folder created earlier. It should look like this:

You should repeat this for the Elechouse one as well as it solved the problem too. i.e.

C:\\...\libraries\NRF\examples\
C:\\...\libraries\NRF\NRF905.cpp
C:\\...\libraries\NRF\NRF905.h
C:\\...\libraries\NRF\keywords.txt

Also of importance is that once you have the library from Elechouse compiling you need to open up the .cpp file and go to line 16, where there is

PROGMEM unsigned int freq_tab[10] = {

and to this add const, like so:

PROGMEM const unsigned int freq_tab[10] = {


What is a safe way to power arduino nano with 7.4V Lipo battery?

Connect it via the Vin pin. That way the 6-8.4 volt of the battery will go through the voltage regulator on the Nano, giving you a stable 5v.

What you show in your diagram is the wrong way of connecting the battery. The absolute maximum you can supply to the Arduino's 5V pin is 6 Volt. Atmel recommends no more than 5.5V. So your battery exceeds this when it's full.


Reading analog value while generating PWM signal

It was an issue with the power source. It's an USB led strip, so I was powering it through Arduino, which was a bad idea as it turns out.

When I have added external power source to the circuit everything started working correctly.


Am I at the limit of UART transmission time?

At 115200 baud you can send 11520 characters per second. At 20 bytes per packet you can send 576 packets per second. That's 1,736µs per packet.
That's assuming zero wait between bytes. That's not going to happen.
Your measurement of 70µs will just be the time taken to place data into the transmit buffer, and has nothing to do with how long the transmission itself takes.
Roll all that together and the value of 2,500µs per packet is not unreasonable.
To transmit faster you will simply have to run at a faster baud rate.  If you're getting 2500µs per packet currently and a packet takes 1736µs (call it 1,750 for simplicity) then there's about a 750µs overhead per packet to do the actual work of sending the data from the buffer. I'll assume this is a fixed value, though with no knowledge of how the STM32F1 UART works it may not be.
If you want <1000µs then that leaves you about 250µs of time to fit the packet into. That means an equivalent of 4,000 packets per second, or 80,000 bytes per second, or a baud rate of 800,000baud.
1 MBaud is more than possible, and is a good standard baud rate number that most things can cope with. So raising your baud rate to 1,000,000 should allow the communication to happen fast enough.


This answer provides both Arduino specific knowledge and general electrical knowledge - both are necessary for a good solution (unfortunately).

Summary

To carry out Arduino analog to analog transfer:

Use analogWrite(pin, value) on a valid digital pin (see below)
Use analogRead(pin) on a valid analog input pin.
Connect a series resistor between the two pins - say 10k.
Place a capacitor from the analog input to ground, say 100 nF to 10 uF.

The R & C act as a low pass filter to convert the PWM to DC.
Details below.

Arduino analog pins are ONLY for analog input, not for analog output.
So trying to do analog out on an analog pin dooms your attempt to failure.

Arduino analogWrite(pin, value) only works on DIGITAL pins and then only on the subset of digital pins that have PWM capability. This is typically digital pins 3 5 6 9 10 11.

"analogWrite(pin, value)  produces as others have said - a PWM signal - rail to rail square waves with mark space ratio that varies so the mean DC value changes. For a 5V system  =
V_DC_mean ~~= value/256 x 5V.
Where 'value' comes from analogWrite(pin, value)

To convert the PWM to good-enough DC a low pass filter with a cutoff somewhat below the PWM frame rate is needed. AFAIK Arduino PWM frame rate is about 800 Hz -  so components are usually higher than that. A simple RC filter where R x C is usefully more than about 0.001S will start to work . Larger RC is smoother but with secondary effects. Using a 10 uF ceramic cap and a 10k resistor is probably OK. 10 uF x 10k = 0.1S. 1uF and 1k = 0.001 s = marginal. An electrolytic cap can be used but leakage current may slightly affect accuracy. So -

From somewhere in Arduino land (unknown) I copied the material below.
This is NOT in the basic reference, but should be.

Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz. Pins 3 and 11 on the Leonardo also run at 980 Hz.

On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11.

The Arduino Due supports analogWrite() on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.


Routing Arduino Mega output to either one of two serial ports

I can think of three distinct ways (and one that is similar to another) of doing what you want.
But first a note on polymorphism.  The HardwareSerial class is itself a child of the Stream class. It's this Stream class that provides all the read/write functionality (it, itself, is a child of the Print class which provides all the print(...) functions).
If all you want to do is print then you should be working with the Print class. if you want to do both reading and writing then the Stream class is what you want. You should only use HardwareSerial if you need to use the Serial-specific functions like .begin(baud).
So with that in mind you could:
1. Assign a pointer
Print *printer;

void setup() {
    Serial.begin(115200);
    Serial1.begin(115200);
    printer = &Serial;
}

void loop() {
    printer = &Serial;
    printer->println(millis());
    delay(100);
    printer = &Serial1;
    printer->println(millis());
    delay(100);
}

This is by far the most efficient method from a purely machine perspective.
Note the use of -> instead of . when calling a function on a pointer.
2a. Use a wrapper function
uint8_t stream = 0;

void printit(const char *text) {
    switch (stream) {
        case 0:
            Serial.print(text);
            break;
        case 1:
            Serial1.print(text);
            break;
    }
}

void setup() {
    Serial.begin(115200);
    Serial1.begin(115200);
}

void loop() {
    stream = 0;
    printit("Hello on stream 0\r\n");
    stream = 1;
    printit("Hello on stream 1\r\n");
}

This is less efficient and limits what you can print unless you write lots of overloaded functions.
2b. Use a macro
This is like 2a but uses a macro instead of a function:
#define printit(T) if (stream == 0) Serial.print(T) else Serial1.print(T)

This keeps the standard overloading of the print function but has lots of IF statements littered through your code. A fraction more efficient than 2a since it's all inline. Harder for a human to understand though.
3. Create a wrapper class
This is the rolls-royce method. Everything becomes encapsulated in your own object. Pointers are used to keep it efficient.
class Printer : public Print {
    private:
        Print *stream;
        Print *stream0;
        Print *stream1;
    public:
        Printer(Print &s0, Print &s1) : stream0(&s0), stream1(&s1) {
            stream = &s0;
        }
        size_t write(uint8_t c) {
            return stream->write(c);
        }
        void setStream(uint8_t sno) {
            switch (sno) {
                case 0: stream = stream0; break;
                case 1: stream = stream1; break;
            }
        }
};

Printer printer(Serial, Serial1);

void setup() {
    Serial.begin(115200);
    Serial1.begin(115200);
}

void loop() {
    printer.setStream(0);
    printer.println(millis());
    delay(100);
    printer.setStream(1);
    printer.prinln(millis());
    delay(100);
}

With this method the new class could be put into a library and used across your projects.
You also get all the functions you'd normally get with the Serial object when printing (for reading change Print to Stream and implement all the pure virtual functions you need for that class).
And a footnote for all those that say "Why use pointers? Why not references?" I say: I hate references. Pointers are far more obvious what they are. References you can't tell apart from distinct variables. With a pointer you know it's a pointer. References are the spawn of the devil.


SPI Overflow in 328 slave with i2c sensor

It is likely that your SPI interrupt on the slave is firing in the middle of updating your global yawInput variable. This would cause the value to be partially updated when you send it back to the master. You might even be sending part of the old value and part of the new value back to the master. It depends on when the interrupts fire.

You need to lock your SampleGyro function somehow. The easiest way would be to disable interrupts when modifying any interrupt accessible variables (i.e. yawInput).

Something like this should tell you if the interrupt timing is the issue:

void SampleGyro(Adafruit_BNO055 &gyroIMU){
    /* Display the floating  point data */
    imu::Vector<3> euler = gyroIMU.getVector(Adafruit_BNO055::VECTOR_EULER);
    uint8_t system, gyro, accel, mag = 0;
    gyroIMU.getCalibration(&system, &gyro, &accel, &mag);

    // Disable interrupts while modifying the global variable
    noInterrupts()
    yawInput=euler.x()-yawOffset;
    if (yawInput >= 360) {
          yawInput -= 360;
    } else if (yawInput < 0) {
          yawInput += 360;
    }
    pitchInput=euler.y();
    //rollInput=fmod((euler.z()+(360+90)), 360)-180;
    rollInput=euler.z();
    calibration=system;
    // re-enable interrupts once your global variable
    // modification is done.
    interrupts();
}

It's also worth noting that you want to put as little code between the noInterrupts() and interrupts() calls as possible. Things like I2C and SPI and basically any other communication will likely not work inside of that block. I rearranged your SampleGyro function to put all calls to the gyro outside of the lock. This is to prevent the sensor reading from failing.


Setting kext-dev-mode=1 allows unsigned kernel extensions to load, which is not recommended, as it lowers OS X security.

Instead, try the signed 64-bit kernel extension from FTDI here: http://www.ftdichip.com/Drivers/VCP.htm , version 2.3, which does require changing OS security permissions.


My arduino won't show up in Device Manager in any way, neither in unknown devices nor in COM port.

As the OP reported: It worked with a different cable.

I converted his comment to an answer so the system would regard this issue as solved. Please accept this answer.

Some cheap USB cables only carry power, and not data. I have such a cable that came with a USB desk light. To save money they only run two wires and not four, since the desk light is not a data device.

Be cautious about grabbing any old cable from your desk for testing. Make sure it is designed for data use. If in doubt, try a known good cable.


You need to level-shift the Arduino's 5V signals to the module's I/O range of 1.7 - 3.6 V if you want to use SPI; that is, if you haven't damaged it already. I suggest you follow the tutorial here though. It employs I2C instead of SPI but is specific to your particular module. There are no level-shifters needed in this case. Simply connect VCC and CS to 3.3 V, the I2C pins to 3.3 V through 4.7k pull-ups and the GNDs together.


Using Lego temperature sensor with Arduino

I managed to get it work with the following code:

float getTemp(){
    #define ADDRESS 0x4C
    #define CONFIG 0x00
    float temp;
    Wire.beginTransmission(ADDRESS);
    Wire.write(CONFIG);
    Wire.endTransmission();
    delay(50);
    Wire.requestFrom(ADDRESS,2);
    temp=Wire.read();
    if(Wire.read()==128){
        temp+=0.5;
    }
    return temp;
}

And connect the green wire to 3.3V, not to the 5V.


How can I stock data, and send them over by serial?

There is no such thing as "all at once" with serial. The whole point of serial is that it sends things one character at a time.

It is entirely up to you to decide what constitutes one "block" of data.

There is absolutely no difference (besides some slight processing overheads) between:

Serial.print("Hello");
Serial.print(" ");
Serial.println("World");

and:

Serial.println("Hello World");

Both of them result in Serial sending:

H
e
l
l
o
[space]
W
o
r
l
d
[cr]
[lf]

No matter how you "batch" stuff together (or attempt to) it makes no difference.

You need to have:

Some way of identifying the start of a block of data,
A mechanism to receive the entire block a byte at a time, and
Some way of identifying the end of a block of data.

How you do that is entirely up to you.

Here's an example of how to arrange the storage:

class MouseRptParser : public MouseReportParser
{
    private:
        int dx[10];
        int dy[10];
        int dpos = 0;

    protected:
        void OnMouseMove (MOUSEINFO *mi) {
            dx[dpos] = mi->dX;
            dy[dpos] = mi->dY;
            dpos++;

            if (dpos == 10) {
                dpos = 0;
                for (int i = 0; i < 10; i++) {
                    Serial.print("X");
                    Serial.print(dx[i]);
                    Serial.print("Y");
                    Serial.print(dy[i]);
                }
                Serial.println();
            }
        }
};

What that gives you is a pair of 10-entry arrays, one for X and one for Y values. Each time a report arrives the current DX and DY values are stored. The pointer for where to store is incremented.  Then, if that pointer equals 10, reset it to 0 and print all the values.

I chose a format that gives you:

X3Y-2X2Y-4X6Y8X-3Y7X6Y38X176Y76X-4Y8X8Y3X39Y-32X71Y4

That is, an "X" followed by a decimal value for a change in X, and a Y followed by a decimal value for a change in Y. The whole lot is then terminated by a standard CR/LF line ending pair.


C3 not declared in this scope when running MIDI example code

The pitches for the notes are taken from pitchToNote.h. In there you can see definitions for the notes like:

#define pitchC3  48

It seems that the names were changed from C3 to pitchC3.

I am not 100% sure, but my guess is that this was done to avoid conflicts between the note A3 and the analog input A3 (and silimar).

So, in line 25 of the example code, add pitch for all notes:

const byte notePitches[NUM_BUTTONS] = {pitchC3, pitchD3, pitchE3, pitchF3, pitchG3, pitchA3, pitchB3};


Is there a way to get about a 10ns Timer resolution from an AVR CPU?

There is nothing you can do on the AVR processors that I know of, which can run on from a quite slow clock, and I think up to 24 MHz. Since your Uno / Leonardo / Micro run at 16 MHz that would be only an incremental speed improvement (to clock them at 24 MHz).
Your idea of bit-banging is interesting, but in general bit-banging is a last resort when you need extra things the hardware doesn't provide (like an extra SPI port) and in general will be slower, not faster, because it involves code rather than inbuilt hardware.
Running at 16 MHz each clock pulse is 62.5 ns which means that is the absolute most resolution it could count. I don't see why you can't count at the rate of 62.5 ns (rather than 125 ns), however that isn't 10 ns resolution.

Or, is there a stand-alone analog or digital IC that is able to read at 10ns intervals pulses that an Arduino can process?

Very likely. There are probably dedicated counting chips that would do that for you. I haven't looked, but it is the sort of thing there would be a market for. Such a chip would probably use I2C or SPI to communicate, which is easy enough to interface to.


Step 1) Check RX TX connections
Step 2) Change your baud rate to 115200. Turn off your arduino. Turn off gsm. Start your gsm first and then your arduino.

or
Step 3) Upload Software Serial code and just send "AT" without quotes using serial monitor. If your connections are correct you should get reply as AT.
Also make sure to set the baud rates to 115200.
Most of the GSM modules have default baud rate at 115200 or have auto baud adjustment enabled but need to be power cycled.


Sorry, but your code is complete nonsense. The following code gives you an example. I have no access to a compiler at the moment, so there might be syntax errors and it is completely untested. Also, you gave no complete description of the things you want to do. e.g when to switch on the green LED or what the up and down variables are for.

And there might also be timing problems. In order not to miss a reed state change,
you should avoid adding delays and slow serial print outs.

I'm pretty sure, I did your homework. So my advice is to learn programming and try to understand. Homework was not ( only ;-) ) invented to enjoy the teacher, they help you through tests. ;-)

Your problem is similar to the decoding of a rotary encoder, so information about this subject might help you also.

const int REED_PIN1 = 2;
const int REED_PIN2 = 3;

// LED pins - active-high
const int RED    =  9;
const int GREEN  = 10;
const int YELLOW = 11;

int fixedState1 = HIGH;
int fixedState2 = HIGH;

void setup()
{
   // If the pin reads low, the switch is closed.
   pinMode(REED_PIN1, INPUT_PULLUP);
   pinMode(REED_PIN2, INPUT_PULLUP);

   pinMode(RED, OUTPUT);
   pinMode(GREEN, OUTPUT);
   pinMode(YELLOW, OUTPUT);

   digitalWrite(RED, LOW);
   digitalWrite(GREEN, HIGH);
   digitalWrite(YELLOW, LOW);
}

void loop()
{
  // AS LONG AS BOTH SWITCHES ARE ON AT THE SAME TIME,
  // THE PROGRAM FLIPS OUT ;-)
  int reedState1 = digitalRead( REED_PIN1 );
  int reedState2 = digitalRead( REED_PIN2 );

  if ( readState1 == LOW && fixedState1 == HIGH )
  {
    if ( fixedState2 == LOW )
    {
      digitalWrite( RED,    HIGH );
      digitalWrite( YELLOW, LOW  );
      digitalWrite( GREEN,  LOW  );

      fixedState2 = HIGH;
    }
    else
    {
      // setting the green LED is just a guess
      digitalWrite( RED,    LOW  );
      digitalWrite( YELLOW, LOW  );
      digitalWrite( GREEN,  HIGH );

      fixedState1 = LOW;
    }
  }

  if ( readState2 == LOW && fixedState2 == HIGH )
  {
    if ( fixedState1 == LOW )
    {
      digitalWrite( RED,    LOW  );
      digitalWrite( YELLOW, HIGH );
      digitalWrite( GREEN,  LOW  );

      fixedState1 = HIGH;
    }
    else
    {
      // setting the green LED is just a guess
      digitalWrite( RED,    LOW  );
      digitalWrite( YELLOW, LOW  );
      digitalWrite( GREEN,  HIGH );

      fixedState2 = LOW;
    }
  }
}


How can i call lcd.begin() from several different code files in a proper way?

The object called lcd that you create inside the setup function is a local variable. It only lives as long as that function is executing - so not very long. It doesn't exist outside that function.
The lcd object you have in namespace display on the other hand is a global variable. That one lives as long as your program, which means until you reset your Arduino here. (It is completely unrelated to the object inside setup.)
If you want all your LCD code to be grouped inside the display namespace, you could do this in Display.cpp:
namespace display {
  // This is a global variable, full name `display::lcd`
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

  void setup() {
    // this `lcd` refers to the global `display::lcd` defined above
    lcd.begin(16, 2);
  }

  // rest of the display functions
}

Create a Display.h file to provide prototypes for the display module:
#ifndef DISPLAY_H
#define DISPLAY_H

// Include the header that defines InputPacket and DataPacket here

namespace display
{
void setup();
void displayData(const InputPacket &inputPacket, const DataPacket &dataPacket);
}

#endif

Then your main file can call the display function. The main file doesn't even have to know that you're using an LCD if you do package all LCD code in the display file.
#include "Display.h" // no need to include LiquidCrystal.h if all
                     // LCD handling is done in Display.cpp

void setup(){
  // Initialize display
  display::setup();
}


Problem with analog pins' name when trying to connect Arduino board and Processing

(as suggested in comments to bump it down)

your code works ok with me. I've shorted the 3.3v to analog A0 and your code fluctuates between 679~680 in processing

If it helps, this is the software versions I'm using: Processing - 3.0.1 Arduino IDE - 1.6.6 Firmata - 2.5.0


Why voltage at AREF is given by Vin * R2 / Rtotal

You are correct.

$$V_{ref} = \dfrac{R_1}{R_1 + R_2} \cdot V_{CC}$$

or Vref = Vin * R1 / (R1 + R2) until we finally get MathJax enabled on this site.


Get hour with ctime (time library with ESP8266)

The easiest way is to use the standard function localtime() or gmtime() and the struct tm.

void loop() {
  time_t now;
  struct tm * timeinfo;
  time(&now);
  timeinfo = localtime(&now);
  Serial.println(timeinfo->tm_hour);
  delay(1000);
}


how to make transmitter and receiver for quad copter?

The APC220 radio module provides a simple and economic solution to wireless data communications. Integrates an embedded high speed microprocessor and high performance IC that creates a transparent UART/TTL interface, and elminates any need for packetizing and data encoding. Use this module as this works as a pair and more intriguing part is that "it" can transmit over a km away.

link ~http://www.dfrobot.com/index.php?route=product/product&filter_name=apc&product_id=57#.VWeKIVWqqko


You cannot. There is no PWM on that pin. PWM is generated by hardware. The hardware simply does not exist.


Why does my Arduino freezes when i turn a servo

You said that you were using 4x 1.5v batteries. That would make a total of 6 volts. The current that those batteries can supply is also little.

The Recommended Input Range is 7-12 volts. And the Limit is 6-20 volts.

You were supplying it with 6 Volts which is at the very limit of the Input Voltage Range. When the motor runs, the Voltage might have dropped and made the arduino freeze.

The fix is to supply the arduino with another source such as a benchtop supply that can supply more than 8 volts.


Trust what is on the board, not what the eBay seller says. They invariably can't tell the difference between a TFT screen and a doll, and they sell everything in between. They just regurgitate Chinglish nonsense. If the board says DB0-DB15 then DB0-DB15 is what you need to use.

Plus it says in the description:

  Support 16 bit RGB565 format , can connect any 16 bit data bus.

At least this one has told you what the driver chip is (OTM4001A) - many times they can't even do that and don't even understand what you are asking when you request that information.

Mind, it's a driver chip I have never come across before, so maybe I should get one on order to support it in DisplayCore...


Can't retrieve data from X-NUCLEO-IKS01A1 using I2C protocol

You're using a wrong slave address. From the datasheet:

  The Slave ADdress (SAD) associated to the LSM6DS0 is 110101xb. The SDO/SA0 pin can be used to modify the less significant bit of the device address. If the SDO/SA0 pin is connected to a voltage supply, LSb is ‘1’ (address 1101011b), else if the SDO/SA0 pin is connected to ground, the LSb value is ‘0’ (address 1101010b). This solution permits to connect and address two different inertial modules to the same I2C bus.

This means your sketch should contain:

#define ADDRESS 0x6A  // if SDO pin is pulled down

or:

#define ADDRESS 0x6B  // if SDO pin is pulled up

It's also a good idea to check if there's actually anything in the Wire buffer (with Wire.available()) before you attempt reading.

Finally, I suggest you read both OUT_TEMP_H and OUT_TEMP_L registers, in order to calculate the temperature correctly. The datasheet says the temperature output is zero at 25 degrees Celsius and that the sensitivity is 16 LSB/C. This means you have to read both registers, combine their results to get a 16-bit signed integer (OUT_TEMP_H is the MSB), divide it by 16 to get the temperature offset, and add the result to 25 degrees Celsius to get absolute temperature.


>> is right shift a value by a certain number of bits.
<< is left shift a value by a certain number of bits.
-> is accessing a member of a class or struct that is referenced by a pointer.
Right Shift and Left Shift
If you have a binary number 0b00010000 and right shift it two bits you get 0b00000100. The C notation for that is val >> 2.  The same for left shift - val << 2 would result in 0b01000000.
Pointers and members
Normally when you access a member of a class or struct you use ., such as Serial.println().  However it is possible to make a pointer to a class instance, and when you do you need to access the members with -> instead of . - such as mySerial->println().
This arrow notation serves as syntactic sugar: mySerial->println() is interpreted as (*mySerial).println(). The parentheses are necessary because the dereferencing operator * has a lower order of precedence compared to the dot . operator.


How do I statements for the various conditions of this function?

You will have to explicitely expand the case ClickEncoder::Pressed. So instead of

VERBOSECASE(ClickEncoder::Pressed);

you should write something like

case ClickEncoder::Pressed:
    Serial.println("ClickEncoder::Pressed");
    digitalWrite(ledpin, HIGH);
    break;

Of course then you'll have to turn it off then, but.. Well, that's another problem


The Dx pin labels on NodeMcu and Wemos/Lolin boards do not correspond to esp8266 internal io pin numbers. The pins_arduino.h file in core defines Dx constants which map internal io numbers to Dx labels.

Use RF24 myRadio(D7, D8);


Can't manually connect HC-05 master to slave

I found the solution.

Apparently, both of my modules were at 9600 baud rate when the optimal rate is of 38400. I had to use AT+ORGL in command mode to reset both slave and master. Afterwards I was able to connect them manually.

So apparently ERROR:(7) represents a failed connection? Just don't forget to make sure everything is exactly like the tutorial that's teaching you.


How to communicate between a webcam and an Arduino UNO and get the live feed on mobile using ESP8266?

The Uno is a very limited platform, perhaps surprisingly, given its wide range of abilities and built-in hardware features. The two most glaring limitations for you application are its 16MHz clock speed (relative to modern desktop processors) and thus its bandwidth, and it's non-expandable 2KBytes of RAM.

Image processing would be right out the window, and even merely transmitting a raw image would be pushing its bandwidth limits, for any reasonable frame-size with even a very modest frame-rate.

Example: For a 100x100 8-bit frame at 15 frames/sec, a 16MHz processor (16M instructions per sec) would have (16000000 / (100x100x15)) = ~107 clocks (instructions) available to process each byte. You'd need some of those to either poll for next-byte-ready or to enter and exit an Interrupt Service Routine to process the byte. You're probably up to around 20 clocks (at a wild guess), to do nothing more than a bit of wire can do! Maybe you could do some trivial manipulation of each byte on the way through (say, brightness manipulation) with a few more clocks and you're already using a significant fraction of the processor just for that. And there isn't enough memory to be able to process a region of the image. And if you could, you run out of processor time before you could do much .... The problem just cascades as you approach the limits of speed and memory-space.


Is it possible to transmit Longitude and Latitude via RF433MHz?

If you are using Xbee modules in your project, why add 433MHz RF, just for the sole purpose of transmitting the location?  With the 433Mhz, you will have to implement error-correction yourself.


Esp8266-01 AT commands returns random chars and/or "ERROR"

The problem is mainly in using Serial and SoftwareSerial together. Or it can be due the esp getting less current than it requires from the Arduino(you are also damaging your Arduino!), use an external 5V source (I use my computer USB)

Why dont you directly use Serial for communication with pins 0 and 1. Just upload a blank sketch, connect Arduino Tx, Rx to esp's Tx, Rx(reverse Tx, Rx if not working). What you type into Serial will then be sent to the esp. Later if you wish to communicate to esp in sketches, use only SoftwareSerial.

Also, the esp is not 5V tolerant so you need to use a level shifter(like the cd4050 ic) or a voltage divider(less efficient) for signals from the Arduino to the esp. 3.3V is considered as a logical HIGH so you dont need to do any changes for signals from esp to the Arduino.

I highly recommend getting a USB TTL converter, this will save you a lot of headaches and debugging will be easy. I did things without it for 1-2months and now I can totally feel the difference.


HC-06 Bluetooth RX & TX voltage (3v3 || 5v)

Some chips that run on 3.3v have 5v tolerant inputs. But it doesn't look like the BC417 does (looking at the datasheet).

So just add the voltage divider.


Forcing bootloader startup through program

Theoretically it is quiet easy to fake that double-tap with software, but there might be some obstacles in practice.
The bootloader uses an unsigned long value in RAM memory to indicate if the double tap happend. The actual bootloader for the zero uses the following definitions.
// zero specific; but other boards use the same values AFAIK
// (in board_definitions_arduino_zero.h)
#define BOOT_DOUBLE_TAP_ADDRESS  (0x20007FFCul)
#define BOOT_DOUBLE_TAP_DATA  (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))

// for all bootloader (in main.c)
#define DOUBLE_TAP_MAGIC 0x07738135

When the bootloader is started after a reset, it checks, if that was a power on reset (POR) or not. If it has been a POR, it sets the indicator value to 0 BOOT_DOUBLE_TAP_DATA = 0;.
If it does not detect a POR, the bootloader continues with checking the indicator value whether it is set to the tap magic.
If the magic can be found  the indicator value is set back to 0 and the bootloader is started. Otherwise the value is set to the "double tap magic": BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC. The bootloader waits for 500 ms to let the user reset the zero a second time (double tap) and resets the indicator value after that time interval.

How to:
To simulate a double tap, you just need to set the indicator variable with the magic value from within you program. Use the definitions above. Then perform a software reset.

The caveats:

If the bootloader was changed, that could make you code useless.
I have not the time to test my ideas, so this is just an unverified method. It might fail for some reasons, I do not see actually.
You have to find a method to reset the zero with the program. Iknow some methods but I've not tried any of them so far.

Reset Methods: (as a starting point for your search)
I've read somewhere that the zero supports the CMSIS method NVIC_SystemReset.
This is a method often used for M0 ARM controllers (like SAMD11).
SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;

Here is my code "idea" (untested):
#define BOOT_DOUBLE_TAP_ADDRESS  (0x20007FFCul)
#define BOOT_DOUBLE_TAP_DATA  (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))
#define DOUBLE_TAP_MAGIC 0x07738135

// lots of code ....

void resetWithDoubleTap()
{
   BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
   NVIC_SystemReset();
}

I would be lucky, if you succeed with this. Please let us know your outcomes, either write your own answer or tell me what you've done and I will correct my answer if necessary. Good luck.


Arduino Obstacle Avoiding Shield controlor motor L293D

To complete @chrisl answer: Yes you need these pins to make the same robot as in the video. You can order them online and solder them (if you know how to solder and if you have the soldering material). Be careful with soldering ;)

For your information, the pins you circled in red are used to communicate with the Arduino pins A0 to A5, and provide +5V and GND. In the video, they are connected to the ultrasound sensor.

And please clarify what is your motor??? Do you mean the Shield motor driver? It is not the same. A shield is an eletronic board that you plug to your Arduino to do a specific task (control a motor, connect to wifi...). A motor driver is the electronic to control the motor. On your pictures, they are mainly the 3 components with 16 legs each.


Arduino Yun & nRF24L01+ -> Linino crashing

I finally managed to get it running. It really seems to be a problem with radio interference. I failed to hook up an external WLAN antenna to the Arduino Yun mini but I found a very useful workaround with a usb adapter here:
http://www.lucadentella.it/en/2014/11/08/yun-adattatore-wifi-usb/

This workaround is possible with an Arduino Yun mini as well but you'll need the Arduino Yun Linux OS from here:
https://www.arduino.cc/en/Main/Software

because the necessary packages are not available for the Linino system that comes with the Yun mini. Then, you can connect the WiFi adapter to USB+, USB-, 5V and GND of the Yun mini and you're good to go.


This schematic shows a complete connection of a blinking led.

Red cable = +5V (pin 8)
White cable = Ground (pin 4)
Resistor = 1 end at pin 5 (IO 0) and the other in the LED anode (+)
Led anode (+) in the resistor, cathode (-) (small leg) in the ground
Resistor = 330 Ohms

The arduino in the picture is not necessary, just used to give power. But in the video linked below its used to burn the ATtiny85. The resistor can be a 330 ohms for a simple project like this.

Youtube Video with a simple explanation

I hope this explanation will enlighten who wants to start on it.

--

Edited:

If you want to record your ATtiny85 using Arduino UNO as ISP, then you will also need:

10 uF electrolytic capacitor

Here a picture of the pins:


The last loop exceeds the limits of 8 Digits. You iterate 9 times (0-8).

   for (int a = 7; a >= 0; a--){
        lc.setDigit(0, a, a, false);
        delay(100);
    }


MCU Recommendations for Audio Pitch Shifting

I get the impression that you haven't done this sort of thing before, on any scale. Pitch shifting is a totally non-trivial process.  I suggest you start out on a regular computer and try to get a single channel working to your satisfaction.  Then, if you are still determined to do this on a smaller system, you will at least know what you are up against and will be able to decide what systems are appropriate.  Sorry if it sounds like I'm trying to throw cold water on your idea, because I'm sure it would be a fun instrument to play.  But I think you would be getting in way over your head if this isn't already your field of expertise.


Is Teensy compatible with the Arduino keyboard library?

It looks like the Teensy designer uses the standard Arduino mouse and keyboard library:

https://www.pjrc.com/teensy/td_keyboard.html

On another note, I'm sure Teensy is a fine product, but I prefer other open hardware solutions like Pro Micro which can be had on AliExpress.com for  under $4 ea.


How to program for two Arduinos with different code but share one same .h?

I confronted this exact issue a little while back when writing some sketches that hard shared information. In particular github.com/nickgammon/arduino_sketches

Whilst another IDE may help, I wanted to make my sketches usable by people with the default IDE.

There are a few (annoying) issues here:

You can't use relative folders as suggested in another answer, because the IDE copies your current sketch folder to a temporary folder and compiles from there. It won't copy other nearby folders that happen to be mentioned in .h files.
You can make soft links (in Linux anyway) as suggested, however that makes it hard to do Git control on them. My first attempt had the link (only) appear in GitHub, which meant that the links didn't compile, once you downloaded them (via the .zip file option in GitHub).
I switched to hard links, but then had another issue. If you edit a file in the IDE, and save it, evidently this becomes a new file, and so the files in other folders, which are now hard-linked, have the older version and not the newer version.

The best solution I could come up with (and I am open to suggestions) was to have a "master" sketch - which has the "real" files you want to include. The other folders have links to them. However if you change the master folder you have to recreate the hard links. I wrote a shell script to do that, but it is still an ugly solution. However since it is a manual process anyway, under Windows you could simply make a copy of the files, when you change the master one.

The other (simpler) alternative would be to make a library, and then simply change the files in that library. That gives you better Git management. The only thing is that you have to edit the library, and then go and test the sketch. It's not that bad.

  And I found that after I added the h as library, no matter how I change the content of the h, the first version is always used in ide.

That shouldn't happen unless the IDE doesn't expect the library to change in-between compiles. If that is the case, even the library idea has flaws.


Is it ok to declare variables inside timer interrupts?

The problem is i need more arrays like this...

you probably want to take a look at your processing flow to see if you need all of them at the same time. if you do, well, there is no alternative but to get a bigger chip.


I think you are overestimating the size of wire required to attach to the LED strips, I have connected a lot of single color LED strip (in excess of 1mtr) with the wire that was already attach and it was reasonably light gauge.
Look at this Example on Ebay and you can see what i mean.

I am note an Electrical Engineer so i don't know the method to calculate the minimum wire gauge, but if in doubt contact the manufacturers and ask them or search on the web.

As for the Transistor mounting/wiring you would mount that on a small circuit board with terminal block fitted for ease. Any power/connecting wire should not be less that used to the LED strip.

Also you will need a current limiting resistor attached to the Base pin on your transistors. You will have to work out the value of that based on the spec sheet.

There is a bit of learning required first, once you have researched the above you will have you exact answers.


Your code:

int speedpinA=9;//enable motor A
...
int speedpinB=10;//enable motor
...
 analogWrite(speedpinA,spead);//input a simulation value to set the speed
 analogWrite(speedpinB,spead);

See https://www.arduino.cc/en/reference/servo

  On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

(My emphasis).

So, you can't do that, exactly. Perhaps choose other pins for the analogWrite, pins that analogWrite supports, that are not 9 and 10.


take a look at the datasheet, compare it vs. your code for any incompliance.

based on my quick reading, your code isn't consistent with the datasheet.

put the communications in a routine would help maintain uniformity.


How does Arduino IDE for OSX work without drivers?

Windows 8.1 is the last version of any common desktop system that requires CDC/ACM (that is what the Arduino's USB port is) drivers.

OS X is based on BSD which, like Linux, has had CDC/ACM drivers built in since (pretty much) the dawn of time. It is only really Windows that has had the concept of drivers for anything that isn't vendor specific and/or complex (such as video cards, or devices that don't adhere to published standards).

Even Windows 10 now has the drivers for CDC/ACM built in (it's only taken Microsoft 20 years or so to catch up with the rest of the OS world).


Arduino connected keypad printing wrong numbers


Setting a pointer to NULL in Arduino library - error: ‘NULL’ was not declared in this scope

You should make sure your header includes the stddef.h header, which holds all these standard definitions (hence its name):

#include <stddef.h>


Are there any good and maintained libraries for using DS2482 I2C to 1-Wire bridge?

I believe the library linked by Cybergibbons has a bug in

uint8_t OneWire::wireSearch(uint8_t *address)

A discrepancy at i = 0 (bit zero in this library, id_bit_number = 1 in a Maxim example) only follows the direction = 1 path and fails to find ROM addresses where bit zero = 0 (i.e. even family codes are missed when mixed devices, some with even and others with odd family codes, are present on the 1-wire bus).

A fix I have just implemented and appears to work is to modify the library to declare searchLastDiscrepancy and last_zero as int8_t (not uint8_t), initialise/reset them to -1 (not zero) and, near the end of the method

    if (!last_zero)
            searchLastDeviceFlag = 1;

becomes

    if (last_zero == -1)
            searchLastDeviceFlag = 1;

I hope that helps.


How to control a DC Motor with Hall Encoder using Arduino and Motor Driver?

What are the "m1" and "m2" pins you mention?

On the diagram I see on that link, the pins "1-M1 motor -" and "6-M1 motor +" should be connected to the motor driver. The other four pins should go to the Arduino only.

You can probably test the motor by disconnecting it and connecting pins 1 and 6 to a 9-12V battery or similar, to see if it turns.

By the way I guess the two Encoder Phase connections would be set up on the Arduino using PinMode setting "INPUT_PULLUP". But as you can already read the positions, that part may not matter.


The label CLK on esp8266 is in a context of SPI pins CLK, MISO, MOSI, SS. You had no reason to connect TM1637 CLK to this pin, since with TM1637 you can use any GPIO pins of the MCU for CLK and DIO.


Failing to read from DHT22 when multiple components on breadboard

First off:
Welcome to Arduino Stack Exchange
Hopefully we can help you here, but you really need to include a lot more information in your question. You really haven't given us anything to work on here and should include as a minimum:

what other sensors you are using, including protocols and model numbers
a circuit diagram (or a very detailed verbal description of your connections)
your source code including the libraries you are using (no need to list the library code, just the #include line will do)

At this early stage I would guess you are using incompatible sensors. The DHT22 is a 1-wire device, but not all 1-wire devices are the same. It would be certainly possible to run multiple protocols on one pin, but you'd really need to know what you are doing, and it would be preferable that you didn't.
It could also be that you're mixing protocols and have completely incompatible sensors clashing. Especially if you've got something else on the line that is trying to be the master.
Include some more info, with photos and/or a circuit diagram and code and hopefully we can get you on your way.


Extra "zero" displayed on LCD when integer sent from PC to Arduino through serial port

The Serial.parseInt returns zero when it can not find a number within a timeout. That timeout is default one second.
When a number is typed in the serial monitor, often a linefeed is added to it. That linefeed is read by Serial.parseInt. It can not make a number out of that and waits until the timeout and returns zero.

There is no way to tell if the Serial.parseInt returns zero because the number was zero, or if it returns zero because there was a timout.

You can try the next sketch to show the problem. Set the line ending in the serial monitor to linefeed or carriage return or both or nothing and see what happens.

int a;

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

void loop() {
  Serial.println("Enter a number");
  while(Serial.available()==0){}
  a=Serial.parseInt();   // it returns zero with a linefeed !
  Serial.println(a);
}

The easiest way to fix this, is to use a number that is only a single digit. The function isdigit is used to check the incoming characters.

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

  Serial.println("Enter a number (a single digit)");
}

void loop() {
  if (Serial.available() > 0) {
    int inChar = Serial.read();
    if (isdigit(inChar)) {
      int value = inChar - '0';
      Serial.println(value);
    }
  }
}

The Serial.parseInt is not completely useless, but the number zero can not be used. The next sketch ignores the input when Serial.parseInt returns zero.

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

  Serial.println("Enter a integer, but not zero, with a linefeed at the end");
}

void loop() {
  if (Serial.available() > 0) {
    int value = Serial.parseInt();
    if (value != 0) {
      Serial.println(value);
      Serial.println("Enter a integer, but not zero, with a linefeed at the end");
    }
  }
}

To be able to allow to type the number 0, the Serial.parseInt can no longer be used. To avoid waiting and delays, every character is immediately put into a buffer. The sketch becomes larger, but there is no other way. Either use Serial.parseInt or do it right.

#define BUFFER_SIZE 40
char buffer[BUFFER_SIZE];
int index;

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

  Serial.println("Enter a integer, with a linefeed at the end");
}

void loop() {
  if (Serial.available() > 0) {
    bool ready = false;

    int inChar = Serial.read();
    buffer[index] = (char) inChar;
    index++;
    if (index >= BUFFER_SIZE) {
      index = BUFFER_SIZE - 1;
      ready = true;
    }

    if (inChar == '\n' || inChar == '\r') {
      ready = true;
    }

    if (ready) {
      if (isdigit(buffer[0]) || buffer[0] == '-') {
        buffer[BUFFER_SIZE - 1] = '\0';
        int value = atoi(buffer);
        Serial.println(value);
        Serial.println("Enter a integer, with a linefeed at the end");
      }
      index = 0;
    }
  }
}


Since the format is just = , I'd parse it this way, instead of relying on newlines.

Just treat them as whitespace. So buffer all data till an = sign is found, store the buffer as the variable name, then read until you get something other than a digit or decimal point. Then store this as the value. Then do something with the value based on the variable name. Then read and ignore all following whitespace (spaces, tabs, newlines, carriage-returns). And start back from the top.

That way the parse will never get out of whack when some data get missing or something else goes wrong in the serial stream.


How to upload and play music file directly to ATMega328 arduino nano

The website below will give you the full information on how to do it. You will need a speaker connected to a PWM pin (I think that pin 3 on the Nano should be one of these kind of pins).

You can download the extension for the IDE to play your music and a program, on which you will convert the .mp3 files to a numeric format, which you will then paste in your program.

http://highlowtech.org/?p=1963


While the motor is being powered the current flows from Vcc to GND as in this circuit:

When the power is disconnected (such as the transistor in the ground connection in your circuit is switched off) amongst other things (including the collapsing of magnetic fields) the spinning of the motor turns it into a generator.  The power generated is the opposite of what was being provided to make it move.  As the magnetic field of the coils collapses additional high voltages are also generated.

When disconnected the motor can be represented as a battery connected backwards.  In that configuration the current flows from the + of this hypothetical battery through the diode into the - thus stopping any current from going elsewhere, as in this circuit:


Well, it turns out that the tx/rx for the board are connected to the standard pins 0 and 1 on the Arduino.
To use this, you can simply use Serial.write.
Of course, remember to take of the module when trying to upload your code.....


VDC is an abbreviation for volts DC. DC means Direct Current you can read more a detailed explanation about it here. Basically what powered by 1.8 to 5.5 VDC means is that the DC voltage on the input of your sensor can vary from 1.8 volts up to 5.5 volts. So you can use either 3 AAA batteries in series since the sum of their voltage will be: 1.5V * 3 = 4.5V what is in the range of recommended voltages for your sensor. Also, you can use a Li-ion battery in order to power your sensor since the voltage of this type of battery is 3.7V it is also in the range of recommended voltages for your sensor. However you would need an additional charge/discharge module in order to recharge and keep the battery in a good condition. You can read more about it on the web.


First of all do yourself a favour and listen to your IDE

This report would have more information with
 "Show verbose output during compilation"
option enabled in File -> Preferences.

and in an if else there is no in between so either let it run as a state machine especially inyour case A != B != C != other:

void subfunction(){
  if(A){
  // code to run
  return;
  }
 yield();
 if(B){
  // code to run
  return;
  }
 yield();
 if(C){
  // code to run
  return;
  }
 else{}  // to catch if not A or B or C
 yield();
}

or implement switch case (Pseudo code)

 switch(fromClient){
    case "LR":
      //code to run
      yield();
      break;
    case "RR":
      //code to run
      yield();
      break;
    default:
      //code to run
      yield();
      break;
  }

Id else chains are prone to errors as in your case its A != B != C != other


Save Leading Zero HEX into String RFID RC522 Arduino

String(mfrc522.uid.uidByte[i], HEX) means you want to convert number into hexadecimal string repesentation, if you pass 4 as input parameter, it will convert it into "4", not "04". You need to apply similar approach as you have used when printing the value through UART. For example:

if (String(mfrc522.uid.uidByte[i] < 0x10)
  inStringHex += " ";
inStringHex += String(mfrc522.uid.uidByte[i], HEX);

Personally, I would recommend switching from Strings into static buffers (because arduino has too small memory to use dynamic allocation and there could be issue with running out of memory due to memory fragmentation):

char id[16];
sprintf(id, "%02x%02x%02x%02x", mfrc522.uid.uidByte[0], mfrc522.uid.uidByte[1], mfrc522.uid.uidByte[2], mfrc522.uid.uidByte[3]);


10k ohm Potentiometer vs 10k ohm Resistor on LCD Display

No, it would not be correct to use a single resistor to replace a potentiometer.

On an LCD the potentiometer is used to adjust the bias level of the LCD - that is the contrast.  You need to use it to set a voltage between Vcc and Vee, which you feed into Vo.  That is, a voltage somewhere between +5V and -5V.

You can't do that with one resistor.

You can, however, do it with two resistors.  Some experimentation will provide the right values to use.  Pick a pair of resistors which add up to around 10K (the exact value doesn't matter that much) and join them together end to end.  The two ends are the equivalent to the ends of the track of the potentiometer, and the join in the middle is the wiper.

To change the "value" of the potentiometer you then need to change the value of both resistors.  If you reduce one resistor you need to increase the other so that they still add up to around the same value.  What you are working with here is not the actual values of the resistors, but the ratio of the values of the two resistors.


Use Raspberry and Arduino IDE to programm ESP8266

Have you tried installing Python for Windows?

http://docs.python-guide.org/en/latest/starting/install/win/

In theory it should work and you should be able to run esptool.py on a Windows command line like you do on your Pi (provided that your usb to serial in recongnized by Windows).

If esptool.py fails to run under Python for Windows I would first suggest to open a ticket with the esptool maintainer and then try under a cygwin environement (https://www.cygwin.com).


the maximum frequency is around 1000 pps

Arduino pin operations takes about 100 ticks. Or 400 ticks for four pins. No more than another 100 ticks for processing and logic ops. So I would expect 500 ticks or 30k on a 16mhz Arduino.

Much faster if you use direct pin ops.

So maybe the code you used isn't well written or your Arduino is doing lots of other things?

edit:

  I found my solution. Code:

there is no reason for you to repeatedly initialize the module. this thing is simple, and others have laid out the thought process for you. write a set of routines that spin the motor - spin it left, spin it right. and then call those routines in a timer isr. nothing fancy here.


Error while trying to drive relay through the state of a digital input pin in Arduino

Assuming your circuit is correct (and perhaps it is, since you imply that it works some of the time), the first obvious problem is that when you press the button, the code will repeatedly toggle the output, very very fast.  It may seem to you like you're only pressing the button for a moment, but the code will loop many many times.  When you release the button, it's a 50/50 chance whether it leaves the relay on or off.

To solve this, you can wait until the button is released before checking again.

In addition to this, you may have switch bounce.  There are nicer ways of fixing this, but for your stated purpose, waiting 0.1s after a releae before checking the button again is probably sufficient.

....
void loop() {
  if(digitalRead(enable1) == HIGH)
  {
    if(led1_OnOff == true)
    {
      led1_OnOff = false;
      //+digitalWrite(led1, LOW);
    }
    else
    {
      led1_OnOff = true;
      //digitalWrite(led1, HIGH);
    }

    // Wait for the button to be released
    while(digitalRead(enable1) == HIGH)
    {
      // do nothing, just wait
    }
    // Poor-man's debounce
    delay(100);
  }

  if(led1_OnOff == true)
    digitalWrite(led1, HIGH);
  else
    digitalWrite(led1, LOW);
}


Can tx and rx pins on the uno be used like regular digital pins?

Yes you can perfectly use these 2 pins as long as your program does not use Serial.

EDIT: Serial data over USB goes through copper traces connected to the rx and tx pins, connecting them to the USB to serial converter chip.


Problems with (somewhat) large boolean arrays

According to http://arduino.cc/en/pmwiki.php?n=Reference/BooleanVariables, "Each boolean variable occupies one byte of memory." Meaning you are trying to use 4032 Bytes of RAM with your array which I assume you do not have (whatever this unofficial Arduino is -- it's likely to be less than that: the ATmega328 of the Arduino Mini has 2 kB of SRAM, the ATmega32u4 of the Micro has 2.5 kB).

You could try with a quarter of the field size for a start and see if that makes your problems go away.