New answers tagged

0

TL;DR: You really need to know what components you have and you need to find datasheets. In the datasheet, you find what voltage the component requires. Don't care too much about amperes in the beginning. If you get the voltage right, each component will just draw as much current as it needs. An Arduino Uno operates from 7 to 12 Volts, so 7.4 V is ok. "...


2

To round to the nearest X in fixed point arithmetic: add 1/2 X (in the base units, msec, in this case) and divide by X (again, in the base units) so: milliseconds = (milliseconds + (30*1000L))/(60*1000L); The addition of 1/2 X causes a carry of one whole X if the fractional X in the original quantity was 1/2 X or greater. (Likewise, if the fractional X was ...


-1

Here's another version using only integer arithmetic: unsigned long milliseconds = millis(); unsigned long millisec_quo = milliseconds / 60000; unsigned long millisec_rem = milliseconds % 60000; unsigned long minutes = millisec_quo + (millisec_rem < 30000 ? 0 : 1);


0

Those sensors have no units. If you can find a schematic you could possibly relate the value to the resistance of the soil, but you'd need to know the resistance that the soil is paired with to form the resistive divider. All you can say from the numbers is "This is wet" or "This is dry". Normally you would use trial and error to determine what the values ...


0

(https://i.stack.imgur.com/Rm3On.jpg) you can simply connect one in the A0 and the other in the A1 since all those pins can be used for the same function


0

AO is not "Ay Zero", it's "Ay Oh", and stands for "Analog Output". It means it just sends a varying voltage. It really doesn't care where it's sent to, it just sends it. It's up to you where you connect that output to. But suffice it to say it wants to be connected to an input that can read an analog signal. And the Arduino has 6 of them. Which one you ...


-2

I guess that rounding within the language requires declaring as double or casting to double (and then, if required, casting “back” to unsigned long). Rounding is not a process conceptually associated with integer arithmetic. The results are not always easily predictable. I give an illustrative example for rounding non-negative numbers in your context. (The ...


0

Here is a simple trick how to switch from integer math to floating point math and use round function. unsigned long milliseconds = 599999; unsigned long minutes_long = (milliseconds/1000)/60; // minutes_long = 9 double minutes_double = (milliseconds/1000.0)/60.0; // minutes_double = 9.99998... double minutes_rounded = round(minutes_double); ...


0

From your comments: I want the while loop to be there and I somehow want to stop it, is that possible? => yes - press the reset button.When I started programming some decades ago one of the basics was NEVER use while loops.Why? Because you might run into deadlocks like your code does. Options: Check inside the while for a state change/input to break ...


1

If you are transmitting Hello and receiving Fh'Fx**-H3r:AJb6# E0CbJ, then the problem is most likely a baud rate mismatch. The receiver is sampling the data signal 3 or 4 times faster than it should. Start by lowering the baud rate of the serial monitor to 1/4 of the current baud rate. If that does not produce correct data reception, then start at the ...


1

As already written in the comments the software defines what G-Codes are taken by a (printer) boardBUT Even if the software has the same name (eg Marlin) it might behave different on different boards because of: different release versions for different hardware different release repositories being ahead or behind the master repo hardware specific features a ...


0

Arduino Uno has 3 ports. You can read and write the ports as 1 byte. With all the switches on one port, you can read them all at once. For example, using D7 to D3 to read the switches: switches = (PIND & 0b11111000) >>3; // read D7 to D0, mask off D2-1-0, move data to lower 5 bits Then you could have case (switches): for the 0 to 31 cases that ...


1

If all are handled the same and they don't have individual names, arrays and for loops are what you are looking for. const byte relayPins[] = { A5, A4, A3, A2, A1, A0}; const byte ledPin = 3; const byte swPins[] = {5, 6, 7, 8, 9}; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); for (const byte relayPin: relayPins) pinMode(relayPin, OUTPUT)...


0

I cleaned up your code a bit. Removed duplicate and unused code. I used a for-loop to make it run for 100 repetitions. Feel free to let me know if you have any more questions, or if there are things that aren't clear. // You aren't using these libraries, so I commented them out //#include <AccelStepper.h> //#include <MultiStepper.h> int ...


0

See my post https://www.fpaynter.com/2020/03/arduino-spi-data-exchange-between-two-arduinos-in-a-master-slave-configuration/ for a newbie's take on the problem


0

I want to ask a question. You don't need to tell us. Can i communicate 2 esp module like xbee ? You can make two ESP8266 modules talk together, yes. It's not "simple" like an XBee, since you have a generic WiFi network interface, so there's many many different ways of doing it. Typically one would be running as a WiFi Access Point (SoftAP) and the ...


2

Probably the first time because you received the character '1' or '0'. The second character is probably a '\0' or '\d', an end-of-string or end-of-line character. You can easily check this by printing the value of each received character, like Serial.println((int)(BluetoothData)); You probably see the value for '0' (48), '1' (49), end of string '0' of ...


0

I too have had this problem with a Mega. It was working with my SCADA package, running on linux and you could ping the Mega/ Ethernet board, but then something changed, and it wouldn't run/ read using the ehternet port. Had two units, and both behaved the same. When connected to the programming laptop ( runing W7) and the ethernet port, and running serial ...


1

Long to Integer conversion will overflow the value and you'll get values in negative numbers. Define the pauseLength as unsigned long to make it work.


2

The Arduino Uno cannot use the Keyboard library. The microcontroller needs to have a native USB interface. The Uno uses the Atmega328p, which does not have one. You can use the Arduino Micro or Arduino Leonardo for this. For more experienced hackers: If you need to use the Uno, but still want to use extended USB capabilities (more than USB to Serial), it ...


2

You are mixing ASCII characters and integer values. The serial data is a pure binary stream, a series of bytes. It is up to the programs on both sides to interpret, how these bytes are meant. When you type 1 into your bluetooth serial app, it already does this. It complies to the ASCII standard, which gives a meaning to every binary value between 0 and 127. ...


1

Thanks for the help, this is my working code. I changed things to long, got rid of some long's, stopped passing variables, and forced number in sensorValue to be long. It now counts up and down were I set the potentiometer every minute. int analogInPin = A0; int analogOutPin3 = 3; long sensorValue; int i = 0; int a; long y; void sens(){ sensorValue = ...


1

When using if(BT.available()) that's doing the same as if(BT.available() > 0) But then you are reading 2 bytes, though you cannot be sure, that there are 2 bytes to read. The data is transmitted serially, so even when you send it on your phone in one bunch, it does not get transmitted as bunch. Try to use if(BT.available() >= 2) Also makes sure, ...


2

You define i,y,i as global variables so there is no need to hand them over to different functions. They can be accessed and changed in all parts of your program. define instead of int y; change to long y; and change void inOut(int &i){ to void inOut(){ and remove return i;// Its a global var change the line unsigned long y = ((...


0

The UNO can't be a Keyboard. It doesn't have a real USB connection. It has a serial connection that passes through a UART to USB converter. You cannot use the UNO as a keyboard. Instead you need one of the boards that has a real USB connection, such as the Arduino Leonardo or any of the other ATMega32U4-based boards.


1

If there are no other constraints, send them as a text with delimiters and a terminating character. e.g. something like "123;45;678\n" On the arduino, either manually check for those delimiters and convert the digits to a number on the fly, or use strtok and atoi after reading the whole line.


1

I asked this question to be moved to Stackoverflow as it is not Arduino related. However to answer your question, you assign the booleans before you start the program, so they are never re-evaluated and always keep their initial value, based on when x = 0. What you should do is, reevaluate them within the loop: int x = 0; boolean state1; boolean state2; ...


1

At first, I had similar behavior with the servo motor in this project. The servo buzzed and either did not move or made very slight erratic movements. The problem in my case was that I had wrongly placed the wire that is supposed to connect the potentiometer to pin A0. Here's how my board looked after I corrected the problem:


0

What's happening is that you've written a fraction in a way that the compiler treats it as integer math. C/C++ truncate fractions, so 255/100 is just 2 (and if any of the rest of those are integers, they cause truncation too). What you want to do is make some number in that calculation a decimal--it doesn't matter which one--or cast an input to a float with (...


2

You need either a memory extension for your UNO - projects like Arducam did this way back 2016 and then used an OV2640 module. If you want to develop something yourself these are the steps (hurdles) to take: Get a datasheet of the camera Design a circuit including plug for Camera and a memory module (min 512Kb) Attach it to the UNO Write a library/...


0

Alright, I finally realized that RPM value was too low. It has to be at least 150 for my case.


2

For measuring oxygen saturation (SpO2) with a pulse sensor, you need to use the fact, that hemoglobin, that carries oxygen, will reflect in different light wave lengths, as hemoglobin, which doesn't carry oxygen. But that also means, that you need to use light in at least 2 different wavelengths. Common are one red (about 660nm)(though green may also work) ...


0

You could easily set the LED output LOW just before you call going_to_sleep(), and set it HIGH when going_to_sleep() returns. There would be two short periods where the LED signal would indicate sleeping but the processor is running: between the LED going LOW and the processor actually entering sleep; and between the processor waking and the LED going HIGH. ...


1

You have probably installed the box servo backwards so that when it tries to open it actually closes and vice versa.


2

The IO doesn't require the clock to keep its current state. It only requires it to change state. There is no real external signal provided by the chip to indicate if its in sleep mode or not. However you could monitor the current consumption of the chip and when it drops below a certain threshold you can assume that it is in sleep mode.


-1

We have to add 1k resistors and 2k resistors as 330 ohms instead and follow the link below..!


0

After I waited to get my order on ebay. I managed to restore the bricked board. The issue was related to bootloader fail. either the producer shipped it without a bootloader or some kind of static discharge caused to erase or stop the booloader from working and that why windowws didnt detect the board. I used a converted cortex m3 to swd programmer debugger ...


0

firstly, move your pinMode() settings to setup section. in your code, when the temperature is 21 active pin will be 6 and 8. you should rewrite your code in next ways: 1: if (t < 22) { ... its cold temp ... } else if (t > 26) { ... its hot temp ... } else { ... it's nor temp ... } 2: if (t < 22) { ... its cold temp ... } if (t > 26) ...


1

This is not a complete answer, but an idea of how to accomplish the task. I just typed it in without testing the code. Use arrays to hold variables. That way a loop can be used to service the three sensors and the three LEDs.. for (i = 0; i<3; i++) { currentTime = millis(); // ...


0

I don't think you can use pins 9 and 10 they are connected to the internal mSPI flash, uart0 is connected to FTDI usb chip, use uart2 on 16 and 17.


1

You code shows multiple errors: At the start you are commenting the SmartInventor library out. You need this library. You should delete the comment markers /* and */ around the #include statement. At the end of the code you have < SmartInventor.h / >. You should delete this line. It is simply wrong, not even C/C++ syntax. You seem to misunderstand, ...


0

There are multiple ways you can solve it. The easiest way to do it is by just adding one more line in your code. static bool stringComplete = false; String x; String slevel; static int level; static int n; void setup() { Serial.begin(9600); } void loop() { if (stringComplete) { Serial.println(level); Serial.println(n); ...


3

This looks like something out of an Arduino n-part “sensor kit”. It’s hard to tell because the quality of the image is not very good. My guess is, this is an analog temperature sensor, like in this link, part number 18. You can also find an example sketch there.


0

Either set the watchdog to 8s, and setup the WDT interrupt. And deal with the fact that the MCU wakes up every 8s. You could have it go back to sleep, unless a button is pressed, or something. The extra power usage for these short wakeups is negligible in most cases. Or disable the watchdog right before sleeping, and enable right after waking up. And hope ...


1

Here is what you have asked for: I am making home coming/leaving light for car. First i want that whenver i press car key lock a timer will start for 10 second.And if i press button twice within 10 second pin 13 will high remain for 10 second and if i cant press the button it return to the void loop aor condition may get false. I am working on it ...


0

When you sleep the Arduino is locked up. So yes, the watchdog timer will time out and reset the Arduino. But, since you're in sleep mode, it's not so much a "reboot" as a "wakeup". The watchdog timer is one of the normal ways of waking up periodically to do things. If you want to use the watchdog for its other "anti-lockup" purpose then you will have to ...


0

I have no access to a compiler, so there might be errors. #include <WiFiEsp.h> #include <MySQL_Connection.h> #include <MySQL_Cursor.h> #ifndef HAVE_HWSERIAL1 #include "SoftwareSerial.h" SoftwareSerial Serial1(2, 3); // RX, TX #endif byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress server_addr(192,168,x,x); char user[] ...


0

Almost certainly not Compilers often optimise switch statements using jump tables. However the entries in the jump table basically make up a lookup table with 214 entries! So you don't gain anything. Some ideas for compression You can use bit packing If your numbers aren't 8 bits in size, you can pack them together. For example, if you have managed to ...


1

214 is 16384 entries. Each entry takes 2 bytes. That's 32768 bytes. That's all the flash the ATMega328P has. The most efficient storage will be an array in flash, and that will take 100% of it. Using a switch will take more space. So in short: no. Just no. It won't work whatever you try. You need to come up with a radically different storage solution (...


1

The main problem is, that the module does not get any supply voltage. You connected the Unos 5V to the OLED boards 5V. But this pin doesn't seem to be connected on the OLED shield. It is marked with 5V there, because this board is a shield to be stacked onto the Wemos D1. When you do this, you have 5V on this pin from the Wemos and can access it on the OLED ...


Top 50 recent answers are included