The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

5

Yes, that is how C and C++ (and most other C-like languages) work. Variables have "scope". Any variable define inside a pair of curly braces (between a { and a }) is only visible inside those braces. If you want to reference a variable in both setup() and loop(), you have to make it a global variable, defined at the top of your code. #include "Servo.h" ...


4

The VIN pin goes to a 5V voltage regulator on the Arduino and needs at least about 7V minimum to work properly. If you want to supply 5V to an Arduino do it either on the 5V pin or via the USB connector. The VIN pin should receive 7V to 12V.


3

If you are controlling an AC pump, you might look into a PowerTail switch, which allows you to control AC power easily and relatively safely, but of course, if you are working with anything around water, be careful! http://www.powerswitchtail.com/


3

As noted by markshancock, you are using an older version of the Adrafruit Motor Shield library meant for the version 1 of the board (you have the version 2.3), and according to their forum they are not compatible (they use different communication protocols) use the newer version of the library https://forums.adafruit.com/viewtopic.php?f=31&p=276888


3

The encoder attaches to the motor (or other) shaft and sends a 10-bit rotational position for a precision of 0.35 deg, and a claimed accuracy of +/- 0.7 degrees. It will be up to the application to keep track of number of rotations, detecting when the shaft has completed a rotation in either direction. In a lead-screw application there will always be a ...


2

In theory, it should work to control the speed of fan. The manufactures description mentions "fan regulator". One of the pictures shows on the backside of the module that it is for 2 A (5 A peek). This should be good for 230 V / 100 W motor. The module gives you a basic circuit to control AC. It reports zero-crossing and has an optocoupler switch to turn AC ...


2

It won't work, as you don't give it any time to do anything. The PWM works about 1kHz and motor needs much more time to start rotating. And you are sending values as fast as possible (it means microseconds for every analogWrite) And analogWrite(300) without changing the Arduino default settings means it overflows to value 300 % 256 = 44. All Timers are set ...


2

I would suggest finding sensors that work on an I2C bus. This way all the sensors are only using two pins for data. That will free up other outputs for motors, heaters that will probably be on relays or other drivers that need a single or multiple pins for each devices. As you start to plan it out, if you do run out of pins on a arduino uno, look at the ...


2

Your project is pretty simple, and Arduino can handle it easilly. (Pretty much any microcontroller could do it) It's true that only ome program can be run at a time on Arduino (same as on 99% of other microcontrollers) but that one program can handle all three conveyors at the same time. Though I suggest using 3 different Arduinos and separating the systems. ...


2

You cannot control the "V3" output. It's a 3.3V power supply output. Think of it like a battery. It's always on and always giving power. Instead, you need to add a "switch" to control that power that the ESP8266 can itself control, such as a MOSFET or a motor driver (H-Bridge).


2

OK. Looks much better now. And I see one problem. It seems that the normal way to do the speed control is with a pot. A variable voltage at the input depending on the rotation. The Arduino low end designs have an analog out capability but it really is not analog. It is a pulse width variable signal that produces an on percentage between 0 volts and the CPU ...


2

Note: Since all vendors (checked Mouser, Octopart, and Sparkfun) link to the L298 datasheet when listing the L298N I will assume they are reasonably equivalent. I will assume that the "12V-35V input pin" is the V_S pin, despite that label. There are only two supply pins on the L298 with the following electrical characteristics: V_S, Supply Voltage, pin 4, ...


2

Depending on the type of stepper motor the answer can be "Yes" or "No". There are two types of stepper motor: Unipolar and Bipolar. Bipolar motors typically have 4 wires and require a H-bridge to drive them. The L239D is a popular (and cheap), though inefficient, H-bridge that is commonly used. But it is possible to build your own H-bridge from discrete ...


2

For an infra-red remote control you generally can't. Those don't normally have the concept of button release. Normally there are two kinds of buttons on a remote: Burst code Repeat code The first sends a short burst of the same code. This allows for a function to be run once per button press. The second sends the same code over and over again constantly ...


