We’re rewarding the question askers & reputations are being recalculated! Read more.
80

Introduction to SPI The Serial Peripheral Interface Bus (SPI) interface is used for communication between multiple devices over short distances, and at high speed. Typically there is a single "master" device, which initiates communications and supplies the clock which controls the data transfer rate. There can be one or more slaves. For more than one slave,...


23

Those aren't the only frequencies available for the PWM signals. However, they are the frequencies as determined by the applied prescaler (which you can readily change as detailed below). Each of the 3 pairs of PWM pins is tied to one timer, each of which has its own base frequency, as follows: Pins 5 and 6 are paired on timer0, with base frequency of ...


8

I am not aware of the design considerations, but if you check the datasheet for the microcontroller on your Arduino, you will notice that PWM pins are grouped together and per group connected to a timer. The speed at which this timer is increased varies by the configured prescaler. If you change the prescaler for a certain timer, you change the PWM frequency ...


7

If you know Ohm's Law (which you should) and you realise that the ADC measures voltage, you should be able to work it out from there. But I will go into minute detail for you to ensure you understand. Ohm's Law defines the relationship between Voltage (V), Current (I) and Resistance (R). R = V/I To find one unknown value (in your case R) you need to know ...


7

did somebody come across such case, or I'm the first in the world? You are not the first. I recently got bitten by the very same issue. However, unless you are close to an unusually strong radio source, I do not think it has anything to do with electromagnetic interference. In my experience, the internal pullup is perfectly reliable for reading switches ...


6

Reading the answer from Gerben I realised the core of the issue: The TX/RX LED's on the Leonardo are wired PIN-LED-5V(common anode), whereas on the Olimexino-32U4 they are wired PIN-LED-GND(common cathode). So the two boards will need inverse signals for the same visual output. Compare: http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf ...


6

int A0, A1,A2,A3,A4; delay(200); A0= analogRead(A0); A1= analogRead(A1); A2= analogRead(A2); A3= analogRead(A3); A4= analogRead(A4); Your local variables (A0 through A4) are shadowing the global variables for the pins (A0 through A4). Give your local variables different names.


6

From looking at the source it appears that on 32u4 based boards Serial includes extra methods to access the settings from the USB host: see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129 From USBAPI.h: // These return the settings specified by the USB host for the // serial port. ...


6

All of those "A1" "A2" pins have other numbers that go with them. The A1 or A2 is #defined in the core to be some number. You can just use A1 or A2 and it will work. For example, try this line and see what it prints: Serial.println(A0); And for your pins, just put A0, A1, etc. in your int array and leave the quotes off. Those symbols are being ...


5

The teensy series from pjrc.com allows USB MIDI natively (full USB speed!). It works well and does not require any firmware tomfoolery. It can also do HID keyboard/mouse/joystick natively as well. There's the 2.0, which is 32u4, and the 2.0++ which has more pins and memory. If you want to step off the Atmel reservation the teensy 3.0 and 3.1 have more ...


5

You could do a qsort. You haven't posted any data types so it is hard to answer with your specific code, however here is a sample of sorting numbers: const int COUNT = 10; int someNumbers [COUNT] = { 7342, 54, 21, 42, 18, -5, 30, 998, 999, 3 }; // callback function for doing comparisons int myCompareFunction (const void * arg1, const void * arg2) { ...


5

The USB does not go to pins 0 and 1. The UART goes to pins 0 and 1 - that is a totally different interface. The USB is connected to dedicated USB pins on the chip. If you look at the Leonardo schematic you can see it is pins 3 and 4 on the chip. Note that that is not pins D3 and D4 on the board, but the third and fourth pins anti-clockwise from the "pin 1"...


5

There seems to be quite a few Arduinos without a 32U4, like: Uno (you mentioned it already) Mega (same) Lilypad Snap MKR1000 Pro Pro Mini Zero Due Ethernet Mini Nano MKR Zero See the list at Comparison table.


5

The Leonardo should wait a couple of seconds after resetting to see if a new sketch arrives. Power off the board completely (remove the USB cable). Hold down the Reset button, and keep it held down (or, run a jumper wire from the RESET pin to the GND pin). This stops the problem sketch from starting. Still holding down Reset, reconnect the USB cable. Start ...


5

