Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

7

You are not initializing x and y. When a local variable isn't initialized, it will "inherit" the value contained in the register assigned to the variable by the compiler. The fact that your single loop example worked is pure luck - the assigned register happened to contain 0 at that point in execution. Change your nested loop like this: for (int x = 0; x &...


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


4

According to the documentation, SysEx messages are sent like any other messages: array[0] = 0xf0; array[1] = 0x7f; array[2] = 0x7f; array[3] = 0x02; array[4] = 0x7f; array[5] = 0x01; array[6] = 0xf7; usbMIDI.sendSysEx(7, array);


4

After correcting the syntax error (missing semicolon) I tried your code on my Teensy 3.0. The results look OK to me: Start... 1250 2250 Finished 1000 milliseconds elapsed Start... 2250 3250 Finished 1000 milliseconds elapsed Start... 3250 4250 Finished 1000 milliseconds elapsed Start... 4250 5250 Finished 1000 milliseconds elapsed Start... 5250 6250 ...


4

You can't just "print" a key like that. You use print for sending text. When you use println it sends an enter key along with your text, so you can do : Keyboard.println("ls -al"); and it will send the text ls -al and press enter for you. If you want to do it in the 'raw' way you will need to press and then release the key: Keyboard.press(KEY_ENTER); ...


3

Paul Stoffregen (Teensy creator) has released a command line version of the Teensy Loader which can be found on his website. However, this program appears to be Linux only, so unless your client has Linux, that may be a non-starter. The source code for the program is available, so you might be able to work out the logic and port it over to whatever platform ...


3

Using the latest Teensyduino distribution as of this writing, 1.25, you have to uncomment the higher overclocking options in the boards.txt file, located here in my install- /hardware/teensy/avr/boards.txt The options look like this, just remove the # symbol- #uncomment these if you want to try faster overclocking #teensy31.menu.speed.168opt=168 MHz ...


2

Arrays in C/C++ are handled as a pointer. That means the value of the pointer is the location in memory of the first element in the array. The next element is at that starting address, plus the size of each element. So for an array of 1-byte characters, each item in the array is at the very next address. For 32-bit members, it's at +4, and so forth. You'...


2

Here are a few examples how to pass vectors and variable number of arguments to a function in C/C++: void foo(int* vector, size_t nmemb); The function foo takes a vector of integers and the number of members, nmemb. const size_t VECTOR_MAX = 5; int vector[VECTOR_MAX] = { 0, 1, 3, 5, 7 }; foo(vector, VECTOR_MAX); The next variant is generalization. A ...


2