2

The Vref potential should not be 24V. As mentionned in the datasheet: Vref = 0.3V to 1.95V depending on what you want.


2

Possible hardware solution: Consider using 2 battery packs. One connected to the Arduino and the other connected to the motor drive board. Remember to connect the grounds of the 2 battery packs together. Possible software solution: Software is often over looked when solving what appears to be a hardware issue. Consider introducing a short pause between ...


2

You can't just connect random pins together like that. Connecting two output pins together is a recipe for disaster. Best case scenario: nothing works. Worst case scenario: you break one or both Arduinos. Only one Arduino can control a servo. If you want a second Arduino to make something happen to the servo you have to make it tell the Arduino that is ...


2

The commands you are using don't match the ones listed for this board. Here is the AF Documentation for the Motor Shield Board V2. Try #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h" Adafruit_MotorShield AFMS = Adafruit_MotorShield(); Adafruit_DCMotor *motor = AFMS.getMotor(2); void setup()...


2

if we are in level 1, both the levels 2 and 3 are pressed it should go to level 2 even if level 3 was pressed first. For this to work, the program should remember which buttons (mind the plural!) have been pressed. Thus, instead of remembering only one request, as in int required_level =-1; it should have a boolean variable for each of the possible ...


1

Callback function must be data send from server to the ESP. Payload is the data byte sent from server. Length is the size of data in bytes. BTOF is basically byte to float converter which converts all the data byte received into single floating variable and return that floating point value. ECS.write must be the function that write the value to the servo ...


1

I guess this is a kind of debouncing problem, caused by noise on the interrupt pin. The behaviour might also get worsened by the disalignment you mentioned. You could verify this by manually rotating the shaft, even though you "get the blinks" I doubt they are accurate in count. If that is the case there are two things you could do: add a capacity or a RC ...


1

I think reason for which you are not getting the expected result is because of you while loops in you if condition. As you loops doesn't have any termination condition. In case of first button pressed you will get what you want because you have only single not terminating while loop, while in you Case of button 2 and button 3 there are two while loop's and ...


1

I assume from the 0, 10, 20 …. 120 series, that you want to have a linear ramp to the desired speed. This can be done really easily, if your requirements are not to high. First we define the interval, in which we want to update the speed, and a constant acceleration, that you can choose. The current speed will be saved in a global variable. #define ...


1

why exactly is there only one power supply being shown here, is it because the Arduino can get its power from the driver? No. It is assumed that you will provide the power to the Arduino yourself - either through the USB connection to the computer, or through the barrel jack. The thing I want to know, is whether this circuit would function without an ...


1

This is the common issue when trying to connect power and digital circuits together. Probably, when motor starts, there is a short-time voltage drop in Vin due to high motor start current. Consider to use Schottky diode and capacitor to protect digital power circuit from transitional currents.


1

Resetting is due either to a software bug or voltage sag, and since it correlates with driving the motors harder, it's almost certainly the latter. You probably suspected as much since you mentioned the current draw of the sensor array. A quick experiment - disconnecting the sensors (and possibly a software patch to keep the robot running straight, without ...


1

What seems is that you are facing an power shortage while working with on board power supply. While running DC motors and Arduino on same battery set your Arduino is not getting enough power. Try switching to a better power supply which can maintain a constant EMF, as eventually you'll always run out of power. Try an adaptor to use wall socket current. This ...


1

For those looking for more information on PWM in arduino, a must see page is this one: http://www.righto.com/2009/07/secrets-of-arduino-pwm.html. Once you read it you may undestand, what is software and hardware PWM and which are the limitations. To do the software PWM the servo library takes over one of the three arduino's timers. So pin 9,10 are not ...


1

Have you read the Servo library page? The library support upto 12 servos outputs. You can use any pin you want. The library disables analogWrite() (PWM) functionality on pins 9 and 10.


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