Welcome to SE. digitalWrite() takes a few microseconds to execute as well. There is also some overhead around the delayMicroseconds() function. I you need exactly 500 kHz, you would want to consider using a timer. You can read up on how to set one up in the microcontrollers datasheet. Unfortunately, I don't have access to an Arduino Leonardo, but here is ...


4

Please note the SPI clock will only be active while it is shifting data. So simply put the spi.transfer in a hard loop #include <SPI.h> void setup() { SPI.begin(); while (1) { SPI.transfer(0x00); } }


4

This is because on ATmega 32u4, which is used in Arduino Leonardo, pins 5 and 7 are not mapped to port D but to port C and E respectively, as you can see in the ATmega 32u4 - Arduino Pin Mapping. So you will have to: either find another port where all 8 bits are available as digital outputs (note that I'm not sure one such port exists) or split each sine[...


4

As somebody else suggested, 9V batteries are pretty weak. They only provide a very small number of mAh (milliamp/hours) before their voltage starts to drop. Once the voltage drops to around 7 volts, the regulator in the Arduino can't keep providing 5 volts, so your Arduino resets. Wire up 6 AA batteries in series. That will provide a much "stiffer" 9 volt ...


4

Power steering is performed by the assembly labelled "+5V AUTO SELECTOR" at the bottom of the page. The voltage at VIN is halved and then compared with the board's 3.3V output in order to determine whether or not to enable USB power via T1.


4

The Arduino assumes a US keyboard layout. The thing with keyboards is they don't actually send the letters or symbols that are printed on the keys. Instead the send a scan code that defines where on the keyboard the key is. It is then up to the computer to convert those scan codes into actual letters and symbols, and that is performed by the keyboard ...


4

They Keyboard.press() command accept modifiers per the documentation . You may need to do multiple press() commands before releasing. For example, if you want to launch Explorer you could use: Keyboard.press(KEY_LEFT_GUI); Keyboard.press('e'); Keyboard.releaseAll(); This is equivalent to shortcut keys windows + e The modifier GUI is what stands in for ...


4

The Leonardo is specified to provide only 50mA on the 3V3 pin. A ESP8266 can use up to almost 300mA when transmitting. Consider using a LDO regulator connected to the 5V pin instead.


4

32u4 is multi-serial uC. USB connection works on default serial communication which can be used via Serial.print("somevalue"). On the other hand if you want to use RX/TX on pins 0, 1 which are actually RXD1 and TXD1. So, if you use Serial1.print("somevalue"). So the answer is a yes. You can use USB and RX/TX (hardware serial) at the same time.


4

After a bit of tinkering, I noticed that removing the delay() call in the slave fixed it and there were no more hangs. Also, when using the Servo library to move a servo instead of blinking the led, Servo.write() hangs while Servo.writeMicroseconds() doesn't. I'd mark the answer that has an explanation for this strange behavior.


3

Try adding this to your setup routine: TXLED0; RXLED0; These macros (and their cousins TXLED1, RXLED1) are used to control the TX an RX LED's on Leonardo. They are defined in arduino/hardware/arduino/variants/leonardo/pins_arduino.h If that doesn't work you can try the solutions suggested here: http://forum.arduino.cc/index.php?topic=145262.0


3

The documentation for that library is recommending that you place a 100 pF capacitor between the sense pin and ground. However, I personally suspect you will get the best results when the user's presence affects at small mutual capacitance between a sense surface and a ground surface. One idea could be to have a large ground plane, and on it a smaller ...


3

Turns out that the Ignoring Bad Library Name error that I had been receiving regardless of if I ran Arduino IDE through command line or standalone was the issue. For whatever reason it was blocking the script with a dialog that then failed the upload regardless of if I manually moved through the popup. Final setup for those looking for this in the future: ...


3

I recently wanted to do exactly this. Since there is no nice way to do so, I wound up writing a patch for the Stino sublime-text arduino plugin to do exactly this. It's subsequently been accepted, so it should be in any up-to-date Stino installs. This adds a new option to Stino: Using this mode produces compilation results like the following: For a ...


3

You should be able to create your own board definition with a custom boards.txt file as per https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification. As I see there are several usb features in the leonardo's definition. I would hope that the compiles inclusion of the 4K is based off of these flags and not the processor type. ...


3

The inversion operator in C++ is ~. Serial.print(buttons, BIN); Serial.print(~buttons, BIN);


Only top voted, non community-wiki answers of a minimum length are eligible