Hi ,
I am still a beginner, so i will explain in details
I have Arduino UNO , NEMA23 stepper motor with a driver A4899 , 2 switches , 5k potentiometer , 2 * 10k resistor and power supply 12 v 10 A for Vmot , GND mot , power for Arduino UNO board .
I used the following code and wiring , when i power my power supply the Arduino UNO start smoking so i disconnected power , i test it with usb cable ( blink code , control speed only code at the end ) it's working , when use power supply it does not respond .
Can anyone check the code and wiring , UNO power problem ?
//direction and speed
int StartButton = 2;
int DirectionButton = 4;
int Enable = 7;
int Direction = 8;
int stepPin = 9;
int customDelay,customDelayMapped;
void setup()
{
pinMode(StartButton, INPUT);
pinMode(DirectionButton, INPUT);
pinMode(Enable, OUTPUT);
pinMode(Direction, OUTPUT);
}
void loop() {
if(digitalRead(StartButton) == LOW){
digitalWrite(Enable, HIGH);
}
else{
digitalWrite(Enable, LOW);
}
if(digitalRead(DirectionButton) == HIGH){
digitalWrite(Direction, HIGH);
}
else{
digitalWrite(Direction, LOW);
}
customDelayMapped = speedUp();
digitalWrite(stepPin, HIGH);
delayMicroseconds(customDelayMapped);
digitalWrite(stepPin, LOW);
delayMicroseconds(customDelayMapped);
}
int speedUp() {
int customDelay = analogRead(A0);
int newCustom = map(customDelay, 0, 1023, 400,2000);
return newCustom;
}

// speed
const int stepPin = 3;
const int dirPin = 4;
int customDelay,customDelayMapped;
void setup() {
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
digitalWrite(dirPin,HIGH);
}
void loop() {
customDelayMapped = speedUp();
digitalWrite(stepPin, HIGH);
delayMicroseconds(customDelayMapped);
digitalWrite(stepPin, LOW);
delayMicroseconds(customDelayMapped);
}
int speedUp() {
int customDelay = analogRead(A0);
int newCustom = map(customDelay, 0, 1023, 400,2000);
return newCustom;
}
