New answers tagged

1

Basically you have to make the animation loops return if the condition is met, for example: void doAnimation1() { for(int i=0; i<10; i++){ if (digitalRead (button1) == HIGH) // Time to stop? return; neoPixelStrip.setPixelColor(neoPixelArray[i], neoPixelStrip.Color(255, 0, 0, 255)); neoPixelStrip.show(); ...


1

"How to interrupt the loop function and restart it?" You don't. That's not how you write Arduino code. You need to have your loop function call a series of non-blocking functions that check to see if it's time to do something, do a very small bit of work if it is time, or just return if it's not time yet. What I've done is to create a class ArduinoObject ...


1

It's zero because you never assign it a value. Here you are comparing the current value of data (0) with the results of your calculation: data==(scale.get_units()/10); I think you intended to use the assignment, not comparison, operator =: data = (scale.get_units()/10);


0

Electric shocks aren't an issue for low voltage (<24V) appliances. Which is why a lot of items now use external power bricks because if mains voltage never touches the device it is easier to get approved for electrical safety. Avoiding fire is a bit more tricky and mainly involves being able to dissipate any heat buildup before flammable stuff gets too ...


1

strtok modifies the char buffer entered as first parameter. It replaces the delimiters with terminating zeros. To parse a constant string with strtok, you must first copy it into a working char buffer. For your test you can initialize a char array as in following example. char payload[] = "setBrightness: 15"; uint8_t brightness; void setup() { Serial....


1

I can see you are on Linux so I won't give you instructions for using AVR Studio - but do know that if you have access to a Windows machine that is another option you could try. I can't tell you exactly why it is not working through the Arduino IDE - it could be that the settings are not set correctly or any number of reasons. What I can say is that it is ...


0

Which model of Arduino? The design of most models has circuitry that handles getting power from both the barrel connector and the USB port, and switches between them intelligently. Thus the answer should be "no, no problem." However, what else does your 12 adapter power? You might want to post a full circuit diagram of your project. Also, as Juraj says, ...


0

You sure now Serial.write() and Serial.read(). That's already what you want. A hint to make it clear to you: When using the common Serial.print() function only the RxD line is in charge an thus only "half" of the serial interface is used. If you connect TxD of arduino A to RxD of another arduino B and RxD to TxD respectively you have full-duplex ...


1

You cannot call methods outside of a function. Move lcd.createChar(0, character); into setup.


0

You forgot Wire.begin();. You should add it in setup(). Wire.begin(); will configure the IO pins for I2C usage. Without that the signals don't get in or out of the MCU, so I2C functions that wait for an ACK signal never see it and don't complete.


2

There are also a couple of ways of including assembler code right inside your Arduino IDE. By including the assembler in the Arduino IDE, the assembler source is assembled and linked into your project and uploaded to your Arduino from within the IDE - just like any other program. This makes it easy to get started with Assembler while still retaining the ...


1

Nick Gammon's code worked fine for me. Here is an oscilloscope picture of the waveform I've got from his code: His code above (from Nick Gammon, on Jan 25 '16 at 20:33) worked excellent for me. I used his code on Arduino UNO and got about 7.9 MHz of output frequency on an approximately 1 V amplitude (peak-to-peak, with spikes making it go to about 2 V peak-...


2

This is a bug in the compiler (linker) used by the Arduino AVR Core. It's not because of a bug in your code, and there's not much you can do about it except using a different version of the AVR Core. See this forum post: Here's the traditional workaround: Tools > Board > Boards Manager Wait for downloads to finish. When you move the mouse ...


1

It "needs" to be done in assembly as an assignment, right? Otherwise you would "want to learn" assembly. What I suggest you do is change the C program to use port manipulation, for example: void setup() { DDRB |= 0b00100000; // D13 to output mode } void loop() { PORTB |= 0b00100000; // turn on D13 delay(2000); PORTB &= ~...


0

This is a classical application for LoRa technology, not WiFi. Designing a LoRa mesh is no simple task, though. Check this post, or this other post


0

I don't know about SK9822 LED strips, however the other type of led strips can be used with every pin; this is to support multiple LED strips. Because every LED strip has its own CLK input (wire), it would be inconvenient to share them... I'm not sure if it is possible practically, because the timing is critical and if you have just one 'master' CLK signal ...


0

Are you sure every led is 60 mA? Or you mean maybe each Red, green and blue led inside each led (3 x 20 mA). You always should buy slightly more than you need (but you think about 200W instead of 135W) already which is more than enough safety overhead. Why would you need more? If you mean to control it with an Arduino Uno, that MCU (including the LEDs etc) ...


1

The cable you point to is fine for programming the ESP8266. The only reason it's not "good" for an Arduino is the lack of a DTR signal to trigger a reset for you - which you can do manually anyway and still use it for an Arduino (if your reactions are fast enough). You have no such problem with the ESP8266. Once you have it in bootloader mode it stays in ...


1

See my answer here. A 12V battery doesn't necessarily provide you with 12V any more than a 1.5V battery provides 1.5V. See here for example. A 12V lead-acid battery may well provide 12.7V which is out of spec for the Uno. See the page about the Uno. You have too much voltage going into the voltage regulator, it tries to dissipate it, it gets hot and ...


0

If I plug in a 12V source, then the voltage between the 5V and GND pins starts out around 5V, but then starts dropping rapidly. In the meantime, the underside of the board heats up a lot. If I plug in the USB source, the voltage between the 5V and GND pins stabilizes at around 4.28V ... but again, nothing seems to work. That sounds like the LDO is ...


6

Once again an example to Why should I learn C/C++ first before learning Arduino. The main point here is: know your data types. Your calculation millisec*frequency/1000 would work if it was a compile time constant that is evaluated by the pre processor. In any other case this is a runtime value and so the limitations of the datatype apply. Unless stated ...


3

In the case, that this is a school assignment and you actually have to program directly in assembler, you probably don't want to directly convert your C++ sketch. It will generate way more assembler code, than is really necessary for alternatively blinking two LEDs (for example digitalWrite() contains not only the actual writing to the corresponding pin ...


0

Try this method to convert your sketch https://sourceforge.net/projects/arduino-to-assembly-converter/


0

First you need to know what you are going to display the image on. That will dictate what library (or choice of libraries) you need to use. From there you can find out what facilities your chosen library has for displaying image files. For the Arduino a common library is u8glib. Or there is the Adafruit_GFX based library family.


0

Yes it is possible to read for instance a BMP file from a SD and write to an LCD/TFT. A small buffer at a time as the Arduino Uno has only 2K byte SRAM. Cheers! PS: Here is an example https://github.com/mikaelpatel/Cosa/blob/master/libraries/Canvas/examples/CosaCanvasBMP/CosaCanvasBMP.ino


0

Probably since you set the cursor at a position in the middle of a line, only the new text is overwritten over the old text. But if there are some characters from the previous text, those will stay. So the easiest way is to either clear the screen (if you can do the updating of the screen from a single place), or rewrite the entire line (and probably having ...


1

In your approach a button press will be detected every 100ms when you just keep the button pressed. So you have to set a flag when the button is pressed. When the button is not pressed while your flag is set, that's the event you're looking for. In this way you can detect both a button press and a release respectively. As @JRobert mentioned, there still has ...


0

When the output-enable(OE) input is low, all outputs are placed in the high-impedance (Hi-Z) state. You must connect the OE pin to logic high to enable the outputs.


0

A new chip cannot be programmed in that manner until it has the Bootloader installed. The Bootloader starts after a reset and monitors the serial interface to see if something is attempting to download code via the serial port. Selecting a Programmer has no effect on serial download, that only comes into play when Programming via the SPI pins SCK/MOSI/MISO/...


3

I suggest you modify the LiquidCrystal "Hello World" sketch: Here is the example code: // include the library code: #include <LiquidCrystal.h> // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4,...


4

Variable names MUST NOT start with a digit. Only '_' and a-z are allowed! 1cd really should be lcd with an 'ell' instead of a one (1).


0

For example... unsigned long long servo_timing[2]={0,0}; int A_data=0; void servo_ini() { Wire.beginTransmission(0x20); Wire.write(0x00); // address bank A Wire.write(0x00); Wire.endTransmission(); } void servo_set(unsigned int servo_tim,bool servo_mod){ if(servo_mod==1){ servo_tim=map(servo_tim,0,180,200,1900); } //if(...


5

On the Uno unsigned int is a 16 bit number. That means, that it can hold values between (and including) 0 and 65535. If you try to write a bigger value to this variable, it will cut of the higher bits, so that the rest fits into 16 bits. That gives you a totally different value, which is significantly small than 24h. The solution is to use a bigger variable ...


1

Don't use the voltage divider and never set the Uno pin HIGH. Pull io 0 of esp8266 LOW with pinMode of the Uno pin. pinMode(TO_ESP_IO0, OUTPUT); // sets the pin LOW pinMode(TO_ESP_IO0, INPUT); // let it to the io0 pull-up resistor


0

You said... avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding Those errors are occurring because you are attempting ...


1

There's some heavy String usage in that library, would not recommend it for anything you want to be stable, especially with an Uno. The library seems to create a connection by first clearing the SoftwareSerial buffer and then issuing the right AT command. It waits for 500ms for a response before giving up. I suspect the wait interval is sometimes not long ...


0

I don't see any connection between the sensor's GND and your Arduino's. This is likely the problem if they're not connected, since a common GND is necessary even with RS-485. Check the sensor's power supply, make sure it's actually within the advised 10-30 V range. Also check the polarity of the differential lines. Have you tried using the provided ...


0

I would suggest you simplify your setup to the point where you have a 'working baseline configuration', and then start building the system up one step at a time from there. Start by eliminating the SoftwareSerial interface as a possible contributor to the problem. Get an Arduino Mega with multiple hardware serial ports. Next, verify that you can send ...


0

Both power supplies are suitable. The actual 12V/24V current required is not comparable to what the driver current is set at, since the stepper motor coils do not have those 12V/24V across them. My first 3D printer came with a 12V 5A power supply, which proved suitable for simultaneous use of four stepper drivers, the control board, a display, and the ...


1

This indicates your IDE is missing the "Adafruit Unified Sensor" library as outlined here. To install it, select "Tools" -> "Manage Libraries" and search for "Adafruit Unified Sensor". You can install the library by selecting it and pressing "Install".


0

Try changing the order of these: SPI.setDataMode(SPI_MODE1); //SPI.setClockDivider(SPI_CLOCK_DIV16); SPI.setBitOrder(MSBFIRST); SPI.begin(); I think SPI.begin() needs to be started before the other two calls. Instead of digitalWrite to control the chip select, use Direct Port Manipulation, much faster. Does the ADC support 8 MHz SPI clock? From 7....


0

Using I2C (which i recommend over serial), you may not use a NodeMCU ESP8266 as a slave. It can only function as master. An Arduino, on the other hand, may be either. Therefore, the Arduino will always be passive and the NodeMCU will be the master. What you can do, is implement a sempahore (as described by Majenko here), where the Arduino signals that it ...


0

These lines digitalWrite(LEDARRAY_LAT, HIGH); //锁存数据 delayMicroseconds(0.1); digitalWrite(LEDARRAY_LAT, LOW); delayMicroseconds(0.1); Scan_Line(i); //选择第i行 digitalWrite(LEDARRAY_G, LOW); delayMicroseconds(100);; //延时一段时间,让LED亮起来。 Reduce the time in the last one. I don't think ...


3

As one can see from the pinout description page (https://learn.adafruit.com/adafruit-lsm9ds1-accelerometer-plus-gyro-plus-magnetometer-9-dof-breakout/pinouts): So this board is literally designed to be powered by 3.3V and 5V and have compatible logic levels for both these voltage ranges, which is what every Arduino known to me and the Raspberry Pi use. ...


2

There are two solutions that come to my mind, one more HW based and another more SW based. Solution 1 The HW way is to let the programmer control the LCD through 2:1 multiplexer(s). You will need to connect the LCD pins to the common pin of the multiplexer, the Programmer's ones to one of the two inputs and the Worker's to the other. Then the programmer ...


2

I ran into almost the same problem in an educational context. If the I2C bus has a line stuck low, the program hangs in the wire library. In my application everything is soldered together, but not always properly, so I can get by with a single test at startup. Before invoking Wire.begin. For the OP's issue, they will want to use this every time they restart ...


1

"It rotates little bit forward like 10% extra with 3.1 sec delay," "I just want to rotate the motor from the home location to the home location when I give signal one time. But i do not know what time delay should I use?" More than 2.0 and less than 3.1! If 3.1 sec gives 110% rotation, then you need (100/110)*3.1 = 2.818sec to get 100%. I realize ...


3

Time for a crash course in electronics and power: The 5V pin only ever provides 5V. That's why it's the "5V" pin. (assuming, of course, that you give the board more than 5V). In simple linear electronics you have three values: The voltage The current The load Generally two of the three are either "fixed" or "known" and the third changes depending on the ...


0

My guess is, that the function RemoteXY_Handler() has to be called very regularly (without long pauses in between) to communicate with the app on your smartphone, or the app will think, that the communication is lost, and disconnect from the robot. This means, that you cannot use long delay() calls in your code, since that is just busy waiting. In your code ...


1

The "Serial Monitor" is merely a window to the Arduino's serial port. You don't have to use it to use Serial. It's just a (very simple) built in way of seeing the data. You can use the Serial interface with your own software, or with third party software. It's not tied to the Serial Monitor in any way at all. So: Use Serial.print() etc to send data to the ...


Top 50 recent answers are included