Arduino DC Motor Speed And Direction Control using Relays and MOSFET
อุปกรณ์
- Arduino Uno
- Two 12v relay( 5v relay can also be used)
- Two transistors; BC547
- Two pushbuttons
- IRF540N
- 10k resistor
- 24 volt source
- 10K potentiometer
- Three diodes 1N4007
- Connecting wires
Diagram
Code
int x;
int y;
void setup()
{
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(6,OUTPUT);
pinMode(A0,INPUT);
}
void loop()
{
x=analogRead(A0);
y=map(x,0,1023,0,255);
analogWrite(6,y);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}
Credit By : https://circuitdigest.com/microcontroller-projects/arduino-dc-motor-speed-direction-control
ความคิดเห็น
แสดงความคิดเห็น