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