Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int MotorPin = 3;
- const int PotPin = A0;
- int PotVal=0;
- int Speed=0;
- void setup()
- {
- pinMode (PotPin, INPUT);
- pinMode (MotorPin, OUTPUT);
- Serial.begin (9600);
- }
- void loop()
- {
- PotVal = analogRead (PotPin);
- Speed = map (PotVal, 0, 1023, 0, 255);
- Speed= constrain (Speed, 0, 255);
- analogWrite (MotorPin, Speed);
- }
Add Comment
Please, Sign In to add comment