New answers tagged

1

I've got two arduinos, uno interfaced with mpu 6065 and 3 distance sensor working via i2c Protocol, the other Arduino is due interfaced with 17 scale weight. Eveey board works fine separately but when I tried to share data from uno to due through rx tx, I got scrambled data on due serial monitor , is there any solution? Thank you


1

Pwm is just a digital out with extra fancy on off controls. You can use any digital out if you do not need those extra features. To just signal a single H bridge (1 motor of your l289n) for forward, reverse, stop, one only needs two digital outs. I recommend you get the hang of your h bridge first - signaling it on a bread board with vcc (usually 5v but can ...


1

Short answer: No. Arduino Unos and Megas have PWM (Pulse Width Modulation) output, which rapidly turn the output on and off with a varying "duty cycle" (The ratio of on time to off time.) That is not the same thing as an analog output voltage. If you have a constant load you can build a low pass filter that will smooth the output to a slightly ...


0

The Arduino is a digital device; each output pin is either HIGH (+5v) or LOW (0v = GND), not in between. For certain types of devices (motors, LEDs) there is a technique you mentioned called PWM, pulse width modulation, which turns the output on and off rapidly. It's still just a square wave alternating between 0 and 5v but it's doing it really fast. So for ...


2

Static variables are allocated storage only once in a program lifetime The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it and you can't change const variable's value and i guess you know double is a data type that can save floating point numbers that line declare two variables ...


0

It's a good idea to declare variables the strictest possible way. So if you don't intend to change the value of LONDON_LAT at runtime, declare it as const. This allows the compiler to alert you if your code tries to modify it, and it often allows the compiler to optimize the code.


1

The start time will default to zero, so you could change it to: if (digitalRead(2) == LOW && start == 0) { start = millis(); }


0

You can use an external A/D converter, there are a lot of varieties in a lot of price ranges for the Arduino. Check your favorite online source. That will require two of your existing analog pins for the I2C interface but you will gain back many more depending on your choice. If you choose to use SPI that will take 4 pins.


0

The A/D simply gives a binary value between 0 and 1023. That value is evenly divided between reference and ground. Since it is a successive approximation register that starts counting at zero and counts up in consistent steps until the reference voltage is reached, that count is saved and presented as the reading. If your input voltage is in that range you ...


0

Adding capacitance to the input will help compensate for the high impedance but it also forms a low pass filter. For a 16 MHz Arduino the ADC clock is set to 16 MHz/128 = 125 KHz. Each conversion in AVR takes 13 ADC clocks so 125 KHz /13 = 9615 Hz. That is the maximum possible sampling rate, but the actual sampling rate in your application depends on the ...


0

There are certain pins that output a 3.3V signal when the ESP8266 boots. This may be problematic if you have relays or other peripherals connected to those GPIOs. The following GPIOs output a HIGH signal on boot: GPIO1, GPIO3, GPIO9, GPIO10. GPIO3: pin must high at BOOT and is pulled up to that position. I have no idea what will happen if low at that point. ...


1

You have to spend some time and practice coding, it does not come over night. As far as your timing look up for an alarm clock sketch that will do what you want. Once you understand that you should only have to add a few lines of code. As far as open source the tools you are using are open source. Remember there are people out there that are expertes and ...


0

This is a guess based on what I have encountered previously. With all the information given remember I just took a guess! Is it possible you are experiencing a serial flood, ie it is constantly sending something to the console. Take these steps several tries may be needed: Power off the board completely Remove the USB cable Hold down the Reset button keep ...


0

For me it was a matter of -B 10 instead of -b xxxx. So: sudo ~/arduino-1.8.12/hardware/tools/avr/bin/avrdude -P /dev/ttyACM0 -B 10 -c arduino -p m328p -C ~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -U eeprom:r:eeprom.hex:r


1

Finely i try the below code for serial mode. it's worked perfectly... type def union { unsigned char BYTE; struct { unsigned BIT0:1; unsigned BIT1:1; unsigned BIT2:1; unsigned BIT3:1; unsigned BIT4:1; unsigned BIT5:1; unsigned BIT6:1; unsigned BIT7:1; }; }ByteToBit; ...


1

The ADXL345 uses SPI_MODE3 and DPS310 the SPI_MODE0. The libraries for these devices don't use SPI transactions, but set the settings only in begin(), so they can't be used together. Your options to solve this is either to put one sensor on software SPI or to put one or both sensors on I2C. The ADXL345 can be used as I2C device. Its library supports I2C with ...


4

By default the fastLed is limiting the refresh rate to 400 fps (i.e. 2.5ms). You can disable that with FastLED.setMaxRefreshRate(0);


2

No fault is there in code. Rather, it was an faulty connection which prevented RTC module from working. Now, after restoration, the RTC module is working fine.


1

The circuit in the image shows the plan of the Arduino Uno, as you can see the GND pin under AREF and in the GND under the Power pin VCC are connected. you can double-check this with a tester and figure it out. so yes, they are internally connected. now, in your breadboard you have connected GND to VIN, that's the problem, Vin is an input voltage that is ...


1

Hmm the solution is how the code is written...no fancy stuff...the KIWI way //in setup function add tft.fillScreen(ST7735_GREEN); void loop(){ int lightIntensity = myBH1750.getLux(); tft.setTextSize(3); tft.setCursor(10,10); tft.setTextColor(ST7735_RED); tft.print(lightIntensity); delay(3000); tft.setTextColor(ST7735_GREEN); tft.setCursor(...


0

You are using Serial.println() to send the message. That function will add the combination \r\n as line ending to your message, which are the ASCII codes for return carriage and newline. In your receiving code, you read until \n, so your message now reads "0\r", which is of course not equal to "0". Thus the if condition will never trigger....


-1

I think the problem is that you have given the baud rate as 9200 but the minimum baud rate is 9600(Serial.begin(9600)). And change the baud rate in the serial monitor.


1

Explanation about the multiple time execution if ((Hour== 9 && Min== 14)||(Hour== 21 && Min== 0)) { for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits ...


0

Blynk.connected() returns true when hardware is connected to Blynk Server, so you can guard Blynk code with if( Blynk.connected() ){ // do Blynk things here } // Update the LCD anywhere outside of the above "if" statement.


1

The way I see it, the state should go back to IdleState if the button is not pressed. Just putting the switch-case inside the if-statement will result in the motor continue rotating the way it was rotating when the button is released. if (button1State == LOW ) { State = IdleState; counter=2000; } else if(button1State==HIGH && State==IdleState ) { ...


1

Historically it was necessary, yes. In times past the IDE would look only in your sketch to find the list of libraries to compile and link. However much progress has been made in recursive library searching, whereby the IDE can now find libraries that are included by other libraries. I am not sure when that change was implemented, but it was a long time ...


2

I think you may be confused as to what a "critical section" is. I see in your code where you are reading your button, but I don't see where you use it at all. To read your encoder with a critical section all you need is replace this: if( counter != temp ){ Serial.print("counter = "); Serial.print (counter); Serial.print(" ...


1

I changed it, so it at least compiles. int ledPins[]={3,4,5,6,7,8,9,10,11,12}; void setup() { for(int i=0; i < 11; i++) { pinMode(ledPins[i],OUTPUT); } } void loop() { int i = 0; while (i < 10) { digitalWrite(ledPins[i],HIGH); delay(100); digitalWrite(ledPins[i],LOW); i++; } i = 10; while (i > 0) { ...


2

The answer is in the register descriptions in the data sheet. You turned the output on by setting the COM2B1 bit in TCCR2A. TCCR2A = _BV(COM2B1) // non-inverting PWM on OC2B Turn it off by clearing that bit: TCCR2A &= ~_BV(COM2B1); Turn it back on again with: TCCR2A |= _BV(COM2B1); Have a look at the datasheet for the Atmega 328P chip (assuming you'...


6

As one of the comments said, you will need to use the EEPROM library. When you save a variable in your code (e.g. int test = 10;) the variable along with its value gets stored in the RAM. The EEPROM is a piece of harddisk on your arduino that will remember its value when you power off your arduino. If you implement a power-off button, simply save the state (...


0

according to this : it's more similar to I2C than SPI. anyway, it's just 2 wire custom serial interface. you can use any 2 GPIOs for this purpose. for sending a byte, you have to: initialize 2 GPIOS (CLK_IO and DAT_IO) to output, high. set DAT_IO low wait at least 1us (according to datasheet ver 1.1, page 18) then set CLK_IO low. place the D0 bit value on ...


0

when uploading the code, did you ensure disconnecting the Rx, Tx pins from the Arduino? Coz this is a similar error you get when you upload code with your comm pins connected. Try uploading the code with no wires connected.


0

I don't know about commercial drones, however your 'protocol' seems to be quite efficient, as it uses 4 bytes to send 2 values (e.g. U3F5) for Up with speed 3 and Forward with speed 5. Let's assume values from 0-7. Then you can send them both in 8 bits/one byte: H H H H V V V V Where H is the horizontal speed (from -8 (000) to +7 (111), in total 16 possible ...


0

Replacing your sketch with another doesn't actually "remove" the previous one. Is that really necessary? If you're trying to prevent the first one from executing, replacing it, as already suggested by @Juraj, is a simple and proper solution. If you need to prevent anyone ever being able to read any part of the previous one, you'd need to load ...


1

Alright I found the problem. https://www.youtube.com/watch?v=BM3A7w3bhqM&ab_channel=MERTKILIC In this video at 5:00 you can see the following: First you have to download the library, unzip it and copy the files inside. You will have to paste it to your Arduino/Libraries/DS3231 folder. On the left is the current DS3231 Library which I added through the ...


3

Just upload a new one. I frequently "blank" an arduino when I'm done with it by uploading "Blink.ino" from the examples included with the IDE. (The only reason I've had to remove old code is to avoid an issue where I might later wire up the Arduino in a way that is dangerously incompatible with the old code running on it.)


1

I see the problem here. Now observe the if(Serial.available>0) { //Block of Statements } Your closing bracket for that if statement must be after the switch() statement. For every iteration (void loop()) your command variable runs your switch and calls the enrolling function. So it should be: if (Serial.available>0){ //Block of statements Switch(...


0

There once was once something called an "Infinite USB Memory Drive" that acted as a thumb drive that read and wrote data to a networked share over wifi. They aren't selling those anymore, but their approach might be what you need - network share to resolve the issue of multi- device connected to same drive. In your shoes, I'd be looking at a ...


1

Floats in the Arduino IDE are normally 4 bytes. So you can work out with a calculator that your matrix will take at least 15 x 15 x 4 bytes (900 bytes). That is out of a total of 2048 bytes of RAM on the Atmega32. That may seem to be enough RAM, but other things, like the libraries, will also take RAM. I did an answer to a question about RAM a while back. ...


0

if (mySerial.available()>0){ You are checking if any serial data has arrived. Then you never read it. So naturally it is always available. You have a serialFlush function which does read it, however that function is never called. You need, however, to read more than one byte. Otherwise you will send an SMS for every byte in the input message.


1

For the hardware serial port, the buffer is 64 and I was reading at least 100 times. Every read will clear one byte of data from the serial buffer at a time. For the software serial port, you do a dummy read and then check whether the buffer is empty or not using while(mySerial.available()>0) { dummy = mySerial.read(); } So, in ...


0

Inspecting your code, it does not appear you are compensating the raw magnetometer values for soft and hard iron effects. These terms roughly refer to adjusting the range and magnitude of each of the individual magnetometers (X, Y and Z). Some magnetometer manufactures allow writing these compensation values into the chip. Even then the developer and user ...


1

I also had a similar problem running with an external power supply. In my case the sketch ran but totally incorrectly . Conected RX to ground with a 10K Ohm resistor and solved the problem. Thanks for the info!! Others have spent a lot more time solving this problem than I did.


2

Arduino always store the last sketch you have uploaded. Even if you disconnect your board and then replug it then it follow the same commands that you gave earlier.


1

The strip and the Arduino need to share the same ground connection. They are communicating through voltage and voltage is always a difference between two points. The power supply sets the supply voltage as the difference between + and ground. The chips in the strip will then try to measure the voltage on the data line relative to their ground. When the ...


1

Assuming you are using an Arduino Uno, You didn't say. As there are many Arduino platforms these days. As the tmrpcm library is using the PWM (Pulse Width Modulator) HW (Hard Ware) to recreate the sound waves from the WAV file on the SDCard, the PWM is not available for creating the sounds from your piano application (you didn't say what piano application ...


1

after 1 week of try i finally solved it :) As you guys know UNO has 1 i/o serial port, and Sparkfun's OBDII board doesn't work on same i/o serial port (at least i couldn't be able to), with uno when you send a command through serial to obd board you need to wait minimum 3 seconds to send another command or car's can-bus thinks that you canceled the first ...


1

You could try enclosing the Uno in a temperature controlled "oven", say a plastic enclosure with a very low power heater (even a suitable resistor might do) and thermo sensor in with it. It should reduce some of the variation in the crystal frequency.


3

Yes, the delay() will work, as will other methods based on the millis() counter. However, delay() will make it impossible to do something else in the meantime. Look up Blink without delay for an example of how to accomplish such a delay while being able to do other things in your code while waiting. Casting When dealing with large numbers such as your 24-...


3

delay() takes an unsigned long; I think what you do will work. When in doubt, you could always do something like this: for (int hours = 0; hours < 24; hours++) { for (int mins = 0; mins < 60; mins++) { for (int secs = 0; secs < 60; secs++) { delay(1000); } } } It will be wildly inaccurate ...


Top 50 recent answers are included