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

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

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

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

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

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

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

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

Look at how servo motors are typically controlled. As far as I know there are no servos that can just be "enabled to rotate" like you seem to expect. Usually a servo's position is set by applying a pulse of a specific length. This means you can apply a PWM signal with proper frequency. Then the duty cycle should be proportional to the servos position. From ...


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

With out knowing the demands of the motors (how much current they need under a given load) it is difficult to answer your question. But, in most Arduino designs: Motors are powered independently of the Arduino. And when Arduino Uno is powered through its USB port it should be realized that most common USB power sources are only obliged to offer up to ...


1

AccelStepper, as hinted by the name, uses acceleration always. By setting the acceleration high, you reduce the amount of time spent accelerating to the set speed. setAcceleration() sets the rate in steps per second per second. If your MaxSpeed is 200 steps per second, then setting the acceleration to 200*10 means all acceleration is over in 1/10 second. ...


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

The ATTiny has 5 usable pins (6 if you decide to reuse the Reset pin). Since it doesn't have UART hardware, you need to use a SoftwareSerial library to communicate with the HC-05. This takes 2 pins. To drive a motor, you need at least 1 pin. If you need to control it's speed (instead of just on and off), you would need to generate a PWM signal. Either ...


1

When I am getting started with my Servo motor SG90, I have experience the same issue, and finally I have solved the issue. I have used external power supply for Servo and my Arduino with laptop USB port and control signal from Arduino to Servo motor make my Servo motor to spinning continuously. Make sure ground reference of power supply of Servo motor and ...


1

In short, I ended up creating a library capable to drive multiple DShot600 ESCs: DShot-Arduino It still need a lot more polish, but the bit-banging works really well. SPI method I tried the method @dannyf mentioned, which involved combining 3 SPI bytes to form 1 dShot bit and it actually works. But there's a few problem with SPI: It takes up the ...


1

Although the 'Orange' (Out) pins of the Deek-Robot Motor Shield can be used to drive a servo by swapping the '+5vdc' and 'Signal' wires at the servo harness plug it is best to not do as this. This is because the current drive for the servo is drawn from the Arduino UNO. Given that an individual servo can draw well in access of 125ma the current draw may/...


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 ...


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