10

ok, once I got the idea I would need to do it in code, it became simpler to solve. In looking around the terms of quantization, the term thresh-holding came up, and I realized how to solve the problem. I created a threshold value, and compared the difference between old and new variables. int threshold =3; int xVariance = abs(sensorValX-oldX); int yVariance =...


9

Several options here, and a couple folks have pointed out some challenges. "Best" answer -- probably to use a real-time clock (RTC) board to assist your timing, and effectively set a target time (next motor run is at 23:14...) each time the cycle restarts. By saving this target off (to the EEPROM or an SD card for instance), you'd protect against ...


6

First of all: The Arduino IDE brings its own GCC compiler. It is a version, that can compile for the AVR platform (don't know, if the standard version is capable of that). When you activate verbose output for compilation in the preferences of your Arduino IDE, you can actually see, what calls to GCC the IDE is doing. You could use that to replicate it. If ...


6

Remove the analog component from your device. Use a rotary encoder. It will sense the knob rotation digitally. One huge advantage is that you can easily select the sensitivity of the input. One click can advance the counter by .001 just as easily as advancing by a 1000. https://duckduckgo.com/?q=rotary+encoder&iar=images&iax=images&ia=images


5

If I understand correctly, you wrote an example code that switches an LED between two states (on and off), and you are stuck because the actual problem you want to solve is more complex than that. And indeed, it seems to me that you want to manage a system with three possible states: it can be on or off but, when it is off, it can be ready to turn on if the ...


5

When you cast a floating point number to an integer, it always gets rounded towards zero. If you want round-to-nearest behavior, you should use the Arduino round() function. As to the origin of the discrepancy you see, it comes from two facts: The numbers you use are not exactly representable as floating point numbers. The double on an Arduino Uno is ...


5

Assuming, the program can stop after playing 6 times, put another for loop in the loop function: void loop() { for (int nTimes = 0; nTimes < 6; nTimes++) { // Existing loop code } while(true) {}; } A less crude way is to create a global variable: int _timesPlayed = 0; And change the for loop: void loop() { if (_timesPlayed < ...


5

This line: TIMSK = (1<<OCIE1A) | (1<<TOIE1); enables a couple of interrupts generated by Timer 1. Whenever you enable an interrupt source, you should make sure that the matching ISR has been defined. Otherwise, the interrupt request is routed to __bad_interrupt(), which by default jumps to the reset vector, thus resetting your program.


5

Some methods for "dealing" with the noise: Take multiple samples. Calculate the average ("mean"). Discard the decimal. This is "oversampling" along with resolution reduction (but reduction of the now increased oversampled resolution). Take multiple samples. Find the most common value ("mode"). Divide the value by 2 (...


4

You could bridging via Firmata: https://playground.arduino.cc/Interfacing/Ruby/ Another resource is https://code.tutsplus.com/articles/using-ruby-to-program-arduino--cms-21893 You will need to Flash your Arduino with Firmata and then program in Ruby. I'm not sure if that would work with Crystal.


4

You can try implementing a counter system in your Arduino program. For example, if this is your loop() function: void loop(){ int buttonState = digitalRead(1); // Give the variable buttonState the value of pin 1, or whatever your button is connected to static int counter{}; // Have a counter variable. Static means it doesn't reset to 0 after loop() restarts ...


4

Cool I got it using avrdude. $ avrdude -c arduino -P /dev/ttyUSB0 -b 9600 -p m328p -U flash:r:CNCArdunio.hex:i > -c the platform (basically) > -P the port where your harware is. > -b the baudrate. > -p the chip architecture. > -U momory type flash :r option to read to file :i option to format into Intel HEX. caveats.Upon closer inspection ...


4

There are a few issues at play here. One is that the Arduino resets every time you open the serial connection on the PC side. You can prevent this by putting a 1 µF (or more) capacitor between 5V and RESET. A second issue is that the tty driver may be keeping old data in its buffer, and you get this data when you open the connection. The third issue is that ...


3

We work with Proculus displays, and we are a distributor of this display here in Brazil (Victor Vision). The display is great, very professional. Used in medical equipments, and cheaper than Nextion. They are starting now in the web and selling in Alibaba.


3

You should make Servo Servo_Pointer; global, i.e. place it outside the setupfunction, e.g. after the line int average = 0;. In your code, it is a local variable within the setup function. When this function ends, the local variables within this function (such as Servo_Pointer ) do not exist anymore. By making the variable global, you can use it anywhere. ...


3

If using optimization, the compiler is smart enough to recognize this. Since your example is so short, it could be optimized away entirely. To ensure that doesn't happen, the results in c and r have to be used in some way. Also, if a and b could never change, the values of c and r would be calculated during compilation. Therefore, I put the calculation in ...


3

Most of the data is duplicated between the registers. Both registers contain MSP[6:2]. If MSP contains 111001001 the registers (ignoring the MSB "PAR" bit) would look like: SR3: 1110010 SR4: 1001001 If we line those up it's then like: SR3: 1110010 SR4 1001001 You can now see the overlap. So taking SR3 and shifting it left two places (sr3 <&...


3

The question is somewhat confused, but I think I got what you mean. Your code suffers from too much repetition. You only showed the handling of two selectors, but you want to handle 6 of them. Repeating all the logic 6 times would make the code unwieldy and hard to maintain. So you want to put the logic in a function and just call that function six times. I ...


3

Thank you all for your contributions. I managed to find the issue and solve the intermittent reset. I was expecting to find a hardware problem as the root cause, but just in case it was software related I wanted to check as well. It turned out to be hardware Gil is certainly questioning the correct piece of hardware. It was indeed the wiring of the Prox ...


3

In this example your missing a semi-colin after int buttonPin = 2, and your if statement should probably look like this if (buttonValue == HIGH){ digitalWrite(lightpin, HIGH); }//red else{ digitalWrite(lightpin, LOW);//red }//red/* Also if you go into the examples in the Arduino IDE, under "digital", this sketch is called button.


3

Using delay() for a 6-hour delay is a bit awkward, but perfectly doable. It will, however, not be very accurate, because the accuracy depends on the accuracy of the Arduino's clock, and it will block all other code you may wish to run. Using timing with millis() would allow your Arduino to do other things while waiting. It will be just as inaccurate, though. ...


3

Since this is for an incubator, I suspect that you don't need high precision. So delay() will work perfectly well, if you don't want to do anything else in the meantime (like maybe monitor temperature, control a heater, and/or light LEDs for over/under temperature). In that case you could use a loop that handled all those operations at some convenient rate ...


3

Using roundf() function: float rounded_temperature = roundf(temperature * 10) / 10;


3

The failing is not with your code. The failing is with the MPU6050_6Axis_MotionApps20.h library. It erroneously has code in the header rather than in a separate CPP file. You have done everything right. The author of that library could do well in taking a leaf out of your book. To get it working you will have to move the code out of the header file into the ....


3

The problem is, that you are filling up the Serial buffer rather fast, because you try to send ASCII numbers every 10ms at only 9600ms. When the buffer is full, Serial.println() will wait, until there is enough space free in the buffer for the current data. That makes your loop lasting significantly longer. In that case the time, where the time is exactly 10 ...


3

It's not exactly clear what you're trying to do, but I think you want to start the vac and start the stepper, then 4 seconds later stop the vac. The 4 second delay forces the rest of your code to wait (doing nothing) during the 4 seconds. Look at the Arduino IDE example program, BlinkWithoutDelay. The technique used there is what you need to use instead of ...


3

Hadn't pushed the button all the way in lol


2

I'm not sure if you ever solved this issue but for me this error was occurring because the ATmega4809 chip was not powered on. By adjusting the wiring I managed to get rid of the "RSP_NO_TARGET_POWER" error. So I would suggest double checking wiring and then use the "Upload using programmer" (in "Sketch" tool-bar menu) to upload ...


2

For your current issue (turning LEDs on and off after 1s / 2s, much of your code can be simplified: int ledPin = 2; // Number of the LED pin int ledState = LOW; // ledState used to set the LED unsigned long TimeLedOFF = 0; //Time at which the LED was last turned off unsigned long TimeLedON = 0; //Time at which the LED was last turned on ...


2

I'm assuming you will be using the Arduino millis() function for keeping time. The output of the millis() function in the Arduino environment is a 32-bit unsigned integer*. A 32-bit integer can be split into 4 x 8-bit bytes. To keep things simple you could program the Java receiving side to always expect 4 bytes (or whatever amount you need, see *). Assuming ...


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