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


5

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

To better understand how you can do this it is good to understand first just what goes on when a button bounces. It is, literally, bouncing - just like a ball when you drop it. Due to the fact that it's either connected to ground or pulled up to +5V by the pullup resistor it's either going to be LOW or HIGH with very little time between when it's not in ...


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


3

The whole concept of Baud Rate with USB communication is completely meaningless. There is no such thing as "baud rate" over USB. What there is, and what you are confusing with "baud rate" is a configuration item which the host can send to the device which is a "I would like you to communicate with other devices at this speed" configuration item. This is ...


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

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

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

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


1

Yes, it is perfectly possible. You will need three things: The HEX file you want to program The programming utility for your chosen board (would be in the IDE folder somewhere - not sure what Teensy uses off hand) A text editor. Then, using the text editor, you create a .BAT file which executes the programming utility with the right parameters to program ...


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