Hot answers tagged

4

I don't know enough about how tapes work to comment on the sense of what you're doing, but some problems with the code: You are reading the input and setting buttonstate once only in setup(). You need to read it repeatedly, by putting it in loop(). You also have three variables called state: one global which is never set, and two with very restricted scope ...


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

On an UNO only certain pins are capable of PWM. Pin 12 is not one of them. When you try to call analogWrite with pin 12 it will recognize this and will simply call digitalRead for you with HIGH or LOW depending on whether your input is greater than 127. With most motor controllers you can use one pin as a direction pin and the other as a PWM pin. So to go ...


2

You have created a flow chart. When discussing state machines it is better to use a state diagram. In this state diagram of a turnstile (from the state machine wikipedia page linked to above) it is observed that the nodes (bubbles) contain the state of the turnstile and on the edges (arrows) is written the condition required to travel in the direction of ...


1

The problem was that the 2 pins on which the jumper sits, the jumper or the board was broken (idk exactly). I might've caused that myself by turning on the batteries + powering it through usb at the same time. I bought a new L293D board then made sure I didn't connect usb power to the arduino while the L293D was sitting on top of it. I uploaded the code, ...


1

Try lowering the rpm in the code. I had a similar issue with anything over about 18rpm using certain libraries with certain stepper motors.


1

No , your motor will actually get power from outside but the Servo Motor will be powered by arduino even if the jumper removed because the ln298 shield is mounted on the arduino.


1

From your code I would say, the problem lies within your loop function. The functions motorMoveForward() and motorMoveSide() are both over very quickly. But to actually move your motors need some time, before you change directions. Currently the motors rapidly change between driving forward and sidewards. Since in your motorMoveSide() function you only ...


1

Each state in the state machine should be a state in which the arduino will be for a time. Anywhere you would use a delay() or a blocking function or a busy loop will be a state. You can also use multiple orthogonal statemachines and mix them. For example 1 to control whether the motor needs to be driven at all and one to control which direction it is ...


1

Previously I was powering everything off of the 5V line on the Arduino, but I just switched to using an external battery pack of 4 AAs and that seems to work fine. That suggests, that your power source was not strong enough. You didn't say, how you are powering the Arduino, but I guess you are doing so via USB. The USB port of a PC can only give you 500mA ...


1

Here the proper answer: The vast majority of devices are constant-voltage devices. They need a constant operating voltage to work correctly. Microcontrollers are such devices. When operating, they will try to draw as much current from the power source, as they need, but not more. Much like a simple resistor with an applied voltage will draw a specific ...


1

Read the documentation for both boards. They should list the pins used. Their associated libraries will define variables to which you can assign non-conflicting pins. Review the sample code provided as well. Usually, the sample code included setting the pins to use, even if the code only sets them to their default. There is another possibility. I don’t ...


1

If you are using l293d you must control the voltage on its ENABLE PIN rather than controlling it on other INPUT PINS (l293d). Here is simple tutorial on controlling the Motor using L293d. here. And @VE7JRO is right about map() function as your are passing the values that are out of range please take care of that part as well.


1

analogRead() returns an integer between 0 and 1023. Using 30 and 400 in the map() function, then passing in a value outside of that range will cause strange results. Here is a sketch to illustrate my point. void setup(){ Serial.begin(9600); // Prints -20 to 684 for(int i = 0; i < 1024; i++){ Serial.println(map(i, 30, 400, 0, 255)); } ...


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


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