We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

You are continually incrementing the pin variable via pin++, but you are never resetting it to the start (2?) when a new number is to be written. So it might work the first time but never after that. Also, you clear the display with digitalWrite(pinNumb[i],LOW); But you turn segments on with digitalWRite(pin,....); pin++. Shouldn't you turn the segments on ...


1

Looks like my tone frequency was possibly just too high for the buzzer I was using, causing strange output. Adjusting the clock divider fixed the issue. That is, I changed the following: TCCR2B = _BV(CS20); // clk/1 to TCCR2B = _BV(CS22) | _BV(CS20); // clk/128 and now I get reasonable-sounding tones. Note that the clock divider you choose is ...


2

I tried the code on an Uno and as you say, it does sound odd. By my calculations, the frequency is 40kHz (16MHz/(200 x 2)), which is above the threshold of hearing. The sound we are actually hearing is probably the 3rd or 5th harmonic, at a reduced intensity and perhaps subject to jitter. I tried changing TCCR2B = _BV(CS20); // clk/1 to TCCR2B = _BV(...


0

8915Hz - it is very close to 125000/14 ~= 8928.6 My initial guess that exactly one gap is required between adjacent conversions One ADC clock for sampling and 13 ADC clocks for conversion itself. Small error could be effect of not perfect clock source of Arduino. I am not sure yet. This topic is actual for me now as sampled data must feed digital filter.


0

Just add some delay between irrecv.decode()s and everything will work just fine.


0