If the list is a static list you could conceivably pass a pointer to it in the constructor. Example: class myClass { const int num_; const int * values_; public: // constructor myClass (const int num, const int * values) : num_ (num), values_ (values) { } // other stuff here // demo void printThem (); }; // end of class myClass void ...


2

Actually, Majenko's diagram assumes the interplay of the pullup resistor forces the line back to a HIGH position (as quickly as the internal transistors can overpower the drop from the switch). If the switch itself is mechanical with a pullup resistor (external or internal), then the only thing "bouncing" is the switch. If you use a digital switch, the ...


2

If compatability is what you are after I would say go for the Due. If good products are what you are after, go for the Teeensy. The Due, being a real Arduino, will have the best software support and forum community and thus the best chance of getting existing libraries to work with it. The Teensy, because the project really centers around one guy's ...


2

No. You should provide your own regulator or supply for the servos specified voltage. This might be an original design, or an off-the-shelf "battery eliminator" intended for an R/C vehicle of similar needs. Note that the teensy regulator's maximum input voltage is fairly low, and may be in the range of what more powerful servos expect, ie, you might be ...


2

This is starting to drift off topic for this site, but the best solution for making an automated programming utility for the Teensy on Windows, short of writing one yourself, would be to use some kind of UI automation framework to automate the process described in my earlier answer. My favorite one that I have used in the past is AutoIt. It has tools to ...


2

Shared memory only makes any sense in two combined situations: You have a kernel arbitrating processes, threads and memory allocation, with process isolation You have multiple threads or processes in your application You certainly don't have number 1 unless you can install an operating system on the Teensy 3.1 (some RTOS may provide a SHM analogue). As ...


2

In your loop(), you increment repeatedly loopnumber without ever resetting it. You should at the very least replace loopnumber++ ; with loopnumber = (loopnumber+1)%2560 ; Otherwise, when loopnumber becomes >= 2560, your save() function will begin writing outside the 'everything' array and overwriting whatever is written in the adjacent positions of ...


2

Without the ground of the teensy connected to the ground of the fan all you will be measuring is noise. Ground is required to complete the circuit between the teensy and the fan.


2

The Cortex M does not "have RAM at 0x2000000". The Cortex M is just a CPU. It is down to the chip manufacturer where they choose to place RAM in the memory map. In the case of the MKL26Z64VFT4 used on the Teensy LC: The on-chip SRAM is a single contiguous block split into two ranges: 1/4 is allocated to SRAM_L, and 3/4 is allocated to SRAM_U. Regardless ...


2

Your best bet is to try to take the casing off until you find a company name so that you can get a lead on where to look for documentation. Because until you find out more about how that screen works, it's a black box to you and you don't know what to put in it. No one else will be able to help you until you provide more information to this extent because no ...


2

[Completely rewritten answer] That seems fun. But why 65 keys ? with 64 keys it is easier. You have to test the sensitivity of the hall switches with the magnets to know how far apart the keys must be. Perhaps they only work with strong magnets or perhaps a number of them are activated when the glove is near. With hall switches, there are 65 digital ...


2

Once per second? I don't see any problem, I will try to calculate: 3 ports: send + receive 255 bytes, let's say 270 bytes (with start/stop bits, probably way too much) per message: 3 * 2 (send + receive) * 270 = 1620 bytes 4th port: 50 * 6 bytes = 300 bytes Total: 1920 bps The serials can easily keep up with this, so that is not a problem. 90 MHz is 90 ...


2

First of all, do you really need int values for the measurements or not? If not, and you have numbers between 0 and 255, switch the values to byte, your microcontroller will thank you. Then, there is a problem with the other answers, which is... The variables cannot be left uninitialized!!! You can use this code to get the info you need: (I also put the ...


2

As Juraj rightly points out, you have a typo, which should give you the following compile time error: In file included from sketch/Sensor.cpp:1:0: Sensor.h:17: error: 'pivate' does not name a type pivate: ^ Here is the correct code for Sensor.h #ifndef Sensor_h #define Sensor_h #include <EEPROM.h> #include "IMU/L3G.h" #define CUTOFF_FREQ 30 #...


2

If you can configure the PWM to run at 111 Hz (I don't know how this is done on the Teensy), then “gating” it is as simple as turning the PWM on and off at the desired frequency: uint32_t half_period; // half the gating period in microseconds void set_gate_frequency(float freq_in_hz) { half_period = (1e6 / 2) / freq_in_hz; } void loop() { ...


1

I spoke with an electrical engineering about how to take an Arduino prototype to mass production, and he warned me that the code written in the Arduino IDE cannot be fused onto the processor. That's nonsense. The output from the IDE compiler is a .hex file which is then sent via avrdude to program the board. If the output cannot be "fused" onto the ...


1

Arduino code is AVR code. There's no real difference. The only thing is that Arduino's tend to use bootloaders, which might cause a problem. But in your case I'd advice to not use a bootloader anyways. Since you plan to build a lot of them, you probably want to use bare ATMega chips, and not arduino boards. Bare chips don't have a bootloader to begin with. ...


1

Arduino code and AVR code is essentially the same, at least once compiled it is. The only real difference is the existence of the bootloader, and that is not essential. For quantities of a hundred or so it is probably most cost effective to manually program them via an ISP connector to the board. For larger quantities Atmel provide a mass programming ...


1

The simplest solution is to ask you client to install the TeensyLoader application. https://www.pjrc.com/teensy/loader.html Send the new HEX file to the client. The client should then connect the board to the computer. Run the TeensyLoader and upload the HEX file. The TeensyLoader will recognize the board when the reset button is pushed. The HEX file will ...


1

Yes. Teensy has a command line loader available at https://www.pjrc.com/teensy/loader_cli.html or https://github.com/PaulStoffregen/teensy_loader_cli Given the hex file, the teensy_cli client could upload it without giving your client the source code. For non-teensy devices, avrdude could be used similarly. Alternately, one could fork the cli code, ...


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