These can all be byte instead of int to save on memory: int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8}; int num_array[11][7] = { { 1, 1, 1, 1, 1, 0, 1 }, // 0 { 0, 1, 1, 0, 0, 0, 0 }, // 1 { 1, 1, 0, 1, 1, 1, 0 }, // 2 { 1, 1, 1, 1, 0, 1, 0 }, // 3 { 0, 1, 1, 0, 0, 1, 1 }, // 4 { 1, 0, 1, 1, 0, 1, 1 }, // 5 { 1, 0, 1, 1, 1, 1, 1 }, // 6 { 1, 1, 1, 0,...


1

You call function num_Write a lot, you create a forward declaration: void num_Write(int); But you forgot to create the implementation. If you would have forgot the forward declaration the function would not be known at all (and you would get a compiler error). But with the forward declaration you let the compiler know the signature of num_write (so the ...


1

Remove the & in the master code line, change radio.read(message, sizeof(message)); to radio.read(message, sizeof(message)); message is an array, so either you should pass the address of the first character (&message[0]), or simply pass message. Another problem is sending a String in the slave code (using type String). It's better not to use ...


0

Why do you compute tempc only after you print out the value in serialOutputWhenBeatHappens`? You also forgot to read the temperature continuously. Here is how I would do it: void loop() { // read the sensor before it is printed on the LCD vout = analogRead( sensor ); // here I'm not sure what you are computing // you map the sensor voltage to ...


1

Code seems to lack a repeating update of tempc via vout =analogRead(sensor); An alternative might be changing the line for setting tempc to be tempc=(int) (analogRead(sensor) * 500.0f/1023.0f);


0

The else case is executed every time the other if and else if conditions are not true. That means if it is not 5 sec and not 30 sec and no button is pressed, the relay is switched off. To achieve what you want is not that easy, because you have to synchronize button press and button release with the timer actions. First you must specify what you exactly ...


1

I added pull-up resistors to the board and it started working. Turns out that the boards weren't well designed and the I2C lines were pulled up to 1.8V instead of Vin. By removing the pull-ups and adding pull-ups to Vin, the circuit started functioning. The circuit worked with Mega because it has in-built Pull-up Resistors.


0

The only explanation I have is, that the Software serial switch off the interrupts globally when it operates (print). If interrupts are locked when the timer completes, you loose a tick. It does not explain the different behavior of the four value pairs, but there are some issues reported in a german forum. They did not find an answer, but the assumed it ...


0

step 1: define your MIN_DISTANCE, MAX_DISTANCE step 2: get distance from sensor step 3: rescale the distance value to a value in between 0 and 255 step 4: fade led according to the rescaled value. Note that: you should not use delay() to blink LED. Use analogWrite() instead. See the example. We can change frequency of PWM to make LED from fading to ...


0

I would say the way to go is using non-blocking code with millis(). Look into the BlinkWithoutDelay example, that comes with the Arduino IDE. It doesn't use delay(), which is considered bad coding practice, since it is just busy waiting. Nothing else can happen during a delay, except for interrupts. Instead of waiting it is better to regularily check the ...


0

You didn't include any code for us to see what the actual issue is, but I'm willing to guess that you didn't take into account that the run command requires repeated firing. If your program comes to a point where there's an instance of runToPosition, the blocking function stops the program until the stepper reaches the position specified. When your program ...


0

Under-voltage detected! I think it says it all. Rapsberry have many times problem to feed itself from "common power source", not mentioning attached devices. Especially, if you power your LEDs from it too. You need better power source for Rapsberry (and maybe even power it from pins, but then you need read much more to not damage it) and other powersource ...


-1

You can use timestamp to avoid the blocking code. See BlinkWithoutDelay example


1

OK, I found one little mistake in my coding. I forgot that the writeTo function also receives a pointer and I have to pass an array for both read/write functions. void mcp23017_read(uint8_t *add_reg, uint8_t *buffer){ twi_writeTo(MCP23017_ADD, add_reg, 1, 1, 1); twi_readFrom(MCP23017_ADD, buffer, 1, 1); }


1

I don't know how this lib works. But I'm pretty sure that you have to pass a pointer onto the data variable into the twi_readFrom method. uint8_t mcp23017_read( uint8_t add_reg ) { uint8_t data; twi_writeTo( MCP23017_ADD, add_reg, 2, 1, 0 ); // I inserted an & below twi_readFrom( MCP23017_ADD, &data, 1, 1 ); return data; } ...


0

Consider enlarging your character arrays. When creating strings an extra character is likely necessary to indicate the end of a string. This is usually the null character or zero. If missing, many string related features will not see an end of a string and likely cause unexpected results.


0

This kind of button has 4 pins. These pins are internally connected in pairs. It's easy to make a mistake when wiring. Please post the real picture of your wiring. Or you can refer to read more about button pin in this post


1

The Crystal in Red is for the Atmega16U2 that manages the USB interface with its high speed connection to the PC (12 MHz for USB2 I think). The Resonator in Yellow is for the Atmega328P. It is less precise than the crystal oscillator. PB6 and PB7 are dedicated to the external crystal or resonator by the fuse settings used for Arduino. You can read ...


0

The ground of both computers are connected also via their power lines. You get a ground loop that might result in malfunctions and/or defects. Think about using a galvanically separated connection, for example via an optocouple.


0

You define pointers for each value as : char *matrix[numChars]; //matrix of data entries However, in all cases you let it point to data: matrix[i]=data; Than you set the value starting from that address. So what happens is after you read the first value (11), and matrix[0] contains '11', than matrix[1] points to the same data which you write the value ...


0

Yes they connect to the crystal. There's two of them because a crystal has two pins.


0

i have sum code please visit my https://forum.arduino.cc/index.php?topic=645080.msg4363292#msg4363292


0

I tested your code as it currently is with my own HC-SR04s and a clone Arduino Nano (since that is, what I have here currently). It works like a charm. The values are rather good, maybe accurate about +-1cm. I checked in the change between 10 and 70cm with my desk plate and a wall as obstacle. (I just looked, if the values are plausible. I didn't investigate ...


2

You SHOULD pay attention to the following issues: 1. Floating input problem: Symptom: the reading value from the input pin is not matched with the button's pressing state. Cause: input pin is NOT used pull-up or pull-down resistor. Solution: Use pull-up or pull-down resistor. See Arduino Button (with pull-up/pull-down) 2. Chattering phenomenon It ...


2

It is likely you are experiencing problems associated with button contact bounce. This is where the processor is so fast that it "sees" the button make several contacts when the user only intends for 1 contact to be seen by the program. Consider using this button de-bounce library instead of reading the state of the buttons directly in the sketch. The code ...


1

The Serial output on an Arduino is quite slow. By printing your output, you will slow down the readings so much that it will appear to be nonsense. You should collect a series of readings into a C array of floats in RAM, stop recording, and then log that array of values. Note that you don't have a lot of RAM to work with on most Arduinos, so you will only ...


0

First: Your code would not work, since servo is not defined and thus not an array to iterate over. You would need to first define the array and then fill it with Servo elements. Servo servo[11]; void setup(){ for(int i=0;i<11;i++){ servo[i] = new Servo(); } } The different Servo objects are created dynamically. In most cases it is bad ...


0

Consider using a specific processor / Arduino-board. In this thread there are references to using the Arduino 1280 board with the Arduino Servo Library to control up to 48 servos using a combination of hardware and software. In C++ when you "instantiate" a class you are making good use of memory space as you do not really create duplicate code. All you ...


2

Most Arduino boards come with a bootloader of some form. This bootloader may do things with IO pins. However apart from that, no, nothing else happens to any IO pins. The bootloader may: Flash pin 13 (built in LED) Configure and communicate on pins 0/1 (UART) With no bootloader then absolutely nothing happens on any IO pins.


0

in your nodemcu use void loop() { if(s.readBytesUntil('\n',data ,2)>0) Serial.println(data); delay(1000); } Serial.readBytesUntil(character, buffer, length) Serial.readBytesUntil() reads characters from the serial buffer into an array. The function terminates (checks being done in this order) if the determined length has been read, if ...


1

I am not sure but may be it helps just by checking principle of working of this sensors as it is depicted for low range distance you must be carefull about reflection from other source of ultrasonic. I think it would be a good Idea to place a delay between these two module so to make sure it get less noise from each other FindRange(trigPin1, echoPin1); ...


1

You are using Timer/Counter 1 in Fast PWM Mode with TOP set to OCR1A: OCR1Aonly describes the number to what it counts up so, 0…391 in your case. You have to define the duty cycle with OCR1B. 50% would be 195.


0

The working principle of HC-SR04 is based the reflection of ultrasonic wave. Therefore, It measures distance inaccurately in the following case: The obstacle is something that can adsorbs the ultrasonic wave. For example, cotton wool. The obstacle is faced in non-90-degree. In this case, the obstacle may reflect the ultrasonic wave to another direction The ...


0

In the loop you trigger trgPin1 then trigPin2 but in the first range find you read echoPin2 instead of echoPin1. void loop() { FindRange(trigPin1, echoPin2); duration1 = duration; distance1 = distance; FindRange(trigPin2, echoPin2); duration2 = duration; distance2 = distance; Serial.print(distance1); Serial.print(" cm "); Serial.print(...


1

If you send "12" you send 4 characters/bytes: '1', '2' and a new line which is two characters: ('\r', '\n'). On the receiver side you check for two characters (not the new line), so you should take it into account. Actually, since you will eventually reach "100" you will receive 5 characters ('1', '0', '0', '\r', \'n'). So it is better to change the ...


0

16U output: Atmegmode off. 0xFF 0xFF 0xFF F0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Programming mode off. 0xFF 0xFF 0xFF F0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Programming mode off. Atmega chip detector. Written by Nick Gammon. Version 1.20 Compiled on Nov 4 2019 ...


0

If my supply increase from 12V 1.5A to 4A. My arduino will draw around 800mA @5V (571mA @7V) plus solenoid 1.2A @12V, is it a good idea to get 12V 4A (48W) power supply? Since Filip Franik told me that it is a good practice to get 2 times the current I need just in case. I know there is the efficiency of the converter is calculated by dividing the output ...


1

To me it seems, as if you have no knowledge about C/C++. ( I might be wrong. ;-) ) If you plan to do more programming projects, I advice you to learn the basics of this programming language before proceed with the projects. It would be hard thinking about an algorithm, if you don't know the tools to implement it. In case you just need this once for a (let'...


0

For data communications the problem is often more complicated than DC resistance. Data signals are AC, and subject to impedance, (not simple resistance) inductance, and capacitance, as well as RF interference. A pair that's fine for slow on/off switching of DC signals may not be fine for higher frequency data signals. You can also get intermittent shorts ...


1

Sure, no reason that wouldn't work. For best results you want a known resistor of about the same resistance as, or a little below, the one you are measuring. However, if what you are seeing is an actual open circuit then there's little benefit to measuring the resistance - you may as well just treat it as a switch or button, give it a large pullup, and use ...


1

The problem is that serial.write will block if the buffer is full. Only until the bytes get sent out through the TX pin. If I skip writing if the buffer is full, a receiver will only get old data on the first connect. No it won't. There is no "old" data. How can I replace data in the buffer or make sure there is only one dataset in the buffer? You ...


0

i didnt solder my light sensor and it had the same error, as it was just resting on the pins, try pushing it up so the sensor makes contacts with the male headers or just solder them :D


3

So you want to use the 5V voltage regulator on the Arduino serve as the supply for your 5V components, and feed the 5V regulator from the 12V supply that powers your solenoid? The problem with that plan is heat. The voltage regulator on the Arduino is a poorly heat-sinked (heat-sunk?) "linear" regulator. A linear voltage regulator is basically a solid state ...


0

Consider defining exactly what you want your Arduino application to do using a state machine approach. Drafting a state machine diagram allows a developer to visualize the inputs to the state machine, the number & types of states necessary and the outputs of the state machine. The following diagram from the above wikipedia.org link has two states: A "...


0

@jonas I had a similar problem not quite exceeding the limit. One item you can do is move the strings to Flash. <pgmspace.h> there is the definition of PSTR which will place the literal in flash the patternname, which we normaly just use strcpy, we need to use strcpy_P. strcpy_P states the string will come from Flashmemory and copy it into SRAM space. ...


Top 50 recent answers